Partial derivatives give the slope of a surface only along the two coordinate directions, yet a walker on a hillside can set off on any bearing, and the slope depends on which one.
The previous lesson ended on this gap, and on a hint: the chain rule, which differentiates as , gives the rate of change along any path, and walking in a straight line at unit speed is a path. This lesson defines the slope in every direction, shows that two numbers contain all of them, and draws out the geometry. It assumes partial derivatives, the chain rule along a path, and the dot product with its formula .
The slope in any direction
A direction in the plane is a unit vector with . Starting at and walking a distance in that direction reaches , and the change in height divided by the distance walked is a difference quotient like any other. The directional derivative of at in the direction is its limit:
The insistence on a unit vector is what makes this a slope. With the parameter is the distance travelled, so the quotient is rise over run. A direction given as must first be divided by its length , or the answer comes out five times too large.
The partial derivatives are two special cases. Taking gives the quotient , whose limit is , and gives .
The definition can be applied as it stands. For the paraboloid at , in the direction pointing away from the origin, the new point is and
The quotient is , so . That is the value the first lesson of this course found numerically by stepping outward and getting . But every new direction would need the expansion again.
Two numbers contain every slope
The chain rule removes the labour. Fix the point and the direction, and walk the line through the point at unit speed by setting
This is a function of the single variable , and the difference quotient in the definition is exactly , so . Now is evaluated along the path , , whose derivatives are the constants and . If is differentiable, the chain rule along a path gives , and at
The right side is a dot product. The vector of partial derivatives is called the gradient of and written with the symbol , read "del" or "nabla":
Two numbers computed once at a point now give the slope in every direction through it. For three variables nothing changes but the length: , the line is , and the chain rule produces three terms instead of two. On the paraboloid, at , and , without expanding anything.
The hypothesis matters. Take with . Along any line through the origin , so every directional derivative exists and equals . Both partials are (put , then ), so the formula would predict in every direction, yet along the true slope is . This function has a slope in every direction yet no tangent plane, and the formula holds for differentiable functions only, which includes every function whose partials are continuous.
Example. Find the slope of at in the direction of .
The partials are and , so at they are and , and . The direction has length , so . Then . A difference quotient with a step of gives , agreeing.
Now you. Find the rate of change of at in the direction of .
Answer
The gradient is at the point. The direction has length , so and .
The direction of steepest increase
The dot product formula turns the directional derivative into geometry. If is the angle between and the unit vector , then
since . Only depends on the choice of direction, and it lies between and . So when , the slope is greatest at , walking along the gradient itself, where it equals . It is least at , walking straight against the gradient, where it equals . It is zero at , in the two directions perpendicular to the gradient. The gradient points in the direction of steepest increase, and its length is that steepest rate.
The first lesson of this course found four slopes of the paraboloid at by brute force: due east, due north, directly away from the origin, and along the level circle. All four are . The third is the largest possible, because is the gradient's own direction and , and the fourth is zero because is perpendicular to it. The infinitely many other directions that lesson left open lie between and according to the cosine.
The same picture explains an identity from the previous lesson, where at had and also . The radial unit vector there is and the unit vector round the circle is , and with the two dot products are and . So , and , are the components of one vector, the gradient, measured along two different pairs of perpendicular unit directions. Both sums of squares are , and a length does not depend on which perpendicular axes it is measured along.
Example. A hill has height metres, with metres east and metres north of the summit. A walker stands at . Which way is steepest uphill, how steep is it, and how does it compare with heading straight for the summit?
The height there is metres. The gradient is , of length , so the steepest climb heads in the direction at a gradient of , which is degrees. The summit lies in the direction , of length , so and , about degrees. The hill is narrower north to south, so the fall line bends towards the axis and does not aim at the top.
Now you. On the hill , find the steepest slope at and its angle, and the slope met by walking due east from there.
Answer
The gradient is , so the steepest slope is , an angle of degrees, heading in the direction . Due east is , giving : a descent of metres per metre.
A contour map shows the gradient without any formula. With contours every metres, as on the Ordnance Survey's Landranger maps, the height changes by metres between neighbouring contours, and walking straight across them is walking at slope . So the spacing on the ground is : at the walker's point, metres, which is mm of paper at 1:50,000. The first lesson measured a path crossing five contour gaps in mm and called its gradient . That is only if the path crosses the contours squarely; a path slanting across them is taking a directional derivative, and the ground's true steepest slope there is larger.
Perpendicular to the contours
The slope is zero in the directions perpendicular to , and walking along a contour means not climbing. The two facts are the same fact. Let , trace the level curve through a point, arriving there at with velocity . Since for every , its derivative is zero, and the chain rule says
So the gradient is perpendicular to the tangent of the level curve through the point. For the paraboloid at , the level circle has tangent direction , and . On a map the fall line crosses every contour at right angles, which is why streams, running down the negative gradient, cut the contours squarely.
The gradient therefore serves as a normal to the curve, and the tangent line at is . Its slope is , the implicit differentiation formula of the previous lesson, now read as a statement about a perpendicular.
Tangent planes to level surfaces
A function of three variables has level surfaces rather than curves, and the argument applies to every curve on the surface through a point : its velocity at satisfies . So is perpendicular to every direction in which the surface can be left along itself, which makes it a normal to the tangent plane, and when it is not the plane is
A sphere checks it. For at , , parallel to the radius, as geometry demands, and the plane is . A graph is a level surface too: is , with , minus the normal found earlier in this course by a cross product.
Example. Find the tangent plane to the ellipsoid at .
The point lies on it, since . The gradient is , or after multiplying by . The plane is , which is , meeting the axis at .
Now you. Find the tangent plane to the surface at .
Answer
The gradient is , so the plane is , which is .
Gradient descent
To find the lowest point of a function too complicated to solve for, walk downhill: from the current point take a small step along , the steepest way down, and repeat. With a step size the rule is . Augustin-Louis Cauchy proposed it in 1847, and machine learning now uses it to fit models with millions of variables.
Take , whose minimum is at the origin, starting from with . The gradient is , so each step sends to and to . The iterates are , and , with values falling from to , and . The first step did not aim at the minimum: while the origin lies along , the elongated hill again. The steep direction settles quickly while shrinks by only a fifth per step.
The step size is a genuine limitation. With the update becomes , so runs and the values go : each step overshoots the valley floor further than it started. Too small a step crawls, too large a step diverges, and the safe range depends on how sharply the function curves.
Where the gradient vanishes
Suppose a differentiable has a local maximum at a point, and there. Walking a short way along climbs at rate and reaches higher values, so the point was not a maximum. Walking against rules out a minimum the same way. At a local maximum or minimum, then, : every partial derivative is zero and the tangent plane is horizontal. Gradient descent agrees, since its steps stop exactly where the gradient vanishes.
The converse fails. For the gradient vanishes at the origin, yet the surface rises east and west and falls north and south, like a mountain pass. Setting finds the candidates, and telling summits, hollows and passes apart is the work of the next lesson.