Ma · Mathematics

What Do You Get When You Differentiate a Function Twice?

Published By the 9to5Science editorial team

At a glance

  1. 1. Start with the function

    For a scalar function of one variable, the first derivative is its slope function.

  2. 2. Differentiate again

    The second derivative measures how the slope changes; in several variables, it forms the Hessian matrix.

  3. 3. Interpret the result

    Use the second derivative or Hessian to study curvature and local maxima, minima, and saddle points.

If you differentiate a function once, you get a function describing its rate of change. Differentiating that result gives the second derivative. In one variable, it is a number at each input; for a scalar function of several variables, the corresponding object is a matrix called the Hessian.

The second derivative tells you how the slope changes. That makes it useful for understanding curvature and for classifying stationary points, such as local maxima and minima.

One variable: the second derivative

For a differentiable function f(x)f(x), the first derivative is f′(x)f'(x). Differentiate again to get

f′′(x)=ddxf′(x)=d2fdx2.f''(x) = \frac{d}{dx}f'(x) = \frac{d^2 f}{dx^2}.

The value f′′(x)f''(x) measures the instantaneous rate of change of the slope. If f′′(x)>0f''(x)>0 throughout an interval, the graph bends upward there (it is concave up). If f′′(x)<0f''(x)<0, it bends downward (concave down). When f′′(x)=0f''(x)=0 at a point, the point may be an inflection point, but that condition alone does not guarantee one.

Worked example

Let f(x)=x3−3x2+2f(x)=x^3-3x^2+2. Then

f′(x)=3x2−6x,f′′(x)=6x−6.\begin{aligned} f'(x) &= 3x^2-6x,\\ f''(x) &= 6x-6. \end{aligned}

At x=1x=1, the second derivative is f′′(1)=0f''(1)=0. The graph does change concavity there: f′′(x)<0f''(x)<0 when x<1x<1 and f′′(x)>0f''(x)>0 when x>1x>1, so in this example it does change concavity, and x=1x=1 is an inflection point. At x=2x=2, f′(2)=0f'(2)=0 and f′′(2)=6>0f''(2)=6>0, so the second-derivative test identifies a local minimum at x=2x=2.

Several variables: the Hessian matrix

For a scalar function f(x1,…,xn)f(x_1,\ldots,x_n), the first derivative is represented by its gradient:

∇f=(∂f∂x1,…,∂f∂xn).\nabla f = \left(\frac{\partial f}{\partial x_1},\ldots,\frac{\partial f}{\partial x_n}\right).

Differentiating the gradient gives a matrix of second partial derivatives, called the Hessian:

Hf=∇2f=[∂2f∂xi ∂xj]i,j=1n.H_f = \nabla^2 f = \left[\frac{\partial^2 f}{\partial x_i\,\partial x_j}\right]_{i,j=1}^{n}.

For two variables, this is

Hf(x,y)=[fxxfxyfyxfyy].H_f(x,y)= \begin{bmatrix} f_{xx} & f_{xy}\\ f_{yx} & f_{yy} \end{bmatrix}.

So the direct multivariable analogue of “differentiate twice” is not generally another gradient vector: it is the Jacobian matrix of the gradient. If the second partial derivatives are continuous near a point, the mixed partials agree there, so fxy=fyxf_{xy}=f_{yx} and the Hessian is symmetric.

Worked example with a Hessian

Take f(x,y)=x2y+3y2f(x,y)=x^2y+3y^2. Its gradient is

∇f(x,y)=(2xy,  x2+6y).\nabla f(x,y)=(2xy,\;x^2+6y).

Differentiate each component with respect to each variable:

Hf(x,y)=[2y2x2x6].H_f(x,y)= \begin{bmatrix} 2y & 2x\\ 2x & 6 \end{bmatrix}.

At (1,2)(1,2), the Hessian is

Hf(1,2)=[4226].H_f(1,2)= \begin{bmatrix} 4 & 2\\ 2 & 6 \end{bmatrix}.

Its entries describe the second-order changes in different coordinate directions, including how the variables interact through the mixed partial derivatives. For a twice continuously differentiable function, at a stationary point, the Hessian can help classify the local shape: a positive-definite Hessian indicates a strict local minimum, a negative-definite one a strict local maximum, and an indefinite one a saddle point. If the Hessian is positive semidefinite or negative semidefinite but not definite, the test may be inconclusive.

What the second derivative does not tell you by itself

A second derivative describes local change, not the entire shape or behavior of a function. In one variable, f′′(a)=0f''(a)=0 does not by itself prove that aa is an inflection point or a maximum or minimum. For example, f(x)=x4f(x)=x^4 has f′′(0)=0f''(0)=0, but x=0x=0 is a local minimum, not an inflection point. You need additional information, such as signs on either side or higher-order terms.

Likewise, in several variables, a zero gradient means a stationary point, but the Hessian test can be inconclusive. The function may require a more detailed examination near that point.

Common mistakes

  • Confusing the second derivative with the gradient. In one variable, the gradient is just the derivative (up to convention); differentiating it again gives f′′f''. In several variables, differentiating the gradient gives a matrix.
  • Treating f′′(a)=0f''(a)=0 as a classification. Zero is a test result, not a conclusion; check the function or its derivatives around the point.
  • Assuming every function has a second derivative. A function must be sufficiently smooth for the relevant second derivatives to exist. A first derivative can exist even when the second derivative does not.
  • Assuming the Hessian applies unchanged to vector-valued outputs. The Hessian described here is for a scalar-valued function. Differentiating a vector-valued function twice generally produces a higher-order array of derivatives.

In short, the name of the result depends on the function’s inputs and outputs: a scalar function of one variable has a second derivative; a scalar function of several variables has a Hessian matrix.

References

  1. Calculus, Early Transcendentals — James Stewart
  2. Calculus: Early Transcendentals — Jon Rogawski, Colin Adams, and Robert Franzosa

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.