Unit 3, lesson 20

Multivariable Taylor Approximation

How to build quadratic and higher Taylor models of a function of several variables with the Hessian and multi-index notation, and how to tell how far the model can be trusted.

  • Theory part 39
  • Practice part 40
  • Derivatives and Approximation

A tangent plane matches a surface’s height and tilt at one point, but it cannot see whether the surface curves up like a bowl or bends like a saddle. Adding second derivatives fixes that. The resulting quadratic model is the natural next step when a linear approximation is too crude, and it is the tool behind the second derivative test for extrema. The same idea continues to cubic and higher models, and Taylor’s theorem says how large the error can be.

Key terms

Symmetry of mixed partials

Definition Let ff be defined on an open set U⊆RnU \subseteq \mathbb{R}^n. If the second partial derivatives fxixjf_{x_i x_j} and fxjxif_{x_j x_i} exist and are continuous on UU, then

fxixj=fxjxion U.f_{x_i x_j} = f_{x_j x_i} \quad \text{on } U.

This is Clairaut’s theorem. In particular it holds for every ff of class C2C^2 on UU, and for ff of class CkC^k on UU every partial derivative of order at most kk is independent of the order of differentiation. Without continuity the mixed partials can differ.

In plain words For well behaved functions it does not matter whether you differentiate in xx first or in yy first. The continuity hypothesis is not decoration, it is what makes the result true.

Example For f(x,y)=x2y3f(x, y) = x^2 y^3 both orders give 6xy26xy^2. Now take f(x,y)=xy(x2−y2)x2+y2f(x, y) = \frac{xy(x^2 - y^2)}{x^2 + y^2} for (x,y)≠(0,0)(x, y) \ne (0, 0) and f(0,0)=0f(0, 0) = 0. A direct computation gives fx(0,y)=−yf_x(0, y) = -y and fy(x,0)=xf_y(x, 0) = x. Differentiating the first in yy gives −1-1 at the origin, and differentiating the second in xx gives 11. The two mixed partials disagree, and indeed they are not continuous at (0,0)(0, 0).

Hessian

Definition Let ff have all second partial derivatives at a point aa of an open set U⊆RnU \subseteq \mathbb{R}^n. The Hessian matrix of ff at aa is the n×nn \times n matrix

Hf(a)=[fxixj(a)]i,j=1n.Hf(a) = \Big[ f_{x_i x_j}(a) \Big]_{i, j = 1}^{n}.

For two variables,

Hf(a)=[fxx(a)fxy(a)fyx(a)fyy(a)].Hf(a) = \begin{bmatrix} f_{xx}(a) & f_{xy}(a) \\ f_{yx}(a) & f_{yy}(a) \end{bmatrix}.

When ff is C2C^2 on UU, Clairaut’s theorem makes Hf(a)Hf(a) a symmetric matrix.

In plain words The Hessian collects all the second derivatives in one table. It plays the role that f′′f'' plays in one variable.

Example For f(x,y)=xeyf(x, y) = x e^y the second partials are fxx=0f_{xx} = 0, fxy=fyx=eyf_{xy} = f_{yx} = e^y and fyy=xeyf_{yy} = x e^y. At (1,0)(1, 0)

Hf(1,0)=[0111].Hf(1, 0) = \begin{bmatrix} 0 & 1 \\ 1 & 1 \end{bmatrix}.

Quadratic forms

Definition A quadratic form on Rn\mathbb{R}^n is a function Q(h)=hTAhQ(h) = h^{T} A h, where AA is a symmetric n×nn \times n matrix and hh is a column vector. In coordinates Q(h)=∑i,jaijhihjQ(h) = \sum_{i, j} a_{ij} h_i h_j. For n=2n = 2 and

A=[abbc]A = \begin{bmatrix} a & b \\ b & c \end{bmatrix}

the two off diagonal entries contribute equally, and

Q(h)=ah12+2bh1h2+ch22.Q(h) = a h_1^2 + 2b h_1 h_2 + c h_2^2.

In plain words A quadratic form is a polynomial in which every term has degree exactly two. The factor 22 in front of the mixed term comes from the two equal entries bb above and below the diagonal.

Example Take

A=[2113].A = \begin{bmatrix} 2 & 1 \\ 1 & 3 \end{bmatrix}.

The four entries give 2h12+h1h2+h2h1+3h222h_1^2 + h_1 h_2 + h_2 h_1 + 3h_2^2, which combines to 2h12+2h1h2+3h222h_1^2 + 2h_1 h_2 + 3h_2^2. At h=⟨1,−1⟩h = \langle 1, -1 \rangle the value is 2−2+3=32 - 2 + 3 = 3.

Second-order Taylor polynomial

Definition Let ff be C2C^2 on an open set containing aa, and write h=x−ah = x - a. The second-order Taylor polynomial of ff centered at aa is

T2(x)=f(a)+∇f(a)⋅h+12 hTHf(a) h.\begin{aligned} T_2(x) &= f(a) + \nabla f(a) \cdot h \\ &\quad + \tfrac{1}{2} \, h^{T} Hf(a) \, h. \end{aligned}

