Taylor Series

Polynomials that hug a function more and more tightly, the hidden reason a series stops converging, and Euler’s formula built term by term

Taylor Series

A calculator cannot know what sin(0.3) is. It knows how to add and multiply, so it uses a polynomial that agrees with the sine function so closely that the difference never reaches the screen. Taylor polynomials are those stand-ins: built from the derivatives of a function at a single point, they hug it more and more tightly as terms are added, until, for many functions, the infinite series simply is the function.

Building a Taylor Polynomial

Type a function or pick one, then press Add terms and watch the polynomial wrap itself around it. Drag the centre a and the probe x; the strip underneath shows the error on a log scale.

P₃(x) = x − 1/6·x³
−6.66667
P₃(x) at x = 4
−0.756802
f(x)
5.91
error |f(x) − Pₙ(x)|
10.7
Lagrange bound max|f⁽ⁿ⁺¹⁾|·|x − a|ⁿ⁺¹/(n + 1)!
At x = 4, P₃ is off by 5.91. Drag a and x, or press Add terms to watch the polynomial wrap itself around f.

Drag the diamond to move the centre a and anywhere else to move the probe x. Coefficients of order 0 to 30 are exact symbolic derivatives f⁽ᵏ⁾(a)/k!. All 31 coefficients came from symbolic derivatives. The Lagrange bound samples f⁽ⁿ⁺¹⁾ at 41 points between a and x, so it is a close estimate of the bound, not a certified one.

Go deeper:Matching Derivatives, One at a Time

The tangent line matches f and its slope at a. Asking for more, a polynomial that matches f and its first n derivatives at a, gives exactly one answer:

Pₙ(x) = f(a) + f′(a)(x − a) + f″(a)(x − a)²/2! + … + f⁽ⁿ⁾(a)(x − a)ⁿ/n!

The factorials appear because differentiating (x − a)ᵏ k times leaves k!, so dividing by k! makes the k-th derivative of Pₙ at a come out to exactly f⁽ᵏ⁾(a). About a = 0 this gives the familiar series: eˣ = 1 + x + x²/2! + …, sin x = x − x³/3! + x⁵/5! − …, ln(1 + x) = x − x²/2 + x³/3 − ….

How good is Pₙ? Taylor’s theorem with Lagrange’s remainder says that for some ξ between a and x,

f(x) − Pₙ(x) = f⁽ⁿ⁺¹⁾(ξ)(x − a)ⁿ⁺¹/(n + 1)!,

so the error is at most max|f⁽ⁿ⁺¹⁾|·|x − a|ⁿ⁺¹/(n + 1)!. For sin x every derivative is bounded by 1, and the factorial wins for every x: the series converges to sin x on the whole line. The bound also explains the V-shaped valley in the error strip: near a, |x − a|ⁿ⁺¹ is tiny.

Smoothness alone is not enough. The function e^(−1/x²) (with value 0 at 0) has derivatives of every order, and each one is a polynomial in 1/x times e^(−1/x²), which tends to 0 as x → 0. So every Taylor coefficient at 0 is 0 and the series is identically 0, yet the function is positive everywhere else. Cauchy pointed out this example in the 1820s. Functions that do equal their Taylor series near every point are called analytic; most formulas built from the usual functions are, away from points where they break down.

Brook Taylor published the general series in 1715, and Colin Maclaurin used the case a = 0 so heavily in his 1742 Treatise of Fluxions that it carries his name. Long before either, Madhava of Sangamagrama and the Kerala school in India had found the series for sine, cosine and arctangent, around 1400.

The Hidden Reason a Series Stops

The series for 1/(1 + x²) diverges beyond |x| = 1, though the function is perfectly smooth there. Drag the centre along the real axis and watch the disc of convergence grow until it touches a pole off the line.

1.000
radius R = √(a² + 1)
1.000
from the coefficients: |c60|^(−1/60)
(−1.00, 1.00)
interval of convergence
8
terms in the partial sum
About a = 0.00 the nearest trouble is the pole at i, at distance R = √(a² + 1) = 1.000. So the series converges on (−1.00, 1.00) and diverges beyond, though 1/(1 + x²) is perfectly smooth on the whole real line.

