The Gradient and Directional Derivatives
Stand on a hillside modeled by a height function . If you take a step in some direction, how fast does your altitude change? This question has infinitely many answers. There is one for each direction you might walk. Yet all of them are governed by a single vector attached to your location: the gradient. Understanding this vector converts a seemingly infinite family of rates of change into one compact piece of data. This matters because most of the interesting objects in science are scalar-valued functions of several variables. These include temperature fields, potential energy, pressure, probability densities, and loss functions in machine learning. The question "which way does it increase fastest, and how fast?" is asked constantly. The gradient answers both parts of that question simultaneously. It does so by packaging every directional derivative into one linear functional. The big picture is this: differentiability is already established as the existence of a good linear approximation to near a point. This is exactly the hypothesis needed to guarantee something important. It guarantees that all directional derivatives exist, vary predictably with direction, and are computed by a single dot product with the gradient. Without differentiability, directional derivatives can exist in every direction. Yet they can fail to combine into anything so simple. We exhibit this phenomenon explicitly. This article builds the directional derivative from the total derivative. It proves the gradient formula and the steepest-ascent theorem. It establishes that gradients are orthogonal to level sets. It also works through the subtleties. These include the classic counterexample of a function with all directional derivatives but no gradient behavior at all.
- The directional derivative measures the instantaneous rate of change of at in direction .
- If is differentiable at , then for every unit vector .
- The gradient points in the direction of steepest ascent, and is that maximal rate.
- The gradient is orthogonal to the level set of through , wherever .
- Existence of all directional derivatives at a point does not imply differentiability there, so the dot-product formula can fail.
- Key idea: differentiability turns the infinite family of directional derivatives into one linear functional, the gradient, via .
Where this lives today
The gradient is the computational engine of gradient descent and its variants (stochastic gradient descent, Adam, momentum methods), which train nearly every modern machine learning model by repeatedly stepping in the direction to decrease a loss function . In physics, the gradient of a potential energy function gives (up to sign) the force field, , linking this purely calculus-based construction to Newtonian mechanics and to the theory of conservative vector fields. In thermodynamics and fluid dynamics, gradients of temperature or pressure fields drive heat flow (Fourier's law, ) and fluid motion. In computer graphics and image processing, image gradients detect edges by identifying directions and magnitudes of rapid intensity change. In optimization theory more broadly, the gradient underlies first-order necessary conditions for extrema, feeding directly into constrained optimization via Lagrange Multipliers, where the orthogonality of to level sets becomes the geometric heart of the multiplier condition. In differential geometry, the gradient generalizes to Riemannian manifolds as the vector field dual to under the metric, extending every idea in this article beyond flat Euclidean space.
Ask the tutor: How does the gradient formula change when is defined on a curved surface instead of flat Euclidean space?
Let be defined on an open set , let , and let be a unit vector (). The directional derivative of at in the direction is
provided this limit exists. (Here ranges over real numbers near , positive or negative; since is open, for all sufficiently small .) If is differentiable at , all partial derivatives exist, and we define the gradient of at as the vector of partial derivatives
Recall (from Differentiability and the Total Derivative) that is differentiable at if there exists a linear map such that
When this holds, for all .
Intuition
Think of as elevation on a topographic map. Fix a point and imagine standing there facing some compass direction . The directional derivative is the slope you feel under your feet as you begin walking in that direction — positive if you're climbing, negative if descending, zero if you're momentarily walking level. If is merely differentiable, the graph of near looks, at high magnification, like a plane (the tangent plane). Walking on a plane in any direction produces a slope that depends on direction in the simplest possible way: linearly, via a dot product with a fixed "tilt vector." That tilt vector is exactly . Since , where is the angle between and the gradient, the slope is maximized when — that is, when you walk along the gradient — and it is maximized precisely at the value . Walking perpendicular to the gradient () keeps you level: this is the direction tangent to the level curve through .
Deriving the formula
The key move is to reduce the directional derivative to ordinary single-variable differentiation of the composite function , and to exploit the definition of differentiability directly (not the chain rule as a black box, since the chain rule is normally proved from this kind of argument).
Let be open, let , let , and suppose is differentiable at . Then for every unit vector , the directional derivative exists and
Consequently: 1. (Steepest ascent) If , then is maximized over unit vectors exactly at , with maximum value ; it is minimized at , with minimum value . 2. (Level-set orthogonality) If is differentiable with and for all (i.e. traces the level set through ), then
Step 1: Reduce to a one-variable limit using differentiability directly. Fix a unit vector . Since is open and , there is such that for all . By the hypothesis that is differentiable at , there is a linear map , given by , such that
(Here is simply defined by this equation; the content of differentiability is the limit condition on .)
Step 2: Substitute . For real with , set in . Since is linear and ,
Divide by :
Step 3: Show the remainder term vanishes as . For , , so
As (with ), , so by the limit condition in , . Hence as .
Step 4: Conclude the limit exists and equals . Taking in Step 2's identity and using Step 3,
This proves the main formula. In particular, taking recovers , consistent with the definition of .
Step 5 (Part 1 — steepest ascent): maximize the dot product. Suppose . By the Cauchy–Schwarz inequality, for any unit vector ,
with equality if and only if is a nonnegative scalar multiple of ; since is a unit vector this forces . (Equality in Cauchy–Schwarz holds iff are linearly dependent with a nonnegative proportionality constant, a standard fact proved by expanding via the discriminant of .) So is uniquely maximized at , and the maximum value is . Replacing by everywhere (which is again a unit vector) shows , so the minimum of over unit vectors is , attained uniquely at .
Step 6 (Part 2 — orthogonality to level sets): differentiate the constant composite. Let be as stated: differentiable at , , and identically for near . Since is constant, . We compute directly from differentiability of at , exactly as in Steps 1–4 but with the path instead of the straight ray . Write , so as and by definition of (in particular for small unless , in which case the conclusion is trivial). By applied with ,
Divide by :
As : the left side since is constant; the first term on the right by linearity of the dot product and ; and the second term by the same argument as Step 3 (writing , where the first factor by differentiability of and the second factor , a bounded quantity, when ; if the whole displayed identity gives directly). Hence
as claimed.
∎This proof technique — reducing a multivariable limit to a one-variable limit along a straight line or curve, then controlling the error term using the defining property of differentiability — is the standard method for deriving directional-derivative and chain-rule identities; it is not circular because it invokes only the definition of differentiability, never a later theorem such as the chain rule itself.
If is differentiable at and is a local maximum or local minimum of (relative to ), then .
Suppose . By Part 1 of the theorem above, taking gives . By definition of the directional derivative as a limit,
so for all sufficiently small , , contradicting that is a local maximum. Similarly, using or the direction , one finds points arbitrarily close to with -value below , contradicting a local minimum. Hence . (This is a preview of the first-order condition used systematically in Critical Points and Extrema and in Lagrange Multipliers.)
∎Worked examples
Example 1 — steepest ascent for a non-symmetric quadratic. Let and let . We compute the directional derivative of at in the direction of (not a unit vector), and find the direction and rate of steepest ascent. Gradient. Compute partials:
At : , and . So
Since is a polynomial, it is differentiable everywhere (its partials exist and are continuous, which — by the standard sufficient condition built on the total-derivative definition — implies differentiability), so the Theorem applies. Directional derivative in the direction of . First normalize: , so . Then
So walking from in the direction , increases at instantaneous rate per unit distance. Steepest ascent. The direction of steepest ascent is , and the maximal rate of increase is . Sanity check: the direction makes an angle with satisfying , so — a modest deviation from the steepest direction, consistent with being close to, but strictly less than, the maximum .
Example 2 — level-curve orthogonality with an explicit parametrization. Let , and consider the level curve through the point . We check numerically that is orthogonal to this curve, using an explicit local parametrization solved from the level-set equation, rather than assuming its existence. First verify lies on the curve: . Compute . So . That is not — let's instead choose a genuinely clean point on the level curve : take , and solve , giving . Set with , so exactly by construction. Gradient at . , . At :
Numerically, and , so . Local parametrization of the level curve. Since , the Implicit Function Theorem (built on differentiability, as established elsewhere) guarantees the level set is locally the graph near , with . Implicit differentiation of gives
At : . A tangent vector to the curve at is (parametrizing by itself). Check orthogonality.
confirming (up to rounding) , exactly as the Theorem's Part 2 predicts. (The tiny residual is rounding error from truncating ; algebraically the identity is exact.)
The Theorem requires differentiability of at , not merely the existence of directional derivatives in every direction. Weakening this hypothesis breaks the conclusion. Define by
Claim: every directional derivative of at the origin exists, and is given by an explicit (non-linear) formula in the direction, so the map is not of the form for any fixed vector — in particular it is not linear, so no "gradient dot product" formula can hold. Let be a unit vector. Case . For small ,
So
which exists and is finite for every with . Case (i.e. ). Then for all , so , consistent with the formula having a removable-looking but genuinely undefined value at resolved directly to by this direct computation. So every directional derivative exists at the origin. In particular the partials exist: at , ; at , . So if a gradient-dot-product formula held, we would need and hence for every . But at : , , so
This contradicts what the (falsely assumed) gradient formula would require. The resolution: is not differentiable at the origin. (Indeed is not even continuous there: along the parabolic path , for all , while , so ; differentiability requires continuity, which fails.) This shows the differentiability hypothesis in the Theorem cannot be weakened to "all directional derivatives exist": that weaker condition is compatible with a wildly non-linear, even discontinuous, directional-derivative profile.
Scope, edge cases & common traps
| Situation | What is true | What can go wrong |
|---|---|---|
| differentiable at | for all unit ; gradient gives steepest ascent | — |
| has all partials, is near | is automatically differentiable at (standard sufficient condition), so the Theorem applies | Students sometimes skip checking continuity of partials and wrongly assume differentiability from mere existence of partials |
| has all directional derivatives at , not known differentiable | Nothing about linearity in is guaranteed | The counterexample above: gradient-style reasoning simply fails |
| not a unit vector | as literally defined is not the same as unless | Forgetting to normalize before applying the dot-product formula (see Example 1) |
| All directional derivatives at are zero; is a critical point | Concluding is automatically a local extremum — false in general (e.g. saddle points), addressed in Critical Points and Extrema | |
| Level set orthogonality | Holds wherever | At points where , the level set may fail to be a smooth curve at all (e.g. self-intersections), and "orthogonal direction" is not even well posed |
The mathematician behind it
Origins · 1 minSir William Rowan Hamilton and how this was discovered
Hamilton, already renowned for his reformulation of mechanics (Hamiltonian dynamics), was among the pioneers who treated differential operators acting on scalar fields as objects in their own right. The symbol (nabla), whose modern use as the gradient operator crystallized through the work of Hamilton and later Gibbs and Heaviside, encodes exactly the packaging of partial derivatives into a single vector-valued operation described in this article. Hamilton's broader program — treating operators algebraically, on par with numbers and vectors — set the stage for vector calculus as a coherent language, later systematized by Josiah Willard Gibbs and Oliver Heaviside for use in electromagnetism.
Why must be a unit vector in the definition of the directional derivative?
The directional derivative is meant to measure a rate of change per unit distance traveled. If were not normalized, the quantity would depend on the arbitrary length of , scaling linearly with by linearity of the limit (replacing with multiplies the result by ). Requiring pins down a canonical, comparable notion of "speed of change while moving at unit speed," which is what makes the maximal-rate statement ( is the steepest rate) a meaningful, well-posed claim rather than something that could be inflated arbitrarily by rescaling the direction vector.
Does the gradient formula require to be , or just differentiable at the single point ?
Only differentiability at the single point is needed for the Theorem as proved here; the proof never uses behavior of at other points, nor continuity of the partials near . However, differentiability at an isolated point without continuous partials nearby is a somewhat pathological, hard-to-construct situation. In practice, the much easier-to-check sufficient condition — all first partials exist and are continuous throughout an open neighborhood of — is what analysts verify, since it implies differentiability at (and at every point of that neighborhood) via a mean value theorem argument, which is a separate, standard result built directly on the definition of the total derivative.
Is the gradient basis-dependent? Does it change if I use different coordinates?
The directional derivative is a geometric, coordinate-free quantity: it only depends on , , and the direction in space. The gradient vector , as the vector of partial derivatives, is initially computed component-wise using standard Cartesian coordinates. If you change to a different orthonormal basis, the gradient's components transform exactly as a vector's components should (via the orthogonal change-of-basis matrix), so the vector itself — as a geometric arrow in space — does not change; only its coordinate representation does. In more general (non-orthonormal or curvilinear) coordinate systems, one must be more careful, and the gradient is more properly understood as the vector dual to the differential under the ambient inner product — a refinement studied in differential geometry.
What happens to the steepest-ascent theorem if ?
If , the gradient formula still holds and gives for every unit vector : the function is instantaneously flat in every direction from . There is no well-defined "direction of steepest ascent" because every direction ties for the (trivial) maximum rate of . Such points are called critical points, and determining whether actually has a local max, local min, or saddle behavior there requires second-order information — the subject of Critical Points and Extrema, which builds on exactly this vanishing-gradient condition as its starting point.
Can the directional derivative exist without being continuous at that point?
Yes, and the counterexample in this article demonstrates precisely this: the function (extended by at the origin) has a directional derivative in every direction at the origin, yet fails to even be continuous there, since its limit along the parabola is . This shows that the existence of directional derivatives is a comparatively weak hypothesis — much weaker than differentiability, and even weaker than continuity — which is exactly why the Theorem in this article insists on full differentiability rather than the mere existence of directional derivatives.
How does this relate to the total derivative and the chain rule?
The directional derivative is a special case of a more general fact: if is any differentiable curve with , then , which is the multivariable chain rule. Taking for a unit vector recovers exactly the directional derivative formula proved here. In fact, the proof technique used above (reduce to a one-variable limit, control the error via the differentiability remainder) is the same technique used to prove the chain rule itself, so this article's Theorem can be seen as the chain rule's most important special case, proved independently and without circularity.
Why is the gradient orthogonal to the level set rather than, say, tangent to it?
Along the level set , the function's value never changes, so the rate of change of along any tangent direction to that level set must be zero — that's the content of the orthogonality proof, which shows for any curve tracing the level set. Since is a fixed vector whose dot product with every tangent direction of the level set vanishes, and (in , generically) the level set's tangent line is one-dimensional, this pins the gradient down (up to scaling) to the unique direction perpendicular to that tangent line — hence orthogonal, not tangent, to the level set.