For two variables with a=(x0,y0)a = (x_0, y_0), h1=x−x0h_1 = x - x_0 and h2=y−y0h_2 = y - y_0, the quadratic part is

12(fxxh12+2fxyh1h2+fyyh22),\tfrac{1}{2} \big( f_{xx} h_1^2 + 2 f_{xy} h_1 h_2 + f_{yy} h_2^2 \big),

with all derivatives taken at aa. It is the only polynomial of degree at most 22 whose value and first and second partial derivatives at aa agree with those of ff.

In plain words Start with the height at the center, add the tangent plane, then add a quadratic correction that bends the model the way the surface bends. Always write the powers of x−x0x - x_0 and y−y0y - y_0, never of xx and yy, unless the center is the origin.

Example Take f(x,y)=xeyf(x, y) = x e^y centered at (1,0)(1, 0). Here f(1,0)=1f(1, 0) = 1, ∇f(1,0)=⟨1,1⟩\nabla f(1, 0) = \langle 1, 1 \rangle and the Hessian is the one above, so

T2=1+(x−1)+y+(x−1)y+12y2.\begin{aligned} T_2 &= 1 + (x - 1) + y \\ &\quad + (x - 1) y + \tfrac{1}{2} y^2. \end{aligned}

At (1.1,0.1)(1.1, 0.1) the model gives 1+0.1+0.1+0.01+0.005=1.2151 + 0.1 + 0.1 + 0.01 + 0.005 = 1.215, while the true value is 1.1e0.1≈1.2156881.1 e^{0.1} \approx 1.215688.

Multi-index notation

Definition A multi-index is an nn-tuple α=(α1,…,αn)\alpha = (\alpha_1, \dots, \alpha_n) of nonnegative integers. Its order is ∣α∣=α1+⋯+αn\lvert \alpha \rvert = \alpha_1 + \dots + \alpha_n, and for hh in Rn\mathbb{R}^n

α!=α1!⋯αn!,hα=h1α1⋯hnαn.\begin{gathered} \alpha! = \alpha_1! \cdots \alpha_n!, \\ h^{\alpha} = h_1^{\alpha_1} \cdots h_n^{\alpha_n}. \end{gathered}

The partial derivative DαfD^{\alpha} f differentiates αi\alpha_i times in xix_i for each ii. If ff is CkC^k on an open set containing aa, the Taylor polynomial of order kk centered at aa is

Tk(a+h)=∑∣α∣≤kDαf(a)α! hα.T_k(a + h) = \sum_{\lvert \alpha \rvert \le k} \frac{D^{\alpha} f(a)}{\alpha!} \, h^{\alpha}.

In plain words A multi-index records how many times you differentiate in each variable. Each mixed derivative appears once in the sum, and dividing by α!\alpha! accounts for all the orders in which the same derivatives could be taken.

Example Find the cubic model of f(x,y)=exsin⁡yf(x, y) = e^x \sin y at the origin. The nonzero coefficients come from α=(0,1)\alpha = (0, 1), (1,1)(1, 1), (2,1)(2, 1) and (0,3)(0, 3), with derivatives 1,1,1,−11, 1, 1, -1 at the origin, so

T3=y+xy+x2y2−y36.T_3 = y + xy + \frac{x^2 y}{2} - \frac{y^3}{6}.

For α=(2,1)\alpha = (2, 1) we have α!=2! 1!=2\alpha! = 2! \, 1! = 2, which gives the 12\frac{1}{2}. The same answer comes from multiplying 1+x+x221 + x + \frac{x^2}{2} by y−y36y - \frac{y^3}{6} and keeping terms of degree at most 33. For k=2k = 2 the formula agrees with the Hessian version, because α=(1,1)\alpha = (1, 1) has α!=1\alpha! = 1 and so carries the full mixed term fxyh1h2f_{xy} h_1 h_2.

Remainder

Definition Let ff be Ck+1C^{k + 1} on an open set containing the segment from aa to a+ha + h. Then there is a number θ\theta with 0<θ<10 < \theta < 1 such that f(a+h)=Tk(a+h)+Rk(h)f(a + h) = T_k(a + h) + R_k(h), where

Rk(h)=∑∣α∣=k+1Dαf(a+θh)α! hα.R_k(h) = \sum_{\lvert \alpha \rvert = k + 1} \frac{D^{\alpha} f(a + \theta h)}{\alpha!} \, h^{\alpha}.

This is Taylor’s theorem with the Lagrange form of the remainder. For k=1k = 1 it reads R1(h)=12 hTHf(a+θh) hR_1(h) = \tfrac{1}{2} \, h^{T} Hf(a + \theta h) \, h.

In plain words The error looks like the next term of the series, except that the derivatives are evaluated at some unknown point on the segment instead of at the center.