Drag on either picture to move the centre a along the real axis. In the plane, hue shows the argument of the value and the soft rings mark each doubling of its size; poles glow white, zeros go dark. Coloured by the partial sum, the plane matches f inside the disc and turns to bands of wild colour outside it. The estimate |c₆₀|^(−1/60) is the root test applied to the 60th coefficient; for eˣ it grows without bound as the degree does.

Go deeper:The Radius Lives in the Complex Plane

A power series ∑ cₖ(x − a)ᵏ always converges on an interval centred at a, |x − a| < R, and diverges for |x − a| > R. The radius R is fixed by how fast the coefficients grow (Cauchy, and later Hadamard):

1/R = lim sup |cₖ|^(1/k).

The interval is really a disc. The same series makes sense for complex z, and it converges on the disc |z − a| < R and diverges outside it. For a function given by a formula, the series about a converges in the largest disc that avoids every point where the function breaks down. So R is the distance from a to the nearest singularity, real or not.

For 1/(1 + x²) the trouble is at z = ±i, where 1 + z² = 0. About a = 0 the series is the geometric series 1 − x² + x⁴ − x⁶ + …, with ratio −x², so it stops at |x| = 1. About a the distance to ±i is √(a² + 1), and that is the radius. The function is smooth on the real line; the real line just cannot see the poles. The same poles are behind Runge’s phenomenon (Carl Runge, 1901): polynomials fitted to 1/(1 + 25x²) at equally spaced points swing wildly near the ends.

At the boundary anything can happen. ln(1 + x) has R = 1 about 0; at x = 1 its series becomes 1 − 1/2 + 1/3 − …, which converges to ln 2, while at x = −1 it is the negative harmonic series, which diverges. eˣ, sin x and cos x have no singularities at all, so their series converge everywhere.

Euler’s Formula, Term by Term

Put iθ into the series for eˣ. Each term is the last one turned a quarter turn, and the arrows spiral in on a point of the unit circle. Try θ = π.

0.124 − 2.026i
S₄, the sum of 5 terms
−1.000 + 0.000i
e^(iθ) = cos θ + i sin θ
2.316967
distance |Sₙ − e^(iθ)|
2.550164
next term |θ|ⁿ⁺¹/(n + 1)!
The terms are still growing: the next has length θ^5/5! = 2.550. Once k passes θ they shrink, and the spiral starts to close.

Multiplying by i turns a complex number a quarter turn anticlockwise, so iθ·(previous term)/k is the previous arrow rotated 90° and scaled by θ/k. For large θ the early terms grow before they shrink (the biggest is near k = θ), which is why the spiral for θ = 2π swings far out before it comes home.

Go deeper:Why e^(iθ) Lands on the Circle

The exponential series converges for every complex number, so e^(iθ) = ∑ (iθ)ᵏ/k! makes sense. The powers of i cycle: i⁰ = 1, i¹ = i, i² = −1, i³ = −i, i⁴ = 1. Gather the real terms and the imaginary terms (allowed because the series converges absolutely):

e^(iθ) = (1 − θ²/2! + θ⁴/4! − …) + i(θ − θ³/3! + θ⁵/5! − …) = cos θ + i sin θ.

The two brackets are exactly the Taylor series of cosine and sine, which is what the right-hand plots show converging. With θ = π the formula gives e^(iπ) = −1, the relation e^(iπ) + 1 = 0 that links the five constants 0, 1, π, e and i.

There is a calculus reason too. z(θ) = e^(iθ) satisfies z′ = iz: the velocity is the position turned 90°, and its length is |z|. Starting from z(0) = 1 the point therefore moves at unit speed at right angles to its radius, which is to say round the unit circle, and after time θ it has gone an arc of length θ.

Roger Cotes found an equivalent statement, in logarithmic form, in 1714. Leonhard Euler wrote it down as e^(ix) = cos x + i sin x and made it central to analysis in his Introductio in analysin infinitorum of 1748.

Key Takeaways

  • The Taylor polynomial Pₙ matches f and its first n derivatives at a; its coefficients are f⁽ᵏ⁾(a)/k!.
  • The error is governed by the next derivative: |f − Pₙ| ≤ max|f⁽ⁿ⁺¹⁾|·|x − a|ⁿ⁺¹/(n + 1)!.
  • A series converges out to the nearest complex singularity, which explains limits that are invisible on the real line.
  • Feeding iθ into the series for eˣ splits it into the cosine and sine series: e^(iθ) = cos θ + i sin θ.

Spot a mistake or have an idea?

Search