The Taylor series is a representation of a function as an infinite sum of terms calculated from the values of its derivatives at a single point. The Taylor series of a one dimensional real or complex function \(f(x)\) that is infinitely differentiable at the point \(x=a\) is the power series:

$$ f(x) = f(a) + \frac{(x-a)}{1!}\left.\frac{df}{dx}\right|_{x=a} + \frac{(x-a)^2}{2!}\left.\frac{d^2f}{dx^2}\right|_{x=a} + \frac{(x-a)^3}{3!}\left.\frac{d^3f}{dx^3}\right|_{x=a} + \dots = \sum_{n=0}^{\infty} \frac{(x-a)^n}{n!}\left.\frac{d^nf}{dx^n}\right|_{x=a} \\ \label{eq:ts1} $$

An alternative form of the one dimensional Taylor series may be obtained by letting \(x=a\) such that \(x=a+h\). Substituting into \eqref{eq:ts1}:

$$ f(a+h) = f(a) + \frac{h}{1!}\left.\frac{df}{dx}\right|_{x=a} + \frac{h^2}{2!}\left.\frac{d^2f}{dx^2}\right|_{x=a} + \frac{h^3}{3!}\left.\frac{d^3f}{dx^3}\right|_{x=a} + \dots = \sum_{n=0}^{\infty} \frac{h^n}{n!}\left.\frac{d^nf}{dx^n}\right|_{x=a} \\ \label{eq:ts2} $$

The Taylor series may be generalised to functions of more than one variable. The multivariable Taylor series about the point \((a_1,\dots,a_k)\) may be expressed as:

$$ f(x_1,\dots,x_k) = \sum_{j=0}^{\infty} \left[\frac{1}{j!}\left[\sum_{n=1}^{k} (x_n-a_n)\left.\frac{\partial f}{\partial x_n}\right|_{x_1=a_1,\dots,x_k=a_k} \right]^j\right]\\ \label{eq:ts3} $$

For example, with \(k=2\):

$$ f(x_1,x_2) = f(a_1,a_2) + \left[(x_1-a_1)\left.\frac{\partial f}{\partial x_1}\right|_{(a_1,a_2)} + (x_2-a_2)\left.\frac{\partial f}{\partial x_2}\right|_{(a_1,a_2)} \right] + \frac{1}{2!}\left[(x_1-a_1)\left.\frac{\partial f}{\partial x_1}\right|_{(a_1,a_2)} + (x_2-a_2)\left.\frac{\partial f}{\partial x_2}\right|_{(a_1,a_2)} \right]^2 + \dots \\ \label{eq:ts4} $$ $$ \therefore f(x_1,x_2) = f(a_1,a_2) + \left[(x_1-a_1)\left.\frac{\partial f}{\partial x_1}\right|_{(a_1,a_2)} + (x_2-a_2)\left.\frac{\partial f}{\partial x_2}\right|_{(a_1,a_2)} \right] + \frac{1}{2!}\left[(x_1-a_1)^2\left.\frac{\partial^2 f}{\partial {x_1}^2}\right|_{(a_1,a_2)} + 2(x_1-a_1)(x_2-a_2)\left.\frac{\partial^2 f}{\partial x_1x_2}\right|_{(a_1,a_2)} + (x_2-a_2)^2\left.\frac{\partial^2 f}{\partial {x_2}^2}\right|_{(a_1,a_2)}\right] + \dots \\ \label{eq:ts5} $$

As with the one dimensional Taylor series, an alternative form may be obtained by letting \(a_j=x_j-h_j\) so that \(x_j=a_j+h_j\). Substituting this into equation \eqref{eq:ts3}:

$$ \therefore f(a_1+h_1,a_2+h_2) = f(a_1,a_2) + \left[h_1\left.\frac{\partial f}{\partial x_1}\right|_{(a_1,a_2)} + h_2\left.\frac{\partial f}{\partial x_2}\right|_{(a_1,a_2)} \right] + \frac{1}{2!}\left[(h_1^2\left.\frac{\partial^2 f}{\partial {x_1}^2}\right|_{(a_1,a_2)} + 2h_1h_2\left.\frac{\partial^2 f}{\partial x_1x_2}\right|_{(a_1,a_2)} + h_2^2\left.\frac{\partial^2 f}{\partial {x_2}^2}\right|_{(a_1,a_2)}\right] + \dots \\ \label{eq:ts6} $$

Example

Express \(y=cos(x)\) as a Taylor series about the point \(a=0\).

Determine the function derivatives and evaluate at the point \(a=0\):

\(\left.\frac{dy}{dx}\right|_{a=0}=cos(0)=1\)
\(\left.\frac{d^2y}{dx^2}\right|_{a=0}=-sin(0)=0\)
\(\left.\frac{d^3y}{dx^3}\right|_{a=0}=-cos(0)=-1\)
\(\left.\frac{d^4y}{dx^4}\right|_{a=0}=sin(0)=0\)
\(\left.\frac{d^5y}{dx^5}\right|_{a=0}=cos(0)=1\)
\(\left.\frac{d^6y}{dx^6}\right|_{a=0}=-sin(0)=0\)
\(\left.\frac{d^7y}{dx^7}\right|_{a=0}=-cos(0)=-1\)
\(\vdots\)

Substituting the above values into \eqref{eq:ts1}:

$$ f(x) = f(0) + \frac{(x-0)}{1!}\left.\frac{df}{dx}\right|_{x=a} + \frac{(x-0)^2}{2!}\left.\frac{d^2f}{dx^2}\right|_{x=a} + \frac{(x-0)^3}{3!}\left.\frac{d^3f}{dx^3}\right|_{x=a} + \dots = 1 - \frac{1}{2!}x^2 + \frac{1}{4!}x^4 - \frac{1}{6!}x^6 + \dots = \sum_{n=0}^{\infty}\frac{(-1)^nx^{2n}}{(2n)!} \\ \label{eq:ex1} $$

The figure below shows plots of the Taylor series polynomial for degress of \(n=5,7,9,15,25\). Observe that as the degree of the polynomial increases, it approaches the correct function. Also note that as the approximation diverges from the point at which it was expanded (\(a=0\)) that the error between the exact function value and the Taylor polynomial series increases.

Smiley face
Taylor series approximation of \(y=cos(x)\) for \(n=5,7,9,15,25\).