Worked example · Mathematics

The gradient of a curve, and the tangent that measures it

A straight line has one gradient and you can measure it with a ruler. A curve is steeper in some places than others, so "the gradient" is not a number until you say where. This page finds the gradient of y = x² at x = 3 four separate ways — by chords, by algebra, by tangent and by the rule you may already know — and then reads the gradient of a real speed curve, where it turns out to be the acceleration.

Step 1 — on paper

Rise over run, while the line is straight

Gradient is how much the line climbs for each step to the right. Take y = 2x + 1 and any two points on it — say (1, 3) and (4, 9):

gradient=ΔyΔx=9341=2

Any other pair of points on that line gives 2 as well, and that is the whole reason the answer is simple: a straight line has the same steepness everywhere, so which two points you pick cannot matter.

Now try the same thing on y = x² between (1, 1) and (4, 16): (16 − 1) ÷ (4 − 1) = 5. Between (2, 4) and (4, 16) it is 6. Between (3, 9) and (4, 16) it is 7. Three answers, all correct, none of them "the gradient" — because a curve does not have one.

Step 2 — closing in

Chords, shrinking towards a single point

Ask a narrower question: what is the gradient at x = 3? Take a chord from x = 3 to a point a little further along, at 3 + h, and work out its gradient. Then make h smaller and watch:

chord=(3+h)29h

Put h in a variable and the whole experiment becomes one line you can replay — which is exactly what a variable is for:

  • 1
  • VAR
  • STO
  • A
  • (
  • (
  • 3
  • +
  • VAR
  • A
  • )
  • 9
  • )
  • ÷
  • VAR
  • A
  • =

Store a smaller A, press to bring the expression back, and press =. A new value and two keys is a whole row of this table:

The chord gradient of y = x² from x = 3, as the chord narrows. Every row arrives as an exact fraction; Frac⇄Dec gives the decimal beside it.
A (chord width)Chord gradientAs Ans shows it
177
0.56.513/2
0.16.161/10
0.016.01601/100
0.0016.0016001/1000
Ans on iPhone showing, open bracket, open bracket 3 plus A close bracket squared minus 9, close bracket, divided by A, with the result shown as the fraction 6001 over 1000.
The narrowest chord in the table, exact as 6001/1000. Every other row was this line with a different A and two keypresses.

The answers are walking towards 6 and the pattern is exact: each chord is 6 + A. That is not a coincidence, and the algebra shows why in two lines — ((3+h)² − 9)/h = (6h + h²)/h = 6 + h — so as the chord shrinks to nothing the gradient is exactly 6.

The answer arrives as a fraction, and that is the point. There is no decimal point anywhere in ((3+A)²−9)÷A — the 0.001 went into A — so Ans has not been asked for a decimal and does not give one: it returns 6001/1000, exactly. Press Frac⇄Dec for 6.001. A calculator working in binary floating point would offer 6.009999999999849 for the A = 0.01 row, which is the same answer wearing a disguise that hides the pattern this whole step depends on. There is more on that on the exact values page.

Take the chord from both sides and something surprising happens

Every chord above ran from x = 3 forwards to 3 + A, so every one of them overshoots: 7, 6.5, 6.1, 6.01. Straddle the point instead — from 3 − A to 3 + A — and the same experiment behaves completely differently:

Not 6.001, and not 6.0000001. Exactly 6, from a chord as wide as you like: A = 1 means a chord from x = 2 to x = 4, and it still reads 6. The algebra says why in one line — (3+h)² − (3−h)² = 12h, so dividing by 2h leaves 6 with nothing to shrink. The two overshoots cancel because the curve bends the same amount either side.

That is the centred difference, and it is what a numerical derivative actually uses. On a parabola it is exact; on any other curve it is not, but its error shrinks with the square of the chord width where the one-sided version shrinks in step with it. It is the same keystrokes and a better answer, which is a rare thing.

Step 3 — on the graph

The tangent, drawn and measured

The line those chords are closing in on has a name: the tangent, the straight line that touches the curve at that one point and matches its direction. Ans Graph draws it and states its gradient:

f₁(x) = x^2

Ans Graph: the curve y = x squared with a straight tangent line touching it at x = 3, and the register reading dy/dx = 6.
Tangent puts the gradient at 6 — the number the chords were heading for, and the number the algebra gives.

Four routes to the same answer: five chords narrowing, one algebraic cancellation, one tangent read off a plot, and the rule you may already know — that the gradient of x² is 2x, which at x = 3 is 6. When four methods that share no working agree, the answer is not in doubt.

Drag the tangent along the curve and the number changes as you go: 2 at x = 1, 4 at x = 2, 6 at x = 3. That moving reading is 2x, drawn rather than derived, and it is the whole idea of a derivative before any notation is involved.

Step 4 — what a gradient is for

On a speed–time graph, the gradient is the acceleration

Gradients are worth measuring because they mean something. Take the car from the speed–time example, whose speed follows v = 45(1 − e−t/8). That page used the area under the curve, which was the distance travelled. Its gradient is the other reading: how hard the car is accelerating at that moment.

f₁(x) = 45(1-e^(-x/8))

Ans Graph: the car's speed curve with a tangent line at five seconds, and the register reading a gradient of about 3.01.
At five seconds the tangent's gradient is 3.01 m s⁻² — the acceleration, falling away as the drag builds.
The same car, accelerating less as it speeds up. Gradient of v = 45(1 − e−t/8).
t / sSpeed / m s⁻¹Gradient = acceleration / m s⁻²
00.005.625
29.954.381
520.913.011
1032.111.612

The speed–time page said in words that "the acceleration falls away as you speed up". This is that sentence as a measurement: 5.625 m s⁻² off the line, down to 1.61 ten seconds later. The car is still gaining speed the whole time — the gradient never reaches zero — but it is gaining it more and more slowly.

A tangent that tells you the time constant. Follow that first tangent — the one at t = 0, gradient 5.625 — as a straight line, and it reaches the top speed of 45 m/s at exactly t = 8 s, which is τ. That is true of every curve of this shape, and it is how τ is read off a measured trace in a laboratory: draw the initial tangent and see where it crosses the final value.

Check your own numbers

Four routes to one gradient

The gradient of y = x² at x = 3.
MethodAnswer
Chord with h = 0.0016001/1000, which is 6.001
Centred chord, any h at all6, exactly
Algebra: (6h + h²)/h = 6 + h, as h → 06, exactly
Tangent on the graph6
The rule: gradient of x² is 2x6

What to watch

  • A chord is never the tangent. It approaches it as h shrinks, and the table shows the approach — but every row is an approximation, and only the algebra reaches the limit.
  • A one-sided chord approaches from one side and a centred one straddles the point. On y = x² the centred chord is exact at any width; that is a property of the parabola, not a general rule, so do not expect it on a curve that bends unevenly.
  • The app's tangent is a numerical derivative with a stated uncertainty, not a symbolic one. Where a rule exists — 2x here — the rule is the thing to quote.
  • Not every curve has a tangent everywhere. A sharp corner has no single direction at the corner, so no gradient there, however small you make h.
  • Making h very small is not free: past a point, subtracting two nearly equal numbers loses precision faster than the shrinking chord gains it.

Next: area under a speed–time graph — the same curve read the other way, where the area is distance rather than the gradient being acceleration.