ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing
ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing

All Courses

Calculus Fundamentals for Machine Learning
Chapter 1: Why Calculus for Machine Learning?
The Role of Math in Machine Learning
Introducing Functions: Inputs and Outputs
Visualizing Functions: Graphs
What is a Limit?
Intuition Behind Limits
Connecting Functions and Limits to ML
Quiz for Chapter 1
Chapter 2: Derivatives: Measuring Change
Rate of Change: Average vs Instantaneous
The Derivative: Slope of a Tangent Line
Derivative Notation (Leibniz and Lagrange)
Calculating Derivatives: The Power Rule
Calculating Derivatives: Constants and Sums
Introduction to Higher-Order Derivatives
Practice: Calculating Simple Derivatives
Quiz for Chapter 2
Chapter 3: Optimization with Derivatives
Finding Maximum and Minimum Points
Optimization: Why Minimize or Maximize?
Cost Functions in Machine Learning
Goal: Minimizing the Cost Function
Introduction to Gradient Descent
How Derivatives Guide Gradient Descent
Visualizing Gradient Descent
Quiz for Chapter 3
Chapter 4: Handling Multiple Inputs: Partial Derivatives
Functions of Multiple Variables
Partial Derivatives: The Concept
Calculating Partial Derivatives
Partial Derivative Notation
The Gradient Vector
Geometric Meaning of the Gradient
Practice: Calculating Partial Derivatives and Gradients
Quiz for Chapter 4
Chapter 5: Calculus in Action: Simple Optimization
Recap: Optimization Goal and Gradient Descent
Example: Simple Linear Regression Model
Defining a Cost Function for Linear Regression
Calculating Gradients for the Cost Function
Performing a Gradient Descent Step
The Learning Rate Parameter
Putting It All Together: The Optimization Process
Hands-on Practical: Manual Gradient Calculation
Quiz for Chapter 5

What is a Limit?

Functions describe relationships between inputs and outputs, such as y=f(x)y = f(x)y=f(x). A foundational concept for calculus is the limit. Limits help understand how a function behaves near a particular input value.

Imagine you're walking towards a specific point on a path. A limit is like asking: "Where does it look like I'll end up as I get incredibly close to that point, even if I don't actually step on that exact spot?"

Why "Close To"?

Sometimes, we can just plug an input value into a function to see the output. If we have f(x)=x+2f(x) = x + 2f(x)=x+2 and want to know what happens at x=3x=3x=3, we calculate f(3)=3+2=5f(3) = 3 + 2 = 5f(3)=3+2=5. Simple enough.

But what if the function is undefined at the specific point we're interested in? Or what if we want to understand the trend or tendency of the function right around that point? This is where limits become essential. They allow us to analyze the function's behavior as we approach a value, regardless of what happens precisely at that value.

Approaching a Value: An Example

Let's stick with the simple function f(x)=x+2f(x) = x + 2f(x)=x+2. We already know f(3)=5f(3) = 5f(3)=5. But let's pretend we don't know that, and instead, let's see what value f(x)f(x)f(x) approaches as xxx gets closer and closer to 3.

We can try values of xxx slightly less than 3:

  • If x=2.9x = 2.9x=2.9, then f(x)=2.9+2=4.9f(x) = 2.9 + 2 = 4.9f(x)=2.9+2=4.9
  • If x=2.99x = 2.99x=2.99, then f(x)=2.99+2=4.99f(x) = 2.99 + 2 = 4.99f(x)=2.99+2=4.99
  • If x=2.999x = 2.999x=2.999, then f(x)=2.999+2=4.999f(x) = 2.999 + 2 = 4.999f(x)=2.999+2=4.999

And values slightly greater than 3:

  • If x=3.1x = 3.1x=3.1, then f(x)=3.1+2=5.1f(x) = 3.1 + 2 = 5.1f(x)=3.1+2=5.1
  • If x=3.01x = 3.01x=3.01, then f(x)=3.01+2=5.01f(x) = 3.01 + 2 = 5.01f(x)=3.01+2=5.01
  • If x=3.001x = 3.001x=3.001, then f(x)=3.001+2=5.001f(x) = 3.001 + 2 = 5.001f(x)=3.001+2=5.001

Notice a pattern? As xxx gets closer and closer to 3 (from either side), the output f(x)f(x)f(x) gets closer and closer to 5. We say that "the limit of the function f(x)=x+2f(x) = x + 2f(x)=x+2 as xxx approaches 3 is 5."

In mathematical notation, we write this as:

lim⁡x→3(x+2)=5\lim_{x \to 3} (x + 2) = 5x→3lim​(x+2)=5

Let's break down this notation:

  • lim⁡\limlim indicates we are finding a limit.
  • x→3x \to 3x→3 below lim⁡\limlim means "as the input xxx approaches the value 3".
  • (x+2)(x + 2)(x+2) is the function we are examining.
  • =5= 5=5 states the value the function approaches.

When the Function Has a Hole

The real utility of limits shines when a function has a gap or is undefined at a point. For example, take the function:

g(x)=x2−1x−1g(x) = \frac{x^2 - 1}{x - 1}g(x)=x−1x2−1​

What happens if we try to plug in x=1x = 1x=1? We get 12−11−1=00\frac{1^2 - 1}{1 - 1} = \frac{0}{0}1−112−1​=00​, which is undefined. Division by zero is not allowed. So, g(1)g(1)g(1) does not exist.

However, we can simplify this function algebraically for values where xxx is not equal to 1. Since x2−1=(x−1)(x+1)x^2 - 1 = (x - 1)(x + 1)x2−1=(x−1)(x+1), we have:

g(x)=(x−1)(x+1)x−1=x+1,provided x≠1g(x) = \frac{(x - 1)(x + 1)}{x - 1} = x + 1, \quad \text{provided } x \neq 1g(x)=x−1(x−1)(x+1)​=x+1,provided x=1

So, the graph of g(x)g(x)g(x) looks exactly like the graph of f(x)=x+1f(x) = x + 1f(x)=x+1, except there's a "hole" at the point where x=1x=1x=1.

Let's ask: What is the limit of g(x)g(x)g(x) as xxx approaches 1? We can use the simplified form x+1x+1x+1 because the limit only cares about values near x=1x=1x=1, not at x=1x=1x=1.

Let's check values near x=1x=1x=1:

  • If x=0.9x = 0.9x=0.9, then g(x)=0.9+1=1.9g(x) = 0.9 + 1 = 1.9g(x)=0.9+1=1.9
  • If x=0.99x = 0.99x=0.99, then g(x)=0.99+1=1.99g(x) = 0.99 + 1 = 1.99g(x)=0.99+1=1.99
  • If x=1.1x = 1.1x=1.1, then g(x)=1.1+1=2.1g(x) = 1.1 + 1 = 2.1g(x)=1.1+1=2.1
  • If x=1.01x = 1.01x=1.01, then g(x)=1.01+1=2.01g(x) = 1.01 + 1 = 2.01g(x)=1.01+1=2.01

As xxx gets arbitrarily close to 1, g(x)g(x)g(x) gets arbitrarily close to 2. Even though g(1)g(1)g(1) is undefined, the limit exists. We write:

lim⁡x→1x2−1x−1=2\lim_{x \to 1} \frac{x^2 - 1}{x - 1} = 2x→1lim​x−1x2−1​=2

Here's a visualization of the function g(x)=x2−1x−1g(x) = \frac{x^2 - 1}{x - 1}g(x)=x−1x2−1​, which behaves like y=x+1y = x+1y=x+1 but has a hole at x=1x=1x=1.

The graph of g(x)=(x2−1)/(x−1)g(x) = (x^2 - 1) / (x - 1)g(x)=(x2−1)/(x−1) is the line y=x+1y = x + 1y=x+1 with a single point removed at (1,2)(1, 2)(1,2), indicated by the open circle. The limit as xxx approaches 1 is the y-value the function gets close to, which is 2.

The Core Idea Summarized

A limit LLL exists for a function f(x)f(x)f(x) as xxx approaches some value ccc if we can make the function's output f(x)f(x)f(x) as close to LLL as we desire, simply by choosing an input xxx sufficiently close to ccc (but not actually equal to ccc). The function doesn't even need to be defined at ccc for the limit to exist.

This idea of "getting arbitrarily close" is the foundation upon which the idea of the derivative is built. Derivatives, as we'll see in the next chapter, measure instantaneous rates of change, and limits provide the mathematical machinery to define this "instantaneous" behavior. Understanding limits gives us the basis to understand how functions change, which is fundamental to optimizing machine learning models.

© 2026 ApX Machine Learning