Unit 10 · Topic 10.12 · BC

Lagrange remainder

Builds on Taylor polynomials and the Mean Value Theorem. 13 minutes.

  1. Example 1Choose the derivative order for the remainder
  2. Example 2Find a valid derivative bound
  3. Example 3Calculate a Lagrange error bound
  4. Example 4Use the bound to support an approximation

The Taylor polynomial \(\cy{P_n}\) of degree \(n\) with center \(a\) has the same value and first \(n\) derivatives at \(a\) as the function \(f\). At another input \(x\), the two differ by the remainder

\[\cr{R_n(x)}=f(x)-\cy{P_n(x)}\]

which topic 10.11 also called the error of the approximation \(f(x)\approx P_n(x)\). The value \(f(x)\) is usually the unknown that \(P_n(x)\) approximates, so the remainder cannot be computed. This topic bounds its size with one derivative of \(f\), and uses the bound to decide whether an approximation is accurate enough.

The remainder looks like the next term

The chalk curve e to the x for x from minus 1 to 1, with an orange dot at the center (0, 1) and an orange Taylor polynomial of degree 1, 2 or 3 that touches the curve there. At an input x that can be dragged, a chalk dot sits on the curve, an orange dot sits on the polynomial, and a red segment joins them. A lower graph shows the size of the remainder as a solid red curve, 0 at the center and rising on both sides, and the bound with M equal to e as a dashed red curve above it. A button lowers M to 1, and then the dashed curve falls below the solid curve to the right of 0 but stays above it to the left.

Figure 1The chalk curve is \(e^x\), and the orange curve is its Taylor polynomial \(\cy{P_n}\) with center 0, at the orange dot. Faint dashed lines mark the center and the input \(x\), where a red segment of length \(|R_n(x)|\) joins the two curves. The lower graph plots \(|R_n(x)|\) as a solid red curve and its bound as a dashed red curve.

In Figure 1, \(f(x)=e^x\), the center is 0, and the first slider sets the degree \(n\). The red segment at \(x\) is short near the center and grows away from it.

To find the size of \(R_n(x)\), suppose that \(f\) has derivatives through order \(n+1\) on an interval that contains \(a\) and \(x\). At \(x=a\) the remainder is 0, so take \(x\ne a\). Let \(K\) be the number for which \(R_n(x)=K(x-a)^{n+1}\), and let

\[g(t)=f(t)-P_n(t)-K(t-a)^{n+1}\]

Then \(g(x)=0\), by the choice of \(K\). The function \((t-a)^{n+1}\) and its first \(n\) derivatives all keep a factor \(t-a\), so they are 0 at \(t=a\). Because \(P_n\) matches \(f\) and its first \(n\) derivatives at \(a\), the function \(g\) and its first \(n\) derivatives are 0 at \(a\) too.

By Rolle's Theorem (topic 5.1), a differentiable function with equal values at two points has derivative 0 somewhere between them. Because \(g(a)=g(x)=0\), the derivative \(g'\) is 0 at some \(c_1\) between \(a\) and \(x\). Then \(g'(a)=g'(c_1)=0\), so \(g''\) is 0 at some \(c_2\) between \(a\) and \(c_1\). The derivatives of \(g\) up to order \(n\) are 0 at \(a\), so the same step works \(n+1\) times in all. The last step gives a point \(z\) between \(a\) and \(x\) where \(g^{(n+1)}(z)=0\). Each step applies because \(g\), like \(f\), has derivatives through order \(n+1\).

Every term of \(P_n\) has degree at most \(n\), so its derivative of order \(n+1\) is 0, while that of \((t-a)^{n+1}\) is the constant \((n+1)!\):

\[g^{(n+1)}(t)=f^{(n+1)}(t)-(n+1)!\,K\]

At \(t=z\) this is 0, so \(K=\frac{f^{(n+1)}(z)}{(n+1)!}\). The remainder is therefore \(\frac{f^{(n+1)}(z)}{(n+1)!}(x-a)^{n+1}\), which is the next term of the Taylor polynomial with the derivative taken at \(z\) instead of at \(a\). This result is Taylor's theorem with the Lagrange form of the remainder. The derivative has order \(n+1\), one above the degree, because \(P_n\) already matches every lower derivative at \(a\).

