← Tensor by Tensor
§ Math Fundamentals for AI
Tensor by Tensor · Complete Guide

Derivatives

Fourteen lessons that connect high-school mathematics to AI. Start with the plain-language explanation and a small example. Then read the full formulas, derivations, and Python code at your own pace.

How to study a lesson

Read the opening example. Try the question before revealing its answer. Then work through the detailed notes below it. You do not need to understand every proof on the first reading.

Symbols: a subscript such as xi identifies one entry. Σ means add a collection of terms. ∈ means “belongs to”. The symbol ≈ means “approximately equal”, not exactly equal. A parameter is an adjustable number in a model.

01.02 · Derivatives

Introduction

Suppose a square has side length 3 and the side grows slightly. We want the local rate at which its area changes, not only the area itself; shrinking difference quotients reveals that rate.

Learning goal

Estimate and calculate a derivative, then use it to predict a small change in a function.

Before you start

Functions, powers, subtraction, division, and the idea of slope on a graph.

Lesson plan

  1. Measure change over a small interval and interpret its slope.
  2. Shrink the interval for the square function and derive the exact rate.
  3. Use derivative notation to predict nearby output changes and identify limits.

Predict a nearby value. If f(x)=x², then f(3)=9. The slope at 3 is 6, so moving to 3.01 predicts an increase near 6×0.01=0.06. The exact value is 9.0601, which shows both the usefulness and the local limit of the derivative.

What is a derivative?

The derivative measures the instantaneous rate of change of a function at a point. For $f(x)$, the derivative at $x$ is:

$$f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$

Geometrically, $f'(x)$ is the slope of the tangent line to the curve $y = f(x)$ at the point $(x, f(x))$.

Definition · Derivative

The derivative $f'(x)$ is the unique number (if it exists) such that:

$$f(x+h) \approx f(x) + f'(x) \cdot h$$

for small $h$. The approximation becomes exact in the limit $h \to 0$.

Example: Derivative of $x^2$

Let $g(x) = x^2$. At $x = 3$, we compute:

Input changeOutput changeRatio
3 → 3.19 → 9.61; change 0.616.1
3 → 3.019 → 9.0601; change 0.06016.01
3 → 3.0019 → 9.006001; change 0.0060016.001

The ratios approach 6, so $g'(3) = 6$.

Derivation

Using the limit definition:

$$g'(x) = \lim_{h \to 0} \frac{(x+h)^2 - x^2}{h} = \lim_{h \to 0} \frac{2xh + h^2}{h} = \lim_{h \to 0} (2x + h) = 2x$$

So $g'(x) = 2x$, giving $g'(3) = 6$ and $g'(-2) = -4$.

Using the derivative to predict changes

If $x$ moves from 3 to 3.02 (change $h = 0.02$), the derivative predicts:

$$\Delta g \approx g'(3) \cdot h = 6 \times 0.02 = 0.12$$

The exact change is $3.02^2 - 3^2 = 0.1204$. Close, but not exact — the approximation improves as $h$ shrinks.

Example · Negative derivative

At $x = -2$, $g'(-2) = -4$. If $x$ increases to $-1.99$ ($h = +0.01$):

$$\Delta g \approx -4 \times 0.01 = -0.04$$

The output decreases. A negative derivative means increasing the input locally decreases the output.

Notation

NotationRead asContext
$f'(x)$"f prime of x"Lagrange notation, common in calculus
$\frac{df}{dx}$"derivative of f with respect to x"Leibniz notation, emphasizes the variable
$Df(x)$"D f at x"Operator notation, used in higher dimensions
$\dot{f}$"f dot"Time derivative in physics
Key insight

The derivative is a local linear approximation. It tells you the rate of change at a specific point, not globally. The approximation $f(x+h) \approx f(x) + f'(x)h$ is accurate only for small $h$.