Calculus · Grade 12 and undergraduate

Taylor Polynomials and the Lagrange Error Bound

Quick answer

The Taylor polynomial of degree n for f at a is the polynomial that matches f and its first n derivatives at a: Pₙ(x) is the sum of f⁽ᵏ⁾(a)/k! times (x − a)ᵏ for k from 0 to n. The degree-1 polynomial is the tangent line; higher degrees bend to follow the curve farther from a. The Lagrange error bound says |f(x) − Pₙ(x)| ≤ M|x − a|ⁿ⁺¹/(n + 1)!, where M bounds the size of the next derivative between a and x.

What you'll learn

  • Build the Taylor polynomial of a given degree from derivatives
  • Use Taylor polynomials to approximate function values
  • Read derivatives from the coefficients of a Taylor polynomial
  • Bound the error with the Lagrange error bound

Matching more than the slope

The tangent line matches a function’s value and slope at one point, and it is a good approximation nearby. A parabola can match the curvature too, and a cubic the rate at which curvature changes. The Taylor polynomial of degree nn for ff at aa matches ff and its first nn derivatives there:

Pn(x)=f(a)+f′(a)(x−a)+f′′(a)2!(x−a)2+⋯+f(n)(a)n!(x−a)nP_n(x) = f(a) + f'(a)(x - a) + \frac{f''(a)}{2!}(x - a)^2 + \cdots + \frac{f^{(n)}(a)}{n!}(x - a)^n

Centered at a=0a = 0, it is called a Maclaurin polynomial.

Why the coefficients have factorials

Differentiate (x−a)k(x - a)^k kk times and you get k!k!, a constant; differentiate it fewer times and it still vanishes at x=ax = a. So the kkth derivative of PnP_n at aa comes only from the term ck(x−a)kc_k(x - a)^k, and equals ck⋅k!c_k \cdot k!. To make it equal f(k)(a)f^{(k)}(a), choose ck=f(k)(a)k!c_k = \tfrac{f^{(k)}(a)}{k!}. Each coefficient is chosen so that one more derivative matches, and the factorial undoes what differentiation does to the power.

sin x and its Taylor polynomials at 0 The sine curve with three polynomials centered at 0. The line P₁ = x follows sine only near the origin. The cubic P₃ = x − x³/6 hugs it out to about x = ±1.5. The fifth-degree P₅ = x − x³/6 + x⁵/120 stays close to about x = ±2.5 before peeling away. -4-224-2-112xy
  • y = sin x
  • P₁
  • P₃
  • P₅
sin x and its Taylor polynomials at 0

The Lagrange error bound

How good is the approximation? The error depends on the next derivative, the first one the polynomial does not match.

Lagrange error bound

If ∣f(n+1)(t)∣≤M\lvert f^{(n+1)}(t) \rvert \le M for every tt between aa and xx, then

∣f(x)−Pn(x)∣≤M(n+1)!∣x−a∣n+1\lvert f(x) - P_n(x) \rvert \le \frac{M}{(n + 1)!}\lvert x - a \rvert^{n+1}

It looks like the next term of the polynomial, with the unknown derivative replaced by its largest possible size. Close to aa, the power ∣x−a∣n+1\lvert x - a \rvert^{n+1} is tiny, and the factorial shrinks it further.

Worked examples

Common mistakes

