What is a derivative?
A derivative measures how fast a function's output changes as its input changes, at one specific point. Geometrically it is the slope of the tangent line to the curve there. Formally it is the limit f'(x) = lim h→0 [f(x+h) − f(x)] / h, the slope of a line through two points as the points merge into one.
Machine learning runs on derivatives. Training a model means adjusting its parameters to reduce a loss, and the derivative of the loss with respect to each parameter says which direction lowers it and by roughly how much. Gradient descent, backpropagation, learning-rate schedules, and second-order methods such as Newton's method are all built from this one idea.
Key ideas
- The derivative at a point is the slope of the tangent line there.
- It is defined as the limit of secant slopes, [f(x+h) − f(x)] / h, as h approaches 0.
- The derivative of x² is 2x, and the power rule gives n·xⁿ⁻¹ for xⁿ.
- A positive derivative means the function is increasing; a negative one means it is decreasing.
- Points where the derivative is zero are candidates for minima and maxima.
- Gradient descent uses derivatives of the loss to decide how to change each parameter.
Common questions
What is the difference between a derivative and a differential?
The derivative f'(x) is a rate: output change per unit of input change. The differential dy = f'(x)·dx is the approximate change in output for a small input change dx. The notation dy/dx, due to Leibniz, treats the derivative as a ratio of these small changes.
Can a function fail to have a derivative?
Yes. The function |x| has a sharp corner at 0, where the slope from the left is −1 and from the right is +1, so no single tangent exists. ReLU has the same kink at 0. Frameworks pick a value there, usually 0, and training works fine because inputs land exactly on 0 so rarely.
What are the derivatives of eˣ and ln x?
The derivative of eˣ is eˣ, which makes it the only function (up to a constant multiple) equal to its own derivative. The derivative of ln x is 1/x. Both appear constantly in ML because softmax, sigmoid, and cross-entropy loss are built from exponentials and logarithms.
Why not just compute derivatives numerically with a small h?
Finite differences need one or two extra function evaluations per input, which is far too slow for a model with millions of parameters. They also lose accuracy: too large an h gives truncation error, too small an h gives floating-point cancellation. Automatic differentiation computes exact derivatives for all parameters at roughly the cost of one extra pass.
Related explainers
- The Chain Rule — How derivatives compose through layers
- Partial Derivatives & Gradients — Extend single-variable derivatives to functions of multiple variables and gradient vectors
- Gradient Descent — Optimizing by following the slope downhill
- Backpropagation — How networks learn from their mistakes
- Logarithms & Exponentials — The math behind cross-entropy, softmax, and information theory
References
- Strang, "Calculus" (open textbook), MIT OpenCourseWare
- Deisenroth, Faisal & Ong, "Mathematics for Machine Learning", ch. 5 Vector Calculus
- Goodfellow, Bengio & Courville, "Deep Learning", ch. 4 Numerical Computation
Last updated