Standing on a hillside, you can walk north, east, or any direction in between, and the slope you feel depends on which way you face. Partial derivatives give the slope only due east and due north. The directional derivative gives it for every heading, and for a differentiable function a single vector, the gradient, holds all of those slopes at once.
Key terms
Unit direction
Definition A direction in is given by a unit vector , one with . Any nonzero vector determines the unit direction
The zero vector gives no direction.
In plain words A direction should say which way to go, not how far. Dividing by the length removes the “how far” part.
Example The vector has length , so its direction is . Using itself in the formulas below would multiply every rate by .
Directional derivative
Definition Let be real valued on an open set , let be in , and let be a unit vector. The directional derivative of at in the direction is the one-variable limit
when it exists. The partial derivatives are the special cases , the standard basis vectors. Replacing by changes the sign of the limit.
In plain words Walk through along a straight line at unit speed and measure how fast changes as you pass. On the graph this is the slope of the curve cut out by a vertical plane through in the direction .
Example For at with , expanding gives
Subtracting , dividing by and letting gives .
Gradient formula for differentiable functions
Definition If all first partial derivatives of exist at , the gradient of at is the vector
If is differentiable at , then the directional derivative exists for every unit vector and
This follows from the chain rule applied to . Without differentiability the formula can fail even when every directional derivative exists.
In plain words For a differentiable function you never need the limit again. Compute the partial derivatives once, and every directional rate is a dot product.
Example The polynomial is differentiable everywhere. At its gradient is . Toward , of length , the unit direction is , and
In the first example the same formula gives , matching the limit.
Steepest ascent
Definition Let be differentiable at with . If is the angle between and , then
So the largest directional derivative is , reached only for , the smallest is , reached only in the opposite direction, and the rate is exactly for directions perpendicular to the gradient.
In plain words The gradient points in the input space toward the steepest climb, and its length is how steep that climb is. Walking against it is the steepest descent.
Example On the hill at the gradient is , of length . The steepest way up is the direction
with slope about . Moving along keeps the height unchanged to first order.
Gradient as a level-set normal
Definition Let be real valued on an open set , let be a constant, and let lie on the level set . Suppose is differentiable at . If , defined on an open interval around , is a curve in the level set, differentiable at with , then differentiating gives
If moreover is on and , then by the implicit function theorem the level set near is a smooth curve () or surface (), namely the graph of a function of of the variables. Then is a normal vector to it, and its tangent line or tangent plane at is .
In plain words Moving along a level set keeps constant, so the rate of change is zero, and that forces the gradient to be perpendicular to the level set. Wherever the gradient is not zero, the steepest way uphill is at right angles to the contour lines.
Example The ellipsoid is a level set of a polynomial and contains . The gradient there is , which is not zero. The tangent plane is . Dividing by gives
which simplifies to .
Gradient zero
Definition A point where is differentiable and is a critical point. There every directional derivative is , there is no direction of steepest ascent, and the level set through need not be a smooth curve or surface, so the gradient gives no normal vector there.
In plain words A zero gradient means the surface is flat to first order in every direction. It could be a peak, a pit, or a saddle, and the contour through it can look strange.
Example The function has , which is at the origin. The level set is the pair of lines and , which cross at the origin, so no single normal line exists there. For the level set is only the point .
Directional derivatives alone are not enough
Definition A function can have a directional derivative at in every unit direction without being differentiable at , and even without being continuous there. In that case the formula may fail. Differentiability must be checked separately, for example through partial derivatives that are continuous on an open set containing .
In plain words Directional derivatives test only straight lines through the point. A function can behave nicely on every line and still jump along a curve.
Example Let for and . For a unit vector and ,
which tends to if and is if . So every directional derivative exists. For it is , while would predict . Along the parabola with the function equals , so it is not continuous at the origin and not differentiable there.
Check yourself
- Find the rate of change of at in the direction of .
Show the answer
The function has continuous partial derivatives, so it is differentiable. The gradient is at , and the unit direction is . The rate is
- In which unit direction does decrease fastest at , and at what rate?
Show the answer
The gradient is , of length . The fastest decrease is in the direction , at the rate .
- Find the tangent plane to the surface at .
Show the answer
With the gradient is at , which is not zero. The tangent plane is , or .