Example For f(x,y)=ex+yf(x, y) = e^{x + y} at the origin, T1=1+x+yT_1 = 1 + x + y. Every second partial is ex+ye^{x + y}, so

R1(h)=12eθ(h1+h2)(h1+h2)2.R_1(h) = \tfrac{1}{2} e^{\theta (h_1 + h_2)} (h_1 + h_2)^2.

At h=⟨0.1,0.1⟩h = \langle 0.1, 0.1 \rangle the actual error is e0.2−1.2≈0.021403e^{0.2} - 1.2 \approx 0.021403. The formula gives 0.02 e0.2θ0.02 \, e^{0.2 \theta}, which matches for θ≈0.339\theta \approx 0.339, a number strictly between 00 and 11 as promised.

Approximation error

Definition There are two kinds of error statements. The asymptotic one says that if ff is CkC^k on an open set containing aa, then

lim⁡h→0f(a+h)−Tk(a+h)∥h∥k=0.\lim_{h \to 0} \frac{f(a + h) - T_k(a + h)}{\lVert h \rVert^k} = 0.

It describes how fast the error shrinks but gives no number for a particular hh. The quantitative one follows from the remainder. Assume ff is Ck+1C^{k + 1} on an open set containing the segment from aa to a+ha + h. If ∣Dαf∣≤M\lvert D^{\alpha} f \rvert \le M at every point of the segment for every α\alpha with ∣α∣=k+1\lvert \alpha \rvert = k + 1, then

∣Rk(h)∣≤M(k+1)!⋅(∣h1∣+⋯+∣hn∣)k+1.\begin{aligned} \lvert R_k(h) \rvert &\le \frac{M}{(k + 1)!} \\[0.4em] &\quad \cdot \big( \lvert h_1 \rvert + \dots + \lvert h_n \rvert \big)^{k + 1}. \end{aligned}

In plain words The first statement says the model gets very good very fast as you approach the center. The second gives an actual guaranteed error, once you bound the next derivatives along the segment you use.

Example For f(x,y)=xeyf(x, y) = x e^y and its quadratic model at (1,0)(1, 0), the third partials are 00, 00, eye^y and xeyx e^y. On the segment to (1.1,0.1)(1.1, 0.1) we have x≤1.1x \le 1.1 and y≤0.1y \le 0.1, so all of them are at most M=1.22M = 1.22. With h=⟨0.1,0.1⟩h = \langle 0.1, 0.1 \rangle,

∣R2∣≤1.226(0.2)3≈0.00163.\lvert R_2 \rvert \le \frac{1.22}{6} (0.2)^3 \approx 0.00163.

The actual error found earlier is about 0.0006880.000688, safely inside the bound.

Check yourself

  1. Find the second-order Taylor polynomial of f(x,y)=ln⁡(1+x+2y)f(x, y) = \ln(1 + x + 2y) centered at the origin.
Show the answer

At the origin f=0f = 0 and ∇f=⟨1,2⟩\nabla f = \langle 1, 2 \rangle. Every second partial is −1(1+x+2y)2-\frac{1}{(1 + x + 2y)^2} times 11, 22 or 44, so the Hessian at the origin is

[−1−2−2−4].\begin{bmatrix} -1 & -2 \\ -2 & -4 \end{bmatrix}.

Therefore

T2=x+2y−12(x+2y)2.T_2 = x + 2y - \tfrac{1}{2} (x + 2y)^2.
  1. Write hTAhh^{T} A h as a polynomial and evaluate it at h=⟨2,1⟩h = \langle 2, 1 \rangle, where
A=[122−3].A = \begin{bmatrix} 1 & 2 \\ 2 & -3 \end{bmatrix}.
Show the answer

The form is h12+4h1h2−3h22h_1^2 + 4h_1 h_2 - 3h_2^2, with the 44 coming from the two entries equal to 22. At ⟨2,1⟩\langle 2, 1 \rangle it equals 4+8−3=94 + 8 - 3 = 9.

  1. Use the remainder to show that the linear model x+2yx + 2y of f(x,y)=sin⁡(x+2y)f(x, y) = \sin(x + 2y) at the origin is off by at most 0.0450.045 at (0.1,0.1)(0.1, 0.1).
Show the answer

The function is C2C^2 on R2\mathbb{R}^2, and its second partials are −sin⁡(x+2y)-\sin(x + 2y) times 11, 22 and 44. The remainder formula with k=1k = 1 gives, for some number cc between 00 and 0.30.3,

R1=−12sin⁡(c) (h1+2h2)2.R_1 = -\tfrac{1}{2} \sin(c) \, (h_1 + 2h_2)^2.

Since ∣sin⁡c∣≤1\lvert \sin c \rvert \le 1, the error is at most 12(0.3)2=0.045\frac{1}{2} (0.3)^2 = 0.045. The actual error is 0.3−sin⁡0.3≈0.00450.3 - \sin 0.3 \approx 0.0045.

How this lesson connects

It also uses Differentiability and gradients, Second partial derivatives and One-variable Taylor theorem.