Tutorials › Calculus III › Gradient Magnitude, Contours, and Rate of Change

Directional Derivatives and Gradients · Tutorial 382 of 999

Gradient Magnitude, Contours, and Rate of Change

Use the gradient to estimate how quickly a scalar field changes and how far apart nearby equal-value contours are locally.

Intermediate 9 min read

What You'll Learn

  • Define level curves and level surfaces as sets where a scalar function has a fixed value.
  • Relate the gradient’s direction to increasing function values.
  • Derive the local change in function value per unit distance along the gradient.
  • Estimate nearby contour spacing from a change in level value and the gradient magnitude.
  • Distinguish local contour-spacing estimates from exact distances.
  • Check units and avoid confusing gradient magnitude with its individual components.

Reading Change from Contours

Contour maps represent a scalar function by drawing curves or surfaces on which its value is constant. A weather map, for example, might draw curves of equal temperature. If equal temperature intervals are represented, closely spaced contours suggest that temperature changes rapidly across the map, while widely spaced contours suggest a gentler change.

The gradient gives a precise local way to interpret this picture. At a point where a differentiable function has a nonzero gradient, the gradient points in a direction of increase, and its magnitude is the rate of change per unit distance in that direction. Consequently, a small change in contour value corresponds locally to a shorter distance when the gradient magnitude is larger.

The word locally matters. Contour spacing can vary from place to place, and a spacing estimate based on the gradient is most reliable near the point where that gradient was evaluated.

Level Curves, Level Surfaces, and the Gradient

For a scalar function \(f\) of two variables, a level curve with value \(c\) is the set of points \((x,y)\) satisfying \(f(x,y)=c\). For a function of three variables, the corresponding set of points \((x,y,z)\) is a level surface. A contour map displays selected level curves; the level surfaces of a three-variable function are often visualized separately or by cross-sections.

Definition: If \(f\) is differentiable, its gradient at a point is the vector of its partial derivatives. In two variables, \(\nabla f=(f_x,f_y)\); in three variables, \(\nabla f=(f_x,f_y,f_z)\). The gradient magnitude is its Euclidean length, \(\|\nabla f\|\).

For a unit vector \(\mathbf{u}\), the directional derivative \(D_{\mathbf{u}}f(\mathbf{p})\) is the instantaneous rate at which \(f\) changes as one moves from \(\mathbf{p}\) in direction \(\mathbf{u}\), per unit distance. At a differentiable point, the gradient formula for directional derivatives gives \(D_{\mathbf{u}}f(\mathbf{p})=\nabla f(\mathbf{p})\cdot\mathbf{u}\). In particular, when the gradient is nonzero, the unit vector in its direction is \(\nabla f/\|\nabla f\|\).

Why Gradient Magnitude Measures Local Contour Spacing

Suppose we move a short distance \(s\) from a point \(\mathbf{p}\), following the unit direction of the gradient there. The directional derivative says that the instantaneous rate of change at the starting point is \(\|\nabla f(\mathbf{p})\|\). For a small move, the change in function value is therefore approximately that rate multiplied by the distance.

$$ \Delta f\approx \|\nabla f(\mathbf{p})\|s. $$

This is a local approximation, not generally an exact equation for a finite move. Solving it for the distance gives the useful spacing estimate

$$ s\approx\frac{|\Delta f|}{\|\nabla f(\mathbf{p})\|}, \qquad \|\nabla f(\mathbf{p})\|\ne 0. $$

Here \(s\) is measured along the gradient direction, and \(|\Delta f|\) is the size of the change between nearby contour values. The absolute value makes the estimated distance nonnegative; moving in the gradient direction corresponds to an increase in \(f\), while moving in the opposite direction corresponds locally to a decrease.

Interpretation: For the same small contour-value interval, a larger gradient magnitude means a smaller estimated distance between the corresponding nearby contours, measured in the gradient direction. A smaller magnitude means a larger estimated distance.

Derivation of the Local Rate

The relationship follows directly from the directional derivative formula. Assume \(f\) is differentiable at \(\mathbf{p}\) and \(\nabla f(\mathbf{p})\ne\mathbf{0}\). Take the unit vector \(\mathbf{u}\) pointing along the gradient. Because \(\mathbf{u}=\nabla f(\mathbf{p})/\|\nabla f(\mathbf{p})\|\), the directional rate is

