How steep is a curve right here, at one point? Below, a line through two points becomes the slope at one. Before it plays, sketch the slope curve: what shape will it be?
The slope at a point
The loss J(w) = 15 − 21w + 7.5w² above, its slope J′(w) below, on one w axis.
The loss curve of the last lesson, J(w) = 15 − 21w + 7.5w², and a point on it at w = 0.5.
Describe this picture
Two panels stacked on one shared axis from 0 to 2.5. Above, the loss curve of Models and loss, , a bowl lowest at . Below, the panel of its slope, empty at first. In the clip a point sits on the curve at . A second point slides in towards it from and pauses at gaps of 1, 0.5, 0.1 and 0.01, where the line through the two has slope −6, −9.75, −12.75 and −13.425. Then the two points meet, and the line just touches the curve: the tangent, slope −13.5. The tangent goes back to and rides along the curve to , while a vertical link line joins the point above to a dot below at the height of the tangent’s slope. The dot traces the slope curve: a straight line rising from −21, negative on the left, crossing zero at , where the crossing is marked, and positive on the right. Readouts give the point , the gap and the slope of the line. After the clip a slider, “Point, w”, runs from 0 to 2.5 in steps of 0.01 and starts at 2.5; the point can also be dragged across either panel, and the link line follows.
From two points to one
The slope between two points on a curve is rise over run. Take the point at and a second point a small step further on. The line through them, a secant, has slope
Here is a small number, not a filter’s impulse response (that one is written , with brackets). As shrinks, the second point slides towards the first and the secant turns, settling onto one line, the tangent. Its slope is the derivative of at :
Both ways of writing it say the same thing: the rate at which changes per unit of , right at . The derivative is a slope, so it has the units of per unit of .
For the curve in the picture, the secant slopes from work out to . At that is −6, at it is −9.75, at it is −12.75, and as goes to 0 it tends to −13.5, the slope of the tangent.
Now the answer to the question. The slope curve is a straight line. The curve above is a bowl, but its slope is steeply negative on the far left, rises steadily and passes through zero at the bottom. A graph of slopes need not look like the graph it came from.
Watch out
The slope curve is not a copy of the curve. Read it as “how steep”, never as “how high”.
Rules for slopes
Working out a limit every time would be slow. A few rules cover most of what this course needs. For a power of , with a fixed number,
so the slope of is and the slope of is 1. A constant has slope 0. A constant multiple keeps its multiple, and the slope of a sum is the sum of the slopes, term by term. Two more are worth knowing by their pictures, and I state them without proof:
The curve is its own slope everywhere. The curve (for ) climbs ever more gently, with slope .
Describe this picture
Four small panels, each a curve above its slope curve on a shared axis: , a bowl, over , a straight line through 0; over , a bowl that touches 0 at ; , rising ever faster, over the same curve; and for from 0.2 to 4, rising ever more slowly, over , falling towards 0. In the panel the tangent at 0 is drawn: the flat line at height 0, which crosses the curve there. The caption ends “a zero slope need not be a bottom”. There is no control.
For the loss curve, term by term:
That is the straight line in the lower panel. At it gives , the tangent’s slope found above.
Finding the bottom
At the bottom of a smooth valley the tangent is flat, so the slope is zero. For the loss curve, gives : the best slope of Models and loss, found there by completing the square, here in one line.
The sign of the slope says which way the bottom lies. Left of 1.4 the slope is negative: the curve falls as grows, so the bottom is to the right. Right of 1.4 it is positive, so the bottom is to the left. At , : positive, so the bottom is to the left. Gradient descent, later in the course, steps against that sign.
A zero slope does not always mean a bottom. At the top of a hill, at 0, the slope is zero too. And has zero slope at 0 while it keeps rising on both sides: there the flat tangent crosses the curve instead of resting on it. A tangent can cross its curve; what defines it is the slope, not touching once.
Watch out
Zero slope means a bottom, a top or a flat step. Check which: on a bowl like the loss here, it is the bottom.
Slopes from numbers
Sometimes there is no formula to differentiate, only a way to compute the curve. Then the secant itself is the estimate. The forward difference uses one point ahead:
and the central difference one point on each side:
The central difference is much more accurate for the same . Each side’s error has a part of size , and those two parts are equal and opposite, so they cancel; what is left is of size . For a parabola the central difference is exact at any .
In signal processing · the first difference
Amplitude operations in the signal processing course takes the first difference of a signal, each sample minus the one before: a forward difference with a step of one sample, the derivative’s sampled cousin. It is near zero at a peak or a trough and largest where the signal is steepest.
Worked example
Secants. On : , and . From :
- : ;
- : ;
- in general : at , at , tending to .
A step backwards works too: gives .
The rule. , so and at .
A second curve. The slope of is , zero at .
Numerical slopes. For at 0, whose true slope is 1, with : the central difference is , the forward difference . The central one is about thirty times closer. For at 2, true slope 0.5, the central difference is .
Exact for a parabola. For the loss curve at with the large step : and , so the central difference is , the exact slope.
Where you’ll meet this
Speed. A speedometer shows the derivative of distance travelled: metres per second, right now.
Sensitivity. A sensor’s sensitivity is the slope of its calibration curve: how much the output moves per unit of what it measures.
Fitting models. Every training method in this course follows slopes downhill. Partial derivatives and the gradient takes the slope of a loss with two parameters, and Gradient descent walks down it.
In linear algebra · differentiation as a matrix
The matrix of a linear map in the linear algebra course writes differentiation of a cubic as a 4×4 matrix acting on its coefficients. The rules here, sums term by term and constant multiples kept, are what make differentiation linear.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Derivative | the tangent’s slope | |
| Power | a fixed number | |
| Sums, multiples | term by term; constants keep their multiple | a constant’s slope is 0 |
| Exponential, logarithm | , | |
| Bottom of a valley | also a top or a flat step: check | |
| Sign | negative: bottom to the right; positive: to the left | |
| Central difference | error of size ; exact on a parabola | |
| Forward difference | error of size |