Practice problems

  1. Find P2P_2 for cos⁡x\cos x at 00.

    Answer

    1−x221 - \tfrac{x^2}{2}

    Full solution

    cos⁡0=1\cos 0 = 1, −sin⁡0=0-\sin 0 = 0 and −cos⁡0=−1-\cos 0 = -1, so P2=1+0x−12x2P_2 = 1 + 0x - \tfrac{1}{2}x^2.

  2. Find P3P_3 for 11−x\tfrac{1}{1 - x} at 00.

    Answer

    1+x+x2+x31 + x + x^2 + x^3

    Full solution

    The kkth derivative is k!(1−x)k+1\tfrac{k!}{(1 - x)^{k+1}}, which is k!k! at 00, so every coefficient is k!k!=1\tfrac{k!}{k!} = 1.

  3. Find P2P_2 for x\sqrt{x} at 44, and estimate 4.2\sqrt{4.2}.

    Answer

    2+x−44−(x−4)2642 + \tfrac{x - 4}{4} - \tfrac{(x - 4)^2}{64}; about 2.0493752.049375

    Full solution

    f(4)=2f(4) = 2, f′(4)=124=14f'(4) = \tfrac{1}{2\sqrt{4}} = \tfrac{1}{4}, f′′(4)=−14⋅43/2=−132f''(4) = -\tfrac{1}{4 \cdot 4^{3/2}} = -\tfrac{1}{32}, and −1/322!=−164\tfrac{-1/32}{2!} = -\tfrac{1}{64}. At 4.24.2: 2+0.05−0.0006252 + 0.05 - 0.000625. The true value is 2.04939…2.04939\ldots

  4. The Taylor polynomial of ff at 11 is 2−3(x−1)+5(x−1)2−(x−1)32 - 3(x - 1) + 5(x - 1)^2 - (x - 1)^3. Find f′′(1)f''(1) and f′′′(1)f'''(1).

    Answer

    f′′(1)=10f''(1) = 10 and f′′′(1)=−6f'''(1) = -6

    Full solution

    The coefficient of (x−1)k(x - 1)^k is f(k)(1)k!\tfrac{f^{(k)}(1)}{k!}. So f′′(1)=2!⋅5f''(1) = 2! \cdot 5 and f′′′(1)=3!⋅(−1)f'''(1) = 3! \cdot (-1).

  5. Estimate e0.2e^{0.2} with P2P_2 at 00.

    Answer

    1.221.22

    Full solution

    1+0.2+0.042=1.221 + 0.2 + \tfrac{0.04}{2} = 1.22. The true value is 1.2214…1.2214\ldots

  6. Bound the error in problem 5.

    Answer

    Less than 0.0020.002

    Full solution

    The third derivative is et≤e0.2<1.3e^t \le e^{0.2} < 1.3 on [0,0.2][0, 0.2]. The bound is 1.33!(0.2)3=1.3⋅0.0086≈0.0017\tfrac{1.3}{3!}(0.2)^3 = \tfrac{1.3 \cdot 0.008}{6} \approx 0.0017.

  7. What degree nn of the Maclaurin polynomial of exe^x guarantees ee to within 0.0010.001, using e<3e < 3?

    Answer

    n=6n = 6

    Full solution

    The error at x=1x = 1 is at most 3(n+1)!\tfrac{3}{(n + 1)!}. 36!=3720≈0.004\tfrac{3}{6!} = \tfrac{3}{720} \approx 0.004 is too big, but 37!=35040≈0.0006\tfrac{3}{7!} = \tfrac{3}{5040} \approx 0.0006 works, so n+1=7n + 1 = 7.

  8. Find P4P_4 for ln⁡(1+x)\ln(1 + x) at 00.

    Answer

    x−x22+x33−x44x - \tfrac{x^2}{2} + \tfrac{x^3}{3} - \tfrac{x^4}{4}

    Full solution

    The derivatives at 00 are 11, −1-1, 22 and −6-6. Dividing by 1!1!, 2!2!, 3!3! and 4!4! gives 11, −12-\tfrac{1}{2}, 13\tfrac{1}{3} and −14-\tfrac{1}{4}.

  9. Find P3P_3 for sin⁡x\sin x at π2\tfrac{\pi}{2}.

    Answer

    1−12(x−π2)21 - \tfrac{1}{2}\left(x - \tfrac{\pi}{2}\right)^2

    Full solution

    At π2\tfrac{\pi}{2}: sin⁡=1\sin = 1, cos⁡=0\cos = 0, −sin⁡=−1-\sin = -1 and −cos⁡=0-\cos = 0. Only the constant and squared terms survive.

  10. A student writes the Maclaurin polynomial of degree 3 for exe^x as 1+x+x2+x31 + x + x^2 + x^3. What went wrong?

    Hint

    What is the second derivative of the student’s polynomial at 00?

    Answer

    The factorials are missing. The polynomial is 1+x+x22+x361 + x + \tfrac{x^2}{2} + \tfrac{x^3}{6}.

    Full solution

    The student’s polynomial has second derivative 22 at 00, but exe^x has second derivative 11 there. Dividing each coefficient by k!k! fixes every derivative: the correct cubic has f′′(0)=1f''(0) = 1 and f′′′(0)=1f'''(0) = 1.

Frequently asked questions

What is a Taylor polynomial?

The polynomial of degree n whose value and first n derivatives at x = a match those of f. Its coefficients are f⁽ᵏ⁾(a)/k!.

What is a Maclaurin polynomial?

A Taylor polynomial centered at a = 0.

Why is there a factorial in the coefficients?

Differentiating (x − a)ᵏ k times produces k!, so dividing by k! makes the kth derivative of the polynomial equal f⁽ᵏ⁾(a).

What is the Lagrange error bound?

|f(x) − Pₙ(x)| ≤ M|x − a|ⁿ⁺¹/(n + 1)!, where M is at least the largest value of |f⁽ⁿ⁺¹⁾| between a and x.

How do I get a better approximation?

Raise the degree, or approximate closer to the center. Both shrink |x − a|ⁿ⁺¹/(n + 1)!.

What to learn next