$$ D_{\mathbf{u}}f(\mathbf{p}) =\nabla f(\mathbf{p})\cdot \frac{\nabla f(\mathbf{p})}{\|\nabla f(\mathbf{p})\|} =\frac{\nabla f(\mathbf{p})\cdot\nabla f(\mathbf{p})} {\|\nabla f(\mathbf{p})\|} =\frac{\|\nabla f(\mathbf{p})\|^2} {\|\nabla f(\mathbf{p})\|} =\|\nabla f(\mathbf{p})\|. $$

Thus, at the starting point, the change per unit distance along this direction is exactly the gradient magnitude. For a small distance \(s\), the first-order local approximation is \(\Delta f\approx D_{\mathbf{u}}f(\mathbf{p})s\), giving \(\Delta f\approx\|\nabla f(\mathbf{p})\|s\). This derivation explains why contour spacing depends on both the value interval and the gradient magnitude; it does not claim that the approximation is exact over a long distance.

Worked Examples

Worked Example: Estimating Spacing on a Circular Contour Map

Let \(f(x,y)=x^2+y^2\), and examine the point \(\mathbf{p}=(3,4)\). We will estimate the distance along the gradient direction needed for \(f\) to increase by \(0.5\).

First calculate the gradient and its magnitude:

$$ \nabla f(x,y)=(2x,2y), \qquad \nabla f(3,4)=(6,8), \qquad \|\nabla f(3,4)\|=\sqrt{6^2+8^2}=\sqrt{100}=10. $$

The unit direction of the gradient is \(\mathbf{u}=(6/10,8/10)=(3/5,4/5)\). The local spacing estimate for a value increase of \(0.5\) is

$$ s\approx\frac{0.5}{10}=0.05. $$

We can check how close this estimate is by moving exactly \(s\) units along that ray. The new point is \((3+3s/5,4+4s/5)\). Its distance from the origin is \(5+s\), so its function value is \((5+s)^2\). To get an exact increase of \(0.5\), solve \((5+s)^2-25=0.5\). Since \(s\) is a distance, take the positive solution:

$$ s=\sqrt{25.5}-5\approx 0.04975. $$

Substitution checks the exact change: \((5+s)^2-25=25.5-25=0.5\). The local estimate \(0.05\) is close to this exact distance. The contours are circles here, and the estimate concerns spacing along the gradient direction at the specified point.

Worked Example: Exact Spacing for a Linear Function

Let \(f(x,y)=3x+4y\), and start at \(\mathbf{p}=(1,0)\). Find the distance along the gradient direction from the contour \(f=3\) to the contour \(f=5\).

The gradient is constant, and its magnitude is

$$ \nabla f=(3,4), \qquad \|\nabla f\|=\sqrt{3^2+4^2}=5. $$

The value change is \(\Delta f=5-3=2\). The local spacing formula suggests \(s=2/5=0.4\). In this linear case, the rate is constant along the path, so this distance is exact. To verify, the unit gradient direction is \(\mathbf{u}=(3/5,4/5)\). After moving distance \(s\), the point is \((1+3s/5,4s/5)\), and its function value is

$$ 3\left(1+\frac{3s}{5}\right) +4\left(\frac{4s}{5}\right) =3+\frac{9s+16s}{5} =3+5s. $$

At \(s=0.4\), this value is \(3+5(0.4)=5\), as required. The change is \(5-3=2\), and dividing that change by the rate \(5\) gives \(2/5=0.4\) units of distance. The exactness here comes from the constant gradient; for a nonlinear function, the rate can change along the path.

Worked Example: A Local Estimate on a Level Surface

Let \(f(x,y,z)=x^2+y^2+z^2\), and consider \(\mathbf{p}=(1,2,2)\). Estimate how far to move along the gradient direction for \(f\) to increase by \(0.12\).

Compute the gradient, its magnitude, and the unit direction:

$$ \nabla f=(2x,2y,2z), \qquad \nabla f(1,2,2)=(2,4,4), $$ $$ \|\nabla f(1,2,2)\| =\sqrt{2^2+4^2+4^2} =\sqrt{36}=6, \qquad \mathbf{u}=\left(\frac13,\frac23,\frac23\right). $$

The local distance estimate is \(s\approx 0.12/6=0.02\). To check the approximation, a move of distance \(s\) reaches \((1+s/3,2+2s/3,2+2s/3)\). Because the displacement has length \(s\), expanding the squared distance from the origin gives the function-value change \(6s+s^2\). At the estimated distance \(s=0.02\),

$$ 6(0.02)+(0.02)^2=0.12+0.0004=0.1204. $$

This is close to \(0.12\), but not equal to it. For the exact distance, solve \(6s+s^2=0.12\), or \((s+3)^2=9.12\). The positive solution is \(s=\sqrt{9.12}-3\approx0.01993\). Substitution gives \(6s+s^2=0.12\), as required. The small difference from \(0.02\) illustrates why the gradient formula gives a local estimate rather than an exact finite-distance rule.

What Contour Spacing Does and Does Not Tell You

When interpreting a contour map, always check how the contour values are labelled. A drawing with contours labelled \(10, 20, 30\) does not use the same value interval as one with contours labelled \(10, 12, 14\). Spacing alone indicates the rate only when the sizes of the contour-value intervals are taken into account. For example, a distance of \(1\) unit for a value change of \(10\) corresponds to a different rate from a distance of \(1\) unit for a value change of \(2\).

The spacing estimate is directional and local. In the formula \(s\approx|\Delta f|/\|\nabla f\|\), the distance is measured along the gradient direction near the point in question. It is not automatically the shortest distance between two entire contours, nor should it be applied unchanged across a large region where the gradient may vary.

The nonzero-gradient condition also matters. If \(\|\nabla f(\mathbf{p})\|=0\), the displayed spacing formula would divide by zero and cannot be used. The gradient-based first-order rate at that point is zero in every direction, so another analysis would be needed to understand nearby changes.

Common Mistake: Using the Wrong Value Interval

Suppose the gradient magnitude is \(2\sqrt{17}\), and the nearby contour values differ by \(0.2\). A common arithmetic error is to write

$$ \frac{0.2}{2\sqrt{17}} =\frac{1}{5\sqrt{17}}. $$

This simplification is incorrect: \(0.2=1/5\), and the denominator still includes the factor \(2\). The correct estimate is

$$ s\approx\frac{0.2}{2\sqrt{17}} =\frac{1/5}{2\sqrt{17}} =\frac{1}{10\sqrt{17}} \approx 0.0243. $$

A quick check is to multiply the estimated distance by the rate. The correct expression gives \((2\sqrt{17})(1/(10\sqrt{17}))=1/5=0.2\), matching the contour-value change. The incorrect expression would give \(2/5=0.4\), twice the required change.

Why This Interpretation Is Useful

Gradient magnitude connects the numerical information in a function to the visual spacing of its contours or level surfaces. In applications, this helps interpret maps of temperature, pressure, elevation, or concentration: equal-value contours packed close together indicate a larger local change per unit distance, provided the value intervals and map scale are understood.

For a function with units, the gradient’s components and magnitude have units of function value per unit distance. For example, if \(f\) is temperature in degrees and coordinates are measured in metres, then \(\|\nabla f\|\) is measured in degrees per metre. Dividing a temperature interval by that rate produces metres, as a distance estimate should. Keeping units visible is a useful check on both interpretation and arithmetic.

Check Your Understanding

Use the definitions and local spacing relationship to answer these questions.

  1. What set of points is described by the level curve \(f(x,y)=c\)?
  2. If nearby contours differ in value by \(0.6\) and the gradient magnitude is \(3\), what is the local spacing estimate along the gradient direction?
  3. Why must the contour-value interval be considered before comparing spacing on two contour maps?
  4. For \(f(x,y)=x^2+y^2\), find \(\nabla f\) and its magnitude at \((0,2)\).
  5. Why is \(|\Delta f|/\|\nabla f(\mathbf{p})\|\) a local estimate rather than an exact distance in general?