Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Nonlinear functions can be nasty, but polynomials are the “nicest” version. A series expansion is a systematic approach to turn a general nonlinear equation into a polynomial. Suppose we have some function f(x)f(x) that we want to approximate as:

f(x)=n=0cn(xx0)nf(x) = \sum_{n=0}^{\infty} c_n(x-x_0)^n

To determine the coefficients cnc_n, consider the values of f and its derivatives at x0x_0

f(x)=c0+c1(xx0)+c2(xx0)2+c3(xx0)3+f(x0)=c0f(x)=c1+2c2(xx0)+3c3(xx0)2+f(x0)=c1f(x)=2c2+6c3(xx0)+f(x0)=2c2f(x)=6c3(xx0)+f(x0)=6c3\begin{align} f(x) &= c_0 + c_1(x-x_0) + c_2(x-x_0)^2 + c_3(x-x_0)^3 + \cdots & f(x_0) &= c_0 \\ f'(x) &= c_1 + 2 c_2(x-x_0) + 3 c_3(x-x_0)^2 + \cdots & f'(x_0) &= c_1 \\ f''(x) &= 2 c_2 + 6 c_3(x-x_0) + \cdots & f''(x_0) &= 2 c_2 \\ f'''(x) &= 6 c_3(x-x_0) + \cdots & f''(x_0) &= 6 c_3 \end{align}

The pattern of matching derivatives gives rise to the Taylor series.

For example, let’s compute the Taylor series for f(x)=lnxf(x) = \ln x about x0=2x_0 = 2. It’s first two derivatives are:

f(x)=lnxf(2)=ln2f(x)=1xf(2)=12f(x)=1x2f(2)=14\begin{align} f(x) &= \ln x & f(2) &= \ln 2 \\ f'(x) &= \frac{1}{x} & f'(2) &= \frac{1}{2} \\ f''(x) &= -\frac{1}{x^2} & f''(2) &= -\frac{1}{4} \end{align}

Hence,

f(x)ln(2)+12(x2)1214(x2)2+f(x) \approx \ln(2) + \frac{1}{2}(x-2) - \frac{1}{2}\cdot\frac{1}{4} (x-2)^2 + \cdots

In general, we could determine the infinite series and general expressions for coefficients, but for practical purposes, we will usually stop at either first or second order polynomials since that is easier to work with.

For example, let’s find the two-term Taylor series for

f(x)=xe2x2f(x) = xe^{2 x^2}

about x=0x = 0. We will evaluate the required derivatives. This will be a series of product rule calculations.

The value of the function is f(0)=0f(0) = 0. The first derivative is:

f(x)=x(e2x24x)+e2x2=(4x2+1)e2x2\begin{align} f'(x) &= x(e^{2x^2}4x) + e^{2x^2} \\ &= (4x^2 + 1)e^{2x^2} \end{align}

so f(0)=1f'(0) = 1. The second derivative is:

f(x)=(4x2+1)(e2x24x)+8xe2x2=(16x3+12x)e2x2\begin{align} f''(x) &= (4x^2+1)(e^{2x^2}4x)+8xe^{2x^2} \\ &= (16x^3+12x)e^{2x^2} \end{align}

so f(0)=0f''(0) = 0. This means we need to keep going! The third derivative is:

f(x)=(16x3+12x)(e2x24x)+(48x2+12)e2x2=(64x4+96x2+12)e2x2\begin{align} f'''(x) &= (16x^3+12x)(e^{2x^2}4x)+(48x^2+12)e^{2x^2} \\ &= (64x^4+96x^2+12)e^{2x^2} \end{align}

