Introduction
A tangent line of a function,
f
, at
x=a
is a linear approximation of the function near
x=a
.
However, it is a poor approximation for most functions. It does not capture its curvature.
To create better approximations, we use Taylor Polynomials.
A Taylor polynomial approximation of a function,
f(x)
, at
x = a
:
P_n(x) = f(a) + f'(a)(x - a) + \frac{f''(a)}{2!}(x - a)^2 + \cdots + \frac{f^{(n)}(a)}{n!}(x - a)^n
P_n(x)
: The Taylor Polynomial
n
: The degree of the polynomial (number of terms)
f(x)
: The function being approximated For example, here is an approximation of the above function:
f(x) = \frac{1}{2}x^3
at
x = 1
.
A Taylor polynomial of degree 2:
\begin{align*}
P_2(x) &= f(a) + f'(a)(x - a) + \frac{f''(a)}{2!}(x - a)^2 \\
&= f(1) + f'(1)(x - 1) + \frac{f''(1)}{2!}(x - 1)^2 \\
&= \frac{1}{2} + \frac{3}{2}(x - 1) + \frac{3}{2}(x - 1)^2
\end{align*}
Examples
Example 1:
Find the Maclaurin series of degree 2 approximating
f(x) = e^x
.
\begin{align*}
f(x) &= e^x & f(0) &= 1 \\
f'(x) &= e^x & f'(0) &= 1 \\
f''(x) &= e^x & f''(0) &= 1 \\
P_2(x) &= f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 \\
&= 1 + 1x + \frac{1}{2}x^2 \\
&= 1 + x + \frac{1}{2}x^2
\end{align*}
The Maclaurin series of degree 2 for
e^x
is
P_2(x) = 1 + x + \frac{1}{2}x^2
.
Example 2:
Find the Maclaurin series of degrees 1, 3, and 5 for
f(x) = \sin(x)
and observe how the approximation improves with increasing degree.
\begin{align*}
f(x) &= \sin(x) & f(0) &= 0 \\
f'(x) &= \cos(x) & f'(0) &= 1 \\
f''(x) &= -\sin(x) & f''(0) &= 0 \\
f'''(x) &= -\cos(x) & f'''(0) &= -1 \\
f^{(4)}(x) &= \sin(x) & f^{(4)}(0) &= 0 \\
f^{(5)}(x) &= \cos(x) & f^{(5)}(0) &= 1 \\
\end{align*}
\begin{align*}
P_1(x) &= f(0) + f'(0)x = x \text{(grey)} \\
P_3(x) &= f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 + \frac{f'''(0)}{3!}x^3 = x - \frac{x^3}{3!} = x - \frac{x^3}{6} \text{(blue)} \\
P_5(x) &= x - \frac{x^3}{6} + \frac{f^{(4)}(0)}{4!}x^4 + \frac{f^{(5)}(0)}{5!}x^5 = x - \frac{x^3}{6} + \frac{x^5}{5!} = x - \frac{x^3}{6} + \frac{x^5}{120} \text{(red)}
\end{align*}
Example 3:
Find the Taylor series of degree 2 for
f(x) = \ln(x)
at
x = 1
.
\begin{align*}
f(x) &= \ln(x) & f(1) &= 0 \\
f'(x) &= \frac{1}{x} & f'(1) &= 1 \\
f''(x) &= -\frac{1}{x^2} & f''(1) &= -1 \\
P_2(x) &= f(1) + f'(1)(x - 1) + \frac{f''(1)}{2!}(x - 1)^2 \\
&= 0 + 1(x - 1) + \frac{-1}{2}(x - 1)^2 \\
&= (x - 1) - \frac{1}{2}(x - 1)^2
\end{align*}
Example 4:
Find the Maclaurin series of degree 3 for
f(x) = x^3 - 2x^2 + 5x - 1
.
\begin{align*}
f(x) &= x^3 - 2x^2 + 5x - 1 & f(0) &= -1 \\
f'(x) &= 3x^2 - 4x + 5 & f'(0) &= 5 \\
f''(x) &= 6x - 4 & f''(0) &= -4 \\
f'''(x) &= 6 & f'''(0) &= 6 \\
P_3(x) &= f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 + \frac{f'''(0)}{3!}x^3 \\
&= -1 + 5x + \frac{-4}{2}x^2 + \frac{6}{6}x^3 \\
&= -1 + 5x - 2x^2 + x^3
\end{align*}
They are the same!
If approximating a polynomial function, a taylor series of a degree at or higher than the polynomial is the function.
Any derivative of a polynomial function higher than the degree of the polynomial is 0.
Eg:
\frac{d^4}{dx^4}x^3 - 2x^2 + 5x - 1 = 0
Example 5:
Use a Taylor polynomial of degree 2 for
f(x) = \sqrt{x}
at
x = 4
to approximate
\sqrt{4.1}
.
\begin{align*}
f(x) &= \sqrt{x} & f(4) &= 2 \\
f'(x) &= \frac{1}{2\sqrt{x}} & f'(4) &= \frac{1}{4} \\
f''(x) &= -\frac{1}{4x^{3/2}} & f''(4) &= -\frac{1}{32} \\
P_2(x) &= f(4) + f'(4)(x - 4) + \frac{f''(4)}{2!}(x - 4)^2 \\
&= 2 + \frac{1}{4}(x - 4) - \frac{1}{64}(x - 4)^2
\end{align*}
To approximate
\sqrt{4.1}
, we evaluate
P_2(4.1)
:
\begin{align*}
P_2(4.1) &= 2 + \frac{1}{4}(4.1 - 4) - \frac{1}{64}(4.1 - 4)^2 \\
&= 2 + \frac{1}{4}(0.1) - \frac{1}{64}(0.1)^2 \\
&= 2 + \frac{1}{40} - \frac{1}{6400} \\
&= 2.02484375
\end{align*}
\begin{align*}
\text{The approximation: } \sqrt{4.1} &\approx 2.02484375 \\
\text{The true value: } \sqrt{4.1} &= 2.02484567...
\end{align*}