A derivative measures how a function changes as its input changes. Intuitively, it's the slope of the tangent line at a point on a curve.
Definition
For a function , the derivative at point is:
ℹ️ Intuition
Think of the derivative as the "instantaneous rate of change" — like your speedometer reading at a single moment in time, rather than average speed over a journey.
Basic Rules
The power rule is the most common derivative rule:
For example, the derivative of is .
Common Derivatives
| Function | Derivative |
|---|---|
Example in Code
Here's how you'd compute a numerical derivative in Python:
def numerical_derivative(f, x, h=1e-7):
return (f(x + h) - f(x - h)) / (2 * h)
def f(x):
return x ** 3
print(numerical_derivative(f, 2)) # ≈ 12.0💡 Chain Rule
When composing functions, use the chain rule:
Why Derivatives Matter
Derivatives are the foundation of optimization. When we set , we find critical points — places where the function reaches a local maximum or minimum.
This is exactly what machine learning does: gradient descent follows the negative derivative to minimize a loss function.