# Taylor and MacLaurin series

For an arbitrary integer $$k$$, the derivative of order $$k$$ of a function $$f$$ is computed by differentiating it $$k$$ times. It is defined by induction $$$ f^{(0)}(x_0) =f(x_0),\qquad f^{(k+1)}(x_0) = \frac{d}{dx}f^{(k)}(x_0)$$$

The usual derivative is of order 1; the second derivative is of order 2, etc. The derivative of order $$k$$ is also denoted by $$\displaystyle \frac{d^k}{dx^k}f(x)$$.

The derivative of $$f(x) = e^x$$ is $$f'(x)=e^{x}$$; so its second derivative is $$e^{x}$$ as well and so on. Therefore $$f^{(k)}(x) = e^{x}$$ for all $$k$$.

The derivatives of order $$k$$ of some common functions are summarised below. \begin{gather*} (e^x)^{(k)} = e^x\\ (\sin x)^{(2k)} = (-1)^k\sin x,\quad (\sin x)^{(2k+1)} = (-1)^k\cos x\\ (\cos x)^{(2k)} = (-1)^k\cos x,\quad (\cos x)^{(2k+1)} = (-1)^{k+1}\sin x\\ ( x^\alpha)^{(k)} = \alpha (\alpha -1)\dots(\alpha -k+1) x^{\alpha -k} \end{gather*}

All these formulae an be proved by induction.

The Taylor series approximates a function by a polynomial near a point \begin{align*} f(x) &= f(x_0) + f'(x_0) (x-x_0)+ \frac{f'(x_0)}{2!}(x-x_0)^2 +\dots\\ &= \sum_{k=0}^{\infty} \frac{f^{(k)}(x_0)}{k!}(x-x_0)^k \end{align*} It refines the approximation of a function by its tangent.

The series is also called Taylor expansion or asymptotic expansion. The polynomial up to order $$k$$ is the Taylor expansion of order $$k$$.

When $$x_0=0$$, the Taylor series is called a MacLaurin series $$$ f(x) = f(0) + f'(0) x+ \frac{f'(0)}{2!}x^2 +\dots + \frac{f^{(k)}(0)}{k!}x^k +\dots. $$$

For instance, the MacLaurin series of the function $$f(x) = e^x$$ is $$$e^x = 1+x+\frac{x^2}{2!}+\dots+\frac{x^k}{k!}+\dots $$$ We calculate this using $$f^{(k)}(x) = e^{x}$$, and so $$f^{(k)}(0) = 1$$ for all $$k$$.

The MacLaurin series of an indefinitely differentiable function $$f$$ is $$$ f(x) = \sum_{k=0}^{\infty} \frac{f^{(k)}(0)}{k!}x^k $$$

We explain how to **find the coefficients of the polynomial**. Consider an infinite polynomial that approximates $$f$$ $$$ g(x) = a_0+a_1x+a_2x^2+\dots +a_kx^k+\dots $$$ We must have $$f(0) = g(0) = a_0$$. By differentiation, $$$ g'(x) = a_1+2 a_2x^2+\dots+k a_kx^{k-1}+\dots $$$ Therefore $$f'(0) = g'(0) = a_1$$. Repeating the argument, we find $$$ a_k = \frac{f^{(k)}(0)}{k!} . $$$

We clarify the **identification of a function and its MacLaurin series**

- Depending on the function, the series may converge for all $$x$$ or for certain values of $$x$$ only. When the series converges, the function generally equals the series (though there are some exceptions).
- This said, the function can always be approximated by a polynomial, in the sense that, for some constant $$M$$, $$$ \vert f(x) - \sum_{k=0}^{n} \frac{f^{(k)}(0)}{k!}x^k\vert \le M \vert x\vert ^{n+1} $$$

The MacLaurin series of common functions are obtained by computing their successive derivatives. Some are given below.

\begin{align*} e^x & = 1+x + \dots+ \frac{x^k}{k!}+\dots\\ \sin x &= x - \frac{x^3}{3!} + \dots+ (-1)^k \frac{x^{2k+1}}{(2k+1)!}+\dots\\ \cos x &= 1- \frac{x^2}{2!} + \dots+ (-1)^k \frac{ x^{2k}}{(2k)!}+\dots\\ (1+x)^n &= 1+x + \dots+ \frac{n(n-1)\dots(n-k+1) }{k!}x^k +\dots\\ \frac{1}{1+x} &= 1- x + \dots+ (-1)^k x^k+\dots\\ \ln(1+x) &= x - \frac{x^2}{2}+ \dots+ (-1)^{k+1}\frac{x^k}{k}+\dots\\ \end{align*}

For instance, for $$f(x) = \sin x$$, we have that $$$f^{(2k)}(x) = (-1)^k\sin x,\qquad f^{(2k+1)}(x) = (-1)^k\cos x.$$$ Therefore, $$f^{(2k)}(0) = 0$$ and $$f^{(2k+1)}(0) = (-1)^k$$. We deduce that $$$ \sin x = \sum_{k'=0}^{\infty} \frac{f^{(k')}(0)}{k'!}x^{k'} = \sum_{k=0}^{\infty} (-1)^k \frac{x^{2k+1} }{(2k+1)!}$$$