Partial Derivatives and the Gradient

Drag the point across the contour map. The two partial derivatives are the slopes along the axes; turn the heading dial and the last readout is the slope you would feel walking that way.

Loading interactive simulation...

The hill is steeper than anything you measured 🖖

Stand at (1, 1) on 1.5x² + 2y². Walk due east and the ground rises at 3. Walk due north and it rises at 4. Neither of those is the steepest slope at that point: the steepest is 5, on a heading of 53.1°, and you did not walk it. A partial derivative is the slope along one axis and nothing more, and the axes are an accident of where somebody laid the paper. What combines them is Pythagoras rather than addition, so the steepest slope is √(fx² + fy²), which can never come out smaller than either of them, and is strictly larger unless one of them is zero. The gap is widest when the two are equal: measure 1 along each axis and the ground is actually rising at 1.414, which is 41% more than either measurement reported.

Every heading at once, and it is one cosine 🖖

Turn the dial through a full circle and watch the slope readout. It traces a cosine, |∇f| cos(θ − θg), where θg is the steepest heading. That is the entire behaviour of a smooth surface at a point, and one consequence is drawn on the map: wherever the gradient is not zero, two headings have no slope at all, a quarter turn either side of the steepest. Those two point along the contour, which is why the steepest path up a hill crosses contours at right angles and why a contour map can be read at a glance. The same cosine kills a plausible shortcut. At 45° off the steepest line you are still climbing at 71% of the full gradient, not half of it, so cutting the corner on a hill buys much less than it looks.

Level in both directions is not the top 🖖

Press Neither top nor bottom. Both partial derivatives are zero at the origin of x² − y², and the point is neither a maximum nor a minimum: along the x-axis it is the bottom of a valley, along the y-axis the top of a ridge. Now press Both axes level, which is the surface xy. Here both axes are exactly level, the slice panel drawing a flat line at 0° and again at 90°, and the point is still a saddle. Its rise and fall sit on the diagonals, where nobody thought to look. What separates the cases is the discriminant fxxfyy − fxy², which is −4 for the first surface and −1 for the second: negative says saddle, positive says one or the other, and the sign of fxx then says which. On x³ − 3xy² the discriminant comes out 0 and the test has nothing to report. That surface has three wedges rising out of the origin and three falling, and no second derivative in the calculation can see them.

Problems solved in full

  1. Steepness of a hillside rising 3 metres east and 4 metres north 6 steps

    You are on a hillside where the ground rises 3 metres per 100 travelled due east, and 4 metres per 100 travelled due north. How steep is the hill, which way does it fall, and what heading must a road take to climb at half that gradient?

    1. Those two measurements are the partial derivatives. Keeping them as 3 and 4 per hundred reads more easily than 0.03 and 0.04, and changes nothing.

    2. The steepest slope is the length of the gradient, which is neither the sum of the parts nor the larger of them. Three and four give five, and five is what a walker feels.

    3. Its heading is atan2(4, 3), which is 53.1° round from east. Downhill is the opposite way, at 233.1°. Nothing was measured along either.

    4. For a road at 2.5 per hundred, run the identity backwards. The slope on a heading θ away from that steepest heading is 5 cos θ, so cos θ = 2.5/5 and θ = 60°.

    5. Sixty, not forty-five. A road at 45° would still be climbing at 3.54 per hundred, which is 71% of the steepest and nowhere near half of it.

    6. The length comes from the same cosine. Gaining a fixed height at half the gradient means covering twice the ground for as long as the slope holds, and that factor of two is what the switchbacks on a mountain road are made of.

    Answer

    The hill is 5 m per 100 m, rising at a heading of 53.1° and falling at 233.1°, and a road holding 2.5 m per 100 m must run 60° off that steepest heading and travel twice as far. The tool answers the first half: point it any way you like and it gives the slope. The second half is the inverse question, and it is the one that a road engineer, a ramp accessibility standard and a ski piste grading all actually ask. Given the gradient I am allowed, what heading am I forced onto?

  2. The heading with no slope, and how long it stays level 6 steps

    At (1, 1) on 1.5x² + 2y² the panel puts the slope on a heading of 143.1° at 0.000. Work out what the ground does if you keep walking that way, and decide whether that heading is one you could follow to stay level.

    1. A quarter turn from the steepest heading of 53.1°. The two terms of the dot product come out −2.4 and +2.4, so the slope card reads 0.000.

    2. Zero slope is a statement about the first derivative and nothing else. Take the second one along the same heading. It is the quadratic form built from the three second partials, with the same cosine and sine inside it.

    3. On this surface f_xx is 3, f_yy is 4 and the mixed partial is 0, so the second derivative along the level heading is 3.36. Positive, so the ground curves upward.

    4. The height along that line is therefore a parabola with its lowest point where you are standing. Half a unit out the ground has risen 0.42, from 3.5 to 3.92, and the slice panel draws exactly that curve.

    5. Turn it into a property of the contour. The curve that really does hold height bends away from the tangent at the second derivative divided by the gradient: 0.672, which is a radius of 1.488.

    6. The standard formula for the curvature of a level set gives the same number from the partials alone, with no heading anywhere in it. Two routes, one answer, and it is exactly 84/125.

    Answer

    No. That heading is level for an instant and then climbs. Walk half a unit along it and you have gained 0.42, where the first derivative predicted 0. The two zero-slope headings are tangents to the contour rather than the contour itself, and staying level means turning continuously, on a circle of radius 1.488 at this point. The panel gives you the tangent; the curvature says how far it is worth trusting.

Learning path

Why everything looks straight up close

Example problems

  • Three east, four north - At (1, 1) the ground rises at 3 due east and at 4 due north. Heading east, the slope readout says 3. The steepest slope available here is 5, on a heading of 53.1°, and neither measurement pointed that way.
  • Turned onto the contour - The same point and the same gradient of 5, and now the slope reads 0. A heading of 143.1° runs along the contour line, which meets the steepest direction at a right angle.
  • Neither top nor bottom - Both partial derivatives are zero and the point is neither a peak nor a pit. The discriminant is −4. At a heading of 0° the slice is the bottom of a valley; at 90° the same point is the top of a ridge.
  • Both axes level - On xy both axes are exactly level — the slice panel draws a flat line at 0° and again at 90° — and the point is still a saddle, with a discriminant of −1. The rise and the fall are on the diagonals.
  • The test has no answer - Every second derivative vanishes here, so the discriminant is 0 and the test returns nothing at all. Three wedges out of this point rise and three fall.