so f(0)=12f'''(0) = 12.

Putting it all together,

f(x)0+1x+120x2+1612x3+=x+2x3+f(x) \approx 0 + 1 \cdot x + \frac{1}{2} \cdot 0 \cdot x^2 + \frac{1}{6} \cdot 12 \cdot x^3 + \cdots = x + 2x^3 + \cdots

Combining series

Some of these calculations can sometimes be avoided by combining series together. For example, the Taylor series for exe^x is well known

ex=n=0xnn!=1+x+x22+e^x = \sum_{n=0}^{\infty} \frac{x^n}{n!} = 1 + x + \frac{x^2}{2} + \cdots

The argument of e in f is 2x22x^2, which is also zero when x is zero, so we can substitute it in the known series to obtain

e2x21+2x2+(2x2)22+e^{2x^2} \approx 1 + 2x^2 + \frac{(2x^2)^2}{2} + \cdots

Finally, inserting this series into f and expanding

f(x)=xe2x2x(1+2x2+2x4+)=x+2x3+\begin{align} f(x) &= x e^{2x^2} \approx x (1 + 2x^2 + 2x^4 + \cdots) \\ &= x + 2x^3 + \cdots \end{align}

When doing this process, it can be helpful to keep track of dropped terms using OO-notation

ex=n=0xnn!=1+x+x22+O(x3)e2x2=1+2x2+2x4+O(x6)xe2x2=x+2x3+O(x5)\begin{align} e^x &= \sum_{n=0}^{\infty} \frac{x^n}{n!} = 1 + x + \frac{x^2}{2} + O(x^3) \\ e^{2x^2} &= 1 + 2x^2 + 2x^4 + O(x^6) \\ xe^{2x^2} &= x + 2x^3 + O(x^5) \end{align}

Skill builder problems

Expand the following to two terms:

Solution to Exercise 1

The function and its derivatives at x=0x=0 are:

f(x)=cos(x)f(0)=1f(x)=sin(x)f(0)=0f(x)=cos(x)f(0)=1\begin{align} f(x) &= \cos(x) & f(0) &= 1 \\ f'(x) &= -\sin(x) & f'(0) &= 0 \\ f''(x) &= -\cos(x) & f''(0) &= -1 \end{align}

So:

cosx1x22\cos x \approx 1-\frac{x^2}{2}
Solution to Exercise 2

The function and its derivatives at x=0x=0 are:

f(x)=sin(x)f(0)=0f(x)=cos(x)f(0)=1f(x)=sin(x)f(0)=0f(3)(x)=cos(x)f(3)(0)=1\begin{align} f(x) &= \sin(x) & f(0) &= 0\\ f'(x) &= \cos(x) & f'(0) &= 1 \\ f''(x) &= -\sin(x) & f''(0) &= 0 \\ f^{(3)}(x) &= -\cos(x) & f^{(3)}(0) &= -1 \end{align}

So:

sinxxx36\sin x \approx x-\frac{x^3}{6}
Solution to Exercise 3

The function and its derivatives at x=0x=0 are:

f(x)=exf(0)=1f(x)=exf(0)=1\begin{align} f(x)&=e^x & f(0) &= 1\\ f'(x)&=e^x & f'(0) &= 1 \end{align}

So:

ex1+xe^x \approx 1+x
Solution to Exercise 4

The function and its derivatives at x=0x=0 are:

f(x)=ln(1+x)f(0)=0f(x)=11+xf(0)=1f(x)=1(1+x)2f(0)=1\begin{align} f(x)&=\ln(1+x) & f(0) &= 0\\ f'(x)&=\frac{1}{1+x} & f'(0) &= 1\\ f''(x)&=-\frac{1}{(1+x)^2} & f''(0) &= -1 \end{align}

So:

ln(1+x)xx22\ln(1+x) \approx x-\frac{x^2}{2}
Solution to Exercise 5

The function and its derivatives at x=0x=0 are:

f(x)=11+xf(0)=1f(x)=1(1+x)2f(0)=1\begin{align} f(x)&=\frac{1}{1+x} & f(0) &= 1\\ f'(x)&=-\frac{1}{(1+x)^2} & f'(0) &= -1 \end{align}

So:

11+x1x\frac{1}{1+x} \approx 1-x
Solution to Exercise 6

Recall:

cosx1x22\cos x \approx 1-\frac{x^2}{2}

So:

cos(4x)1(4x)22=18x2\cos(4x) \approx 1-\frac{(4x)^2}{2} = 1-8x^2
Solution to Exercise 7

Recall:

cos(x)1x22\cos(x) \approx 1-\frac{x^2}{2}

So:

cos(xπ)1(xπ)22\cos(x-\pi) \approx 1-\frac{(x-\pi)^2}{2}

about x0=πx_0 = \pi.

Solution to Exercise 8

Recall:

ex1+xsin(x)xx36\begin{align} e^x &\approx 1+x \\ \sin(x) &\approx x-\frac{x^3}{6} \end{align}

So:

exsinx(1+x+)(xx36+)=x+x2e^x \sin x \approx (1+x+\cdots)(x-\frac{x^3}{6}+\cdots) = x+x^2
Solution to Exercise 9

The function and its derivatives at x=πx=\pi are:

f(x)=cos(x)f(π)=1f(x)=sin(x)f(π)=0f(x)=cos(x)f(π)=1\begin{align} f(x) &= \cos(x) & f(\pi) &= -1 \\ f'(x) &= -\sin(x) & f'(\pi) &= 0 \\ f''(x) &= -\cos(x) & f''(\pi) &= 1 \end{align}

So:

cosx1+12(xπ)2\cos x \approx -1+\frac{1}{2}(x-\pi)^2

at x=πx = \pi.

Solution to Exercise 10

The function and its derivatives at x=2x=2 are:

f(x)=7x26x+1f(2)=17f(x)=14x6f(2)=22\begin{align} f(x)&=7x^2-6x+1 & f(2) &= 17\\ f'(x)&=14x-6 & f'(2) &= 22 \end{align}

So:

f(x)17+22(x2)f(x) \approx 17+22(x-2)