The point \(z\) depends on \(x\), and its position is unknown. If \(|f^{(n+1)}(t)|\le\cy{M}\) for every \(t\) between \(a\) and \(x\), then \(|f^{(n+1)}(z)|\le M\) wherever \(z\) lies, so \(|R_n(x)|\le\frac{M}{(n+1)!}|x-a|^{n+1}\). This is the Lagrange error bound, which some books call Taylor's inequality.

In the lower graph of Figure 1, the solid red curve is \(|R_n(x)|\), and the dashed red curve is the bound with \(M=e\). Every derivative of \(e^t\) is \(e^t\), which is at most \(e\) for \(-1\le t\le1\). This \(M\) therefore holds for every \(x\) in the graph, and the dashed curve stays above the solid one.

The bound needs \(M\) on the whole interval between \(a\) and \(x\). Set the degree to 1. Then use the button under Figure 1 to take \(M=1\), the value of \(f^{(n+1)}\) at the center. Right of 0, the dashed curve falls below the solid one, because the Lagrange form gives \(R_n(x)=e^z\frac{x^{n+1}}{(n+1)!}\) with \(0<z<x\), so \(e^z>1\). Left of 0, \(e^t\le1\) between \(x\) and 0, so \(M=1\) is valid there and the dashed curve stays above.

With \(M\) taken at the center, the bound is the size of the first term that \(P_n\) leaves out. That size bounds the error only in special cases, such as the alternating series of topic 10.10.

Raise the degree. The dashed curve moves down, because \((n+1)!\) grows while \(|x|^{n+1}\) does not grow for \(|x|\le1\). The solid curve moves down too, and both stay near 0 over a wider interval around the center.

A bound for the next derivative

Because \(z\) can be any point between \(a\) and \(x\), \(M\) must be at least \(|f^{(n+1)}(t)|\) for every \(t\) there. If \(f^{(n+1)}\) is continuous on the closed interval between \(a\) and \(x\), the Extreme Value Theorem gives \(|f^{(n+1)}|\) a largest value there. That value is the smallest valid \(M\), and it gives the smallest bound. If \(|f^{(n+1)}|\) increases or decreases on the interval, the value is at an end, which can be \(a\) or \(x\). Otherwise it is at an end or at a critical point inside. Every derivative of \(\sin x\) or \(\cos x\) is \(\pm\sin x\) or \(\pm\cos x\), so \(M=1\) works on any interval.

A chalk curve for the size of a derivative, with no numbers. From the center a at the left end it falls, rises to a peak and falls again. A faint band runs from a to an input x that can be dragged, and an orange horizontal line at height M touches the curve at its highest point on the band. One button moves the line down to the height of the curve at x, marked by a dot, and the curve turns red where it rises above the line inside the band. Another button moves the line to the largest value on the band.

Figure 2The chalk curve is \(|f^{(n+1)}(t)|\) for some function \(f\), and the faint band covers the interval from the center \(a\) to the input \(x\). The orange line is at the height \(\cy{M}\), and a chalk dot can mark the curve at \(x\). Inside the band, the curve turns red where it rises above the line, and red shading fills the gap between them.

Figure 2 starts with \(M\) at the largest value on the band, where the orange line touches the curve. The first button sets \(M\) to the height at \(x\) alone. The curve then turns red where it rises above the line, so this \(M\) is too small. Drag \(x\) to another place. Then use the second button to find the largest value on the new band. It is at \(a\) for short bands, at \(x\) for longer ones, and inside once \(x\) passes the top of the curve.

Any number above a valid \(M\) is also valid, so you may round \(M\) up but never down. For example, \(e^{0.5}<2\), so \(M=2\) can replace \(M=e^{0.5}\).

Meeting a tolerance

A tolerance is the largest error that a problem allows. If the bound is at most the tolerance, the error is too, so the approximation is guaranteed. If the bound is larger, it decides nothing, because the error itself may be smaller. To choose a degree, compute the bound for \(n=1,2,3,\ldots\), with the \(M\) of each order. The first \(n\) whose bound meets the tolerance is the least degree that the bound guarantees. A guarantee at one input does not carry over to a farther one, where \(|x-a|\) and possibly \(M\) are larger.

Example 1

Choose the derivative order for the remainder

The function \(f\) has derivatives of all orders, and for \(0\le x\le1\) it satisfies \(|f''(x)|\le7\), \(|f'''(x)|\le10\) and \(|f^{(4)}(x)|\le12\). Let \(P_2\) be the second-degree Taylor polynomial for \(f\) about \(x=0\). Find the smallest upper bound for \(|f(0.5)-P_2(0.5)|\) that the Lagrange error bound gives.

Solution

The function has derivatives of all orders, so the Lagrange error bound applies. The polynomial has degree 2, so its remainder uses the derivative of order 3, the first one that \(P_2\) is not built to match. The other two bounds are for \(P_1\) and \(P_3\), so they play no part here.

Every \(t\) between 0 and 0.5 lies in \([0,1]\), so \(|f'''(t)|\le10\) there, and \(\cy{M}=10\). The distance from the center is 0.5, and the power and the factorial use \(n+1=3\):

\[\begin{aligned}&|f(0.5)-P_2(0.5)|\\&\le\frac{10}{3!}\,(0.5)^3=\frac{10}{48}=\frac{5}{24}\end{aligned}\]

Example 2

Find a valid derivative bound

Let \(P_3\) be the third-degree Taylor polynomial for \(f(x)=\ln(1+x)\) about \(x=0\). Use the Lagrange error bound to find an upper bound for \(|f(-0.2)-P_3(-0.2)|\).

Solution

The function \(\ln(1+t)\) has derivatives of every order for \(t>-1\), which includes the interval from \(-0.2\) to 0. The remainder of \(P_3\) uses the fourth derivative, and differentiating four times gives

\[f^{(4)}(t)=-\frac{6}{(1+t)^4}\]

On the interval, \(1+t\) is positive and increases, so the size \(|f^{(4)}(t)|\) decreases, and its largest value is at the left end, \(t=-0.2\). With \(\cy{M}=\frac{6}{(0.8)^4}\), the distance 0.2 and \(n+1=4\),

\[\begin{aligned}&|f(-0.2)-P_3(-0.2)|\\&\le\frac{6}{(0.8)^4}\cdot\frac{(0.2)^4}{4!}\\&=\frac{6}{4!}\left(\frac{0.2}{0.8}\right)^4=\frac{1}{1024}\end{aligned}\]

Example 3

Calculate a Lagrange error bound

The second-degree Taylor polynomial for \(f(x)=\sqrt{x}\) about \(x=4\) is \(P_2(x)=2+\frac{x-4}{4}-\frac{(x-4)^2}{64}\). Use the Lagrange error bound to find an upper bound for \(|f(4.4)-P_2(4.4)|\).

Solution

The function \(\sqrt{t}\) has derivatives of every order for \(t>0\). The remainder of \(P_2\) uses the third derivative:

\[f'''(t)=\frac{3}{8}\,t^{-5/2}\]

It is positive and decreases as \(t\) increases, so on the interval from 4 to 4.4 its largest value is at \(t=4\), which gives \(\cy{M}=\frac38\cdot\frac1{32}=\frac{3}{256}\). The center is 4, so the distance is \(4.4-4=0.4\), and the power and the factorial both use \(n+1=3\):

\[\begin{aligned}&|f(4.4)-P_2(4.4)|\\&\le\frac{3}{256}\cdot\frac{(0.4)^3}{3!}=\frac{1}{8000}\end{aligned}\]

As a check, \(P_2(4.4)=2.0975\) and \(\sqrt{4.4}\approx2.097618\), so the error is about 0.000118, which is below the bound.

Example 4

Use the bound to support an approximation

Let \(P_n\) be the Taylor polynomial of degree \(n\) for \(\sin x\) about \(x=0\). Find the least \(n\) for which the Lagrange error bound guarantees \(|\sin0.5-P_n(0.5)|<10^{-4}\).

Solution

The function \(\sin x\) has derivatives of every order, each \(\pm\sin x\) or \(\pm\cos x\), so \(\cy{M}=1\) is valid for every order on every interval. The distance is 0.5, so the bound for degree \(n\) is

\[\frac{(0.5)^{n+1}}{(n+1)!}=\frac{1}{2^{n+1}\,(n+1)!}\]

The bound decreases as \(n\) grows, because its denominator increases. For \(n=4\) it is \(\frac{1}{3840}\), which is larger than \(10^{-4}=\frac{1}{10000}\), so no degree up to 4 has a guarantee. For \(n=5\) it is \(\frac{1}{46080}\), which is smaller than \(\frac{1}{10000}\). The least degree is \(n=5\).

Each example is one of the four skills of topic 10.12 in Which & Why: AP Calculus.