The Derivative: Mathematics’ Way of Measuring Change
We all have used Google Maps, haven’t we? You start a journey and the ETA is 29 minutes. You’re zipping through the road and it looks like a pretty fun ride. Maps shows you’re moving fast and changes the ETA to 25 minutes.
But then traffic hits. Everything is just crawling. Check your maps and it says no, it’s not 25 minutes anymore but 32 minutes to the destination.
How does Maps figure this out? Simple. It tracks your position every second. From position change, it calculates your speed. From speed, it estimates arrival time.
This idea — measuring how fast something changes right now (in this instant) — is called a derivative.
And it’s everywhere. Your fitness tracker uses it when you’re running. Stock traders use it to spot momentum. Self-driving cars use it dozens of times per second to decide when to brake.
And machine learning? Built on derivatives. Every time a neural network learns, it uses derivatives to figure out which way to adjust to get better.
Let’s understand how.
Understanding Derivatives: From Average to Right Now
Building on the Maps example above. If you travelled 50 km in an hour, your average speed is 50 km/hr. But you were not driving consistently at that speed for the entire hour. Sometimes you were zipping at 70 km/h on the highway. Sometimes crawling at 20 km/h in traffic. Sometimes completely stopped at a red light.
That’s what derivatives help us calculate. Not the average over an hour, but the speed right now, at this exact moment.
Let’s visualize this.
Imagine a graph. X-axis is time, Y-axis is distance travelled. As you drive, this creates a curve.
Now, let’s measure your average speed. Break the 60 minutes into 12 windows of 5 minutes each. Calculate average speed in each 5-minute window. You get a rough sense of how your speed changed.
Go smaller. Break it into 1-minute windows. Now you have 60 data points. Better picture of your speed changes.
Go even smaller. Break it into 1-second windows. Now you have 3600 points. Much clearer view.
What if we keep going? 0.1 seconds, 0.01 seconds, 0.001 seconds.
As the time window shrinks toward zero, something interesting happens. You’re no longer calculating average speed over some duration. You’re getting the speed at that exact instant. Right now. Not averaged over anything.
That’s the derivative. The instantaneous rate of change.
The tangent line
Pick any point on this distance-time curve. Say, exactly 30 minutes into your journey.
Draw a line that just barely touches the curve at that point. That’s called a tangent line.
The slope of that tangent line is your speed at exactly 30 minutes.
Here’s how it works. If you move a tiny distance dx in a tiny time dt, your speed is dx/dt.
Think of it as a right triangle. The horizontal side is dt (tiny change in time). The vertical side is dx (tiny change in distance). The slope of the line connecting them is dx/dt. Rise over run. That’s your derivative.
As dt gets smaller and smaller, approaching zero, dx/dt gives you the exact speed at that moment. Not averaged over any duration. Just that instant.
Sliding along the curve
Now move this tangent line along the curve. At each point, its slope tells you the speed at that instant.
Steep slope? You’re accelerating hard. Gentle slope? Cruising steady. Flat slope? Stopped at a red light.
The derivative reveals the rate of change at every single moment.
Why do we care about instantaneous vs average?
Because nothing in the real world remains constant. Your speed changes. Stock prices fluctuate. A ball’s velocity changes as it falls. Temperature rises and drops throughout the day.
Derivatives capture change at every moment, not just some average. That precision is exactly what makes them powerful.
Seeing is Believing: How x² Becomes 2x
I watched a 3Blue1Brown video on derivatives and suddenly everything clicked. The formulas I had memorized in high school finally made sense.
We learned rules in high school. Derivative of x² is 2x. Derivative of x³ is 3x². Memorize and move on.
But no one explained why. Why does x² become 2x? Why 2 and why not 4?
Let me show you. Once you see it, you will never forget.
For a moment, think of x² not as a formula, but as the area of a square with side length x.
Simple enough. Area = x².
What happens if the side grows by a tiny amount? Let’s call that tiny change dx.
How tiny? Imagine dx = 0.00001. Or smaller. Approaching zero, but not quite zero.
The new square has side length (x + dx).
So, the new area is (x + dx)².
Let’s expand this: (x + dx)² = x² + 2xdx + dx²
But what does this actually mean? Look at the square:
- x² (yellow): The original square. This was already there.
- 2xdx (blue): Two thin strips we just added. One on the right, one on top. Each strip has one side measuring x and the other measuring dx. Together they give 2x·dx.
- dx² (red): A tiny corner piece where the two strips meet.
That corner piece, dx². It’s ridiculously small.
If dx = 0.001, then dx² = 0.000001.
If dx = 0.0001, then dx² = 0.00000001.
As dx approaches zero, dx² vanishes completely. It becomes so small we can ignore it.
Now we are left with: x² + 2xdx
The original area was x². The change in area is 2xdx.
Now here’s the question derivatives ask: what’s the rate of change per unit increase in x?
(change in area) / dx = 2xdx / dx = 2x
There it is. The derivative of x² is 2x.
Not because a textbook told you so. Because geometry shows you.
The pattern extends
Same logic works for x³. Think of it as a cube with side x. Volume = x³.
When the side grows by dx, you add three square faces to the cube. Each face has area x²·dx. Three faces give you 3x²·dx.
Divide by dx: 3x². That’s why the derivative of x³ is 3x².
See the pattern?
- x² → 2x
- x³ → 3x²
- x⁴ → 4x³
- x⁵ → 5x⁴
The exponent comes down and becomes a multiplier. The power decreases by one.
That’s the power rule. And now you know why it works.
Your Differentiation Toolkit
Now that we have some intuition about derivatives, let’s dive into bit of maths. Following is the toolkit of how to find derivatives. It will be pretty useful when we look into machine learning algorithm and gradient descent (more about it, in later blogs).
There are 4 main rules, others can be derived from below
Power Rule
We already saw the power rule above, how x² became 2x. It’s pretty simple.
Bring down the exponent as a multiplier. Reduce the power by one.
Let’s see it work:
· x³ → 3x²
· x⁵ → 5x⁴
· x¹⁰⁰ → 100x⁹⁹
A trick question now, can you guess what’s the derivative of x⁰?
Apply the power rule: bring down the 0, reduce power by 1.
That gives: 0·x⁻¹ = 0
The derivative is 0. Makes sense, because x⁰ = 1, which is a constant.
Constants don’t change. No change means derivative = 0.
Derivative of 5 is 0. Derivative of 100 is 0. Derivative of π is 0. Any constant, derivative is 0.
Constants multiply through
One more thing. Constants come along for the ride.
d(5x³)/dx = 5·(3x²) = 15x²
The 5 stays. Only the x³ part gets differentiated.
Same for any constant: (c·f(x))’ = c·f’(x)
Sum Rule
Let’s find the derivative of a function which is sum of two independent functions.
If h(x) = f(x) + g(x), then h’(x) = f’(x) + g’(x)
Let’s say, you have two bank accounts.
Account 1: Balance = f(t), growing at rate f’(t) per day
Account 2: Balance = g(t), growing at rate g’(t) per day
Total money: f(t) + g(t)
How fast is your total wealth changing?
Rate from Account 1 + Rate from Account 2 = f’(t) + g’(t)
The accounts grow independently. Their growth rates add.
Product Rule
Derivative of products is less intuitive.
You may think, if h(x) = f(x)g(x), then h’(x) = f’(x)g’(x)
But that’s not right. Let’s try f(x) = x² and g(x) = x³
If (f·g)’ = f’·g’, we’d get:
- f’ = 2x, g’ = 3x²
- f’·g’ = 2x·3x² = 6x³
But the actual answer is:
- f·g = x²·x³ = x⁵
- d(x⁵)/dx = 5x⁴
Not the same! So multiplying derivatives doesn’t work.
If you remember when we tried to derive derivative of area of a square, we multiplied two sides of it and each side grew by dx.
Let’s try the same for a rectangle to get better intuition.
Think of f(x) and g(x) as the length and width of a rectangle.
Area = f(x) · g(x)
Now both dimensions change slightly:
- Width changes from f to (f + df)
- Height changes from g to (g + dg)
New area = (f + df)(g + dg) = f·g + f·dg + g·df + df·dg
Change in area: = [f·g + f·dg + g·df + df·dg] — f·g = f·dg + g·df + df·dg
As df and dg approach 0, the corner (df·dg) vanishes.
Rate of change: = (f·dg + g·df) / dx = f·(dg/dx) + g·(df/dx) = f·g’ + g·f’
That’s the product rule!
Chain Rule
Chain rule handles functions inside a function i.e. composite functions.
Imagine you are inflating a balloon.
There are three connected changes:
- You pump air → volume of balloon increases
- Volume increases → radius increases
- Radius increases → surface area increases
Question: How does surface area change with respect to your pumping rate?
You need to chain the rates together:
(change in area) / (pumping rate)
= (change in area) / (change in radius) × (change in radius) / (change in volume) × (change in volume) / (pumping rate)
That’s the chain rule. Changes propagate through layers.
If h(x) = f(g(x)), then h’(x) = f’(g(x)) . g’(x)
Will see it in detail, using an example.
h(x) = (x² + 1)³
This is: outer function = (something)³, inner function = x² + 1
Step 1: Differentiate outer (keep inner as-is)
- Outer: u³ → 3u²
- Keep inner: 3(x² + 1)²
Step 2: Multiply by derivative of inner
- Inner: x² + 1 → 2x
- Result: 3(x² + 1)² · 2x = 6x(x² + 1)²
Btw, this is THE rule for machine learning. Backpropagation in neural networks? That’s just chain rule applied over and over.
Why This Matters: From Calculus to Intelligence
We started with Google Maps calculating your speed. We learned how x² becomes 2x. We built a toolkit: power rule, sum rule, product rule, chain rule.
But why does this matter?
Because derivatives are how machines learn.
Machine Learning is Optimization
You have a model making predictions. Those predictions have errors. You want to reduce those errors.
Question: Which way should you adjust your model’s parameters to improve?
Answer: Derivatives tell you the direction.
The derivative of your loss function shows whether to increase or decrease each parameter. This process of using derivatives to optimize — that’s called gradient descent, and we’ll explore it in detail in upcoming blogs.
Every ML algorithm relies on this: linear regression, logistic regression, neural networks — all powered by derivatives.
Chain Rule Powers AI
Neural networks are functions inside functions. Input → Layer 1 → Layer 2 → … → Loss.
To train them, you propagate derivatives backward through all layers. That’s backpropagation. That’s the chain rule applied repeatedly.
Every time a neural network learns, it’s using chain rule thousands of times.
From Speed to Intelligence
From your phone’s GPS calculating speed to neural networks recognizing images to ChatGPT generating text — derivatives work behind the scenes.
You measure change to understand the world. Machines use derivatives to change themselves and get better.
Now you know that it’s calculus that powers AI.
