# Calculus/Taylor series
## Taylor Series

A function $f(x)$ is said to be analytic if it can be represented by the an infinite power series
    $\sum _{n=0}^{\infty }c_{n}(x-a)^{n}$
The Taylor expansion or Taylor series representation of a function, then, is
    $\sum _{n=0}^{\infty }{\frac {f^{(n)}(a)}{n!}}(x-a)^{n}$
sin(x) and Taylor approximations, polynomials of degree 1, 3, 5, 7, 9, 11 and 13.
Here, $n!$ is the factorial of $n$ and $f^{(n)}(a)$ denotes the $n$th derivative of $f$ at the point $a$ . If this series converges for every $x$ in the interval $(a-r,a+r)$ and the sum is equal to $f(x)$ , then the function $f(x)$ is called analytic. To check whether the series converges towards $f(x)$, one normally uses estimates for the remainder term of Taylor's theorem. A function is analytic if and only if a power series converges to the function; the coefficients in that power series are then necessarily the ones given in the above Taylor series formula.
If $a=0$ , the series is also called a Maclaurin series.
The importance of such a power series representation is threefold. First, differentiation and integration of power series can be performed term by term and is hence particularly easy. Second, an analytic function can be uniquely extended to a holomorphic function defined on an open disk in the complex plane, which makes the whole machinery of complex analysis available. Third, the (truncated) series can be used to approximate values of the function near the point of expansion.
The function $f(z)=e^{-{\frac {1}{z^{2}}}}$ is not analytic: the Taylor series is 0, although the function is not.
Note that there are examples of infinitely often differentiable functions $f(x)$ whose Taylor series converge, but are not equal to $f(x)$ . For instance, for the function defined piecewise by saying that $f(x)={\begin{cases}0&x=0\\e^{-{\frac {1}{x^{2}}}}&x\neq 0\end{cases}}$ , all the derivatives are 0 at $x=0$ , so the Taylor series of $f(x)$ is 0, and its radius of convergence is infinite, even though the function most definitely is not 0. This particular pathology does not afflict complex-valued functions of a complex variable. Notice that $f(z)=e^{-{\frac {1}{z^{2}}}}$ does not approach 0 as $z$ approaches 0 along the imaginary axis.
Some functions cannot be written as Taylor series because they have a singularity; in these cases, one can often still achieve a series expansion if one allows also negative powers of the variable $x$; see Laurent series. For example, $f(z)=e^{-{\frac {1}{z^{2}}}}$ can be written as a Laurent series.
The Parker-Sockacki theorem is a recent advance in finding Taylor series which are solutions to differential equations. This theorem is an expansion on the Picard iteration.

### Derivation

Suppose we want to represent a function as an infinite power series, or in other words a polynomial with infinite terms of degree "infinity". Each of these terms are assumed to have unique coefficients, as do most finite-polynomials do. We can represent this as an infinite sum like so:
    $f(x)={c_{0}}(x-a)^{0}+c_{1}(x-a)^{1}+c_{2}(x-a)^{2}+c_{3}(x-a)^{3}+\cdots +c_{n}(x-a)^{n}+\cdots$
where $a$ is the radius of convergence and $c_{0},c_{1},c_{2},\dots ,c_{n},\dots$ are coefficients. Next, with summation notation, we can efficiently represent this series as
    $\sum _{n=0}^{\infty }c_{n}(x-a)^{n}$
which will become more useful later. As of now, we have no schematic for finding the coefficients other than finding each one in the series by hand. That method would not be particularly useful. Let us, then, try to find a pattern and a general solution for finding the coefficients. As of now, we have a simple method for finding the first coefficient. If we substitute $a$ for $x$ then we get
    $f(a)=c_{0}$
This gives us $c_{0}$ . This is useful, but we still would like a general equation to find any coefficient in the series. We can try differentiating with respect to x the series to get
    $f'(x)=c_{1}(x-a)^{0}+2c_{2}(x-a)^{1}+3c_{3}(x-a)^{2}+4c_{4}(x-a)^{3}+\cdots +nc_{n}(x-a)^{(n-1)}+\cdots$
We can assume $c_{n}$ and $a$ are constant. This proves to be useful, because if we again substitute $a$ for $x$ we get
    $f'(a)=c_{1}$
Noting that the first derivative has one constant term ($c_{1}(x-a)^{0}=c_{1}$) we can find the second derivative to find $c_{2}$ . It is
    $f''(x)=2c_{2}+(2\times 3)c_{3}(x-a)^{1}+(3\times 4)c_{4}(x-a)^{2}+\cdots +(n)(n-1)c_{n}(x-a)^{(n-2)}+\cdots$
If we again substitute $a$ for $x$ :
    $f''(a)=2c_{2}$
Note that $c_{2}$'s initial exponent was 2, and $c_{1}$'s initial exponent was 1. This is slightly more enlightening, however it is still slightly ambiguous as to what is happening. Going off the previous examples, if we differentiate again we get
    $f'''(x)=(2\times 3)c_{3}(x-a)^{0}+(2\times 3\times 4)c_{4}(x-a)^{1}+(3\times 4\times 5)c_{5}(x-a)^{2}+\cdots +(n)(n-1)(n-2)c_{n}(x-a)^{n-3}$
If we substitute $x=a$ we, again, that
    $f'''(a)=(2\times 3)c_{3}$
By now, the pattern should be becoming clearer. $(n)(n-1)(n-2)$ looks suspiciously like $n!$ . And indeed, it is! If we carry this out $n$ times by finding the $n$th derivative, we find that the multiple of the coefficient is $n!$ . So for some $c_{n}$ , for any integer $n\geq 0$ ,
    $n!\times c_{n}={\frac {d^{n}}{dx^{n}}}f(a)$
Or, with some simple manipulation, more usefully,
    $c_{n}={\frac {f^{(n)}(a)}{n!}}$
where $f^{(0)}(x)=f(x)$ and $f^{(1)}(x)=f'(x)$ and so on. With this, we can find any coefficient of the "infinite polynomial". Using the summation definition for our "polynomial" given earlier,
    $\sum _{n=0}^{\infty }c_{n}(x-a)^{n}$
we can substitute for $c_{n}$ to get
    $f(x)=\sum _{n=0}^{\infty }{\frac {f^{(n)}(a)}{n!}}(x-a)^{n}$
This is the definition of any Taylor series. But now that we have this series, how can we derive the definition for a given analytic function? We can do just as the definition specifies, and fill in all the necessary information. But we will also want to find a specific pattern, because sometimes we are left with a great many terms simplifying to 0.
First, we have to find $f(a)$ . Because we are now deriving our own Taylor Series, we can choose anything we want for $f(x)$ , but note that not all functions will work. It would be useful to use a function that we can easily find the $n$-th derivative for. A good example of this would be $\sin(x)$ . With $\sin(x)$ chosen, we can begin to find the derivatives. Before we begin, we should also note that $a$ is essentially the "offset" of the function along the x-axis, because this is also essentially true for any polynomial. With that in mind, we can assume, in this particular case, that the offset is $0$ and so $a=0$. With that in mind, "0-th" derivative or the function itself would be
    $\sin(0)=0$
If we plug that in to the definition of the first term in the series, again noting that $a=0$ , we get
    ${\frac {0}{0!}}x^{0}=0$
where $0!=1$ . This means that the first term of the series is 0, because anything multiplied by 0 is 0. Take note that not all Taylor series start out with a 0 term. Next, to find the next term, we need to find the first derivative of the function. Remembering that the derivative of $\sin(x)$ is $\cos(x)$ we get that
    ${\frac {d}{dx}}\sin(0)=\cos(0)=1$
This means that our second term in the series is
    ${\frac {1}{1!}}x^{1}=x$
Next, we need to find the third term. We repeat this process.
    ${\frac {d^{2}}{dx^{2}}}\sin(0)=-\sin(0)=0$
Because the derivative of $\cos(x)=-\sin(x)$ . We continue with
    ${\frac {0}{2!}}x^{2}=0$
The fourth term:
    ${\frac {d^{3}}{dx^{3}}}\sin(0)=-\cos(0)=-1$
    ${\frac {-1}{3!}}x^{3}={\frac {-x^{3}}{6}}$
Repeating this process we can get the sequence
    ${\frac {0}{0!}}x^{0},{\frac {1}{1!}}x^{1},{\frac {0}{2!}}x^{2},{\frac {-1}{3!}}x^{3},{\frac {0}{4!}}x^{4},{\frac {1}{5!}}x^{5},{\frac {0}{6!}}x^{6},{\frac {-1}{7!}}x^{7},\dots$
which simplifies to
    $0,x,0,{\frac {-x^{3}}{6}},0,{\frac {x^{5}}{120}},0,{\frac {-x^{7}}{5040}},\dots$
Because we are ultimately dealing with a series, the zero terms can be ignored, giving use the new sequence
    $x,{\frac {-x^{3}}{6}},{\frac {x^{5}}{120}},{\frac {-x^{7}}{5040}},\dots$
There is a pattern here, however it may be easier to see if we take the numerator and the denominator separately. The numerator:
    $1,-1,1,-1,\dots$
    $1!,3!,5!,7!,\dots$
And for the $x$ part of the terms, we have the sequence
    $x,x^{3},x^{5},\dots$
By this point, at least for the denominator and the $x$ part, the pattern should be obvious. It is, for the denominator
    $(2n-1)!={\text{denom}}_{n}$
The $x$ term:
    $x^{2n-1}={\text{xterm}}_{n}$
Finally, the numerator may not be as obvious, but it follows this pattern:
    $(-1)^{n-1}$
With all of these things discovered, we can put them together to find the rule for the $n$th term of the sequence:
    ${\frac {(-1)^{n-1}}{(2n-1)!}}x^{2n-1}={\text{sumterm}}_{n}$
And so our Taylor (Maclaurin) series for $\sin(x)$ is
    $f(x)=\sum _{n=1}^{\infty }{\frac {(-1)^{n-1}}{(2n-1)!}}x^{2n-1}$

### List of Taylor series

Several important Taylor series expansions follow. All these expansions are also valid for complex arguments $x$ .
Exponential function and natural logarithm:
    $e^{x}=\sum _{n=0}^{\infty }{\frac {x^{n}}{n!}}\quad {\text{ for all }}x$
    $\ln(1+x)=\sum _{n=1}^{\infty }{\frac {(-1)^{n-1}}{n}}x^{n}\quad {\text{ for }}|x|<1$
Geometric series:
    ${\frac {1}{1-x}}=\sum _{n=0}^{\infty }x^{n}\quad {\text{ for }}|x|<1$
Binomial series:
    $(1+x)^{\alpha }=\sum _{n=0}^{\infty }{\binom {\alpha }{n}}x^{n}\quad {\text{ for all }}|x|<1\quad {\text{ and all complex }}\alpha$
Trigonometric functions:
    $\sin(x)=\sum _{n=1}^{\infty }{\frac {(-1)^{n-1}}{(2n-1)!}}x^{2n-1}\quad {\text{ for all }}x$
    $\cos(x)=\sum _{n=0}^{\infty }{\frac {(-1)^{n}}{(2n)!}}x^{2n}\quad {\text{ for all }}x$
    $\tan(x)=\sum _{n=1}^{\infty }{\frac {B_{2n}(-4)^{n}(1-4^{n})}{(2n)!}}x^{2n-1}\quad {\text{ for }}|x|<{\frac {\pi }{2}}$
    $\sec(x)=\sum _{n=0}^{\infty }{\frac {(-1)^{n}E_{2n}}{(2n)!}}x^{2n}\quad {\text{ for }}|x|<{\frac {\pi }{2}}$
    $\arcsin(x)=\sum _{n=0}^{\infty }{\frac {(2n)!}{4^{n}(n!)^{2}(2n+1)}}x^{2n+1}\quad {\text{ for }}|x|<1$
    $\arctan(x)=\sum _{n=0}^{\infty }{\frac {(-1)^{n}}{2n+1}}x^{2n+1}\quad {\text{ for }}|x|<1$
Hyperbolic functions:
    $\sinh(x)=\sum _{n=1}^{\infty }{\frac {x^{2n-1}}{(2n-1)!}}\quad {\text{ for all }}x$
    $\cosh(x)=\sum _{n=0}^{\infty }{\frac {x^{2n}}{(2n)!}}\quad {\text{ for all }}x$
    $\tanh(x)=\sum _{n=1}^{\infty }{\frac {B_{2n}2^{2n}(2^{2n}-1)}{(2n)!}}x^{2n-1}\quad {\text{ for }}|x|<{\frac {\pi }{2}}$
    ${\rm {arsinh}}(x)=\sum _{n=0}^{\infty }{\frac {(-1)^{n}(2n)!}{2^{2n}(n!)^{2}(2n+1)}}x^{2n+1}\quad {\text{ for }}|x|<1$
    ${\rm {artanh}}(x)=\sum _{n=1}^{\infty }{\frac {x^{2n-1}}{2n-1}}\quad {\text{ for }}|x|<1$
Lambert's W function:
    $W_{0}(x)=\sum _{n=1}^{\infty }{\frac {(-n)^{n-1}}{n!}}x^{n}\quad {\text{ for }}|x|<{\frac {1}{e}}$
The numbers $B_{k}$ appearing in the expansions of $\tan(x)$ and $\tanh(x)$ are the Bernoulli numbers. The ${\binom {\alpha }{n}}$ in the binomial expansion are the binomial coefficients. The $E_{k}$ in the expansion of $sec(x)$ are Euler numbers.

### Multiple dimensions

The Taylor series may be generalized to functions of more than one variable with
    $\sum _{n_{1}=0}^{\infty }\cdots \sum _{n_{d}=0}^{\infty }{\frac {\partial ^{n_{1}}}{\partial x_{1}^{n_{1}}}}\cdots {\frac {\partial ^{n_{d}}}{\partial x_{d}^{n_{d}}}}{\frac {f(a_{1},\dots ,a_{d})}{n_{1}!\cdots n_{d}!}}(x_{1}-a_{1})^{n_{1}}\cdots (x_{d}-a_{d})^{n_{d}}$

### History

The Taylor series is named for mathematician Brook Taylor, who first published the power series formula in 1715.

### Constructing a Taylor Series

Several methods exist for the calculation of Taylor series of a large number of functions. One can attempt to use the Taylor series as-is and generalize the form of the coefficients, or one can use manipulations such as substitution, multiplication or division, addition or subtraction of standard Taylor series (such as those above) to construct the Taylor series of a function, by virtue of Taylor series being power series. In some cases, one can also derive the Taylor series by repeatedly applying integration by parts. The use of computer algebra systems to calculate Taylor series is common, since it eliminates tedious substitution and manipulation.

#### Example 1

Consider the function
    $f(x)=\ln {\big1+\cos(x){\big )}$
for which we want a Taylor series at 0.
We have for the natural logarithm
    $\ln(1+x)=\sum _{n=1}^{\infty }{\frac {(-1)^{n+1}}{n}}x^{n}=x-{\frac {x^{2}}{2}}+{\frac {x^{3}}{3}}-{\frac {x^{4}}{4}}+\cdots \quad {\text{ for }}|x|<1$
and for the cosine function
    $\cos(x)=\sum _{n=0}^{\infty }{\frac {(-1)^{n}}{(2n)!}}x^{2n}=1-{\frac {x^{2}}{2!}}+{\frac {x^{4}}{4!}}-\cdots \quad {\text{ for all }}x\in \mathbb {C}$
We can simply substitute the second series into the first. Doing so gives
    $\left(1-{\frac {x^{2}}{2!}}+{\frac {x^{4}}{4!}}-\cdots \right)-{\frac {1}{2}}\left(1-{\frac {x^{2}}{2!}}+{\frac {x^{4}}{4!}}-\cdots \right)^{2}+{\frac {1}{3}}\left(1-{\frac {x^{2}}{2!}}+{\frac {x^{4}}{4!}}-\cdots \right)^{3}-\cdots$
Expanding by using multinomial coefficients gives the required Taylor series. Note that cosine and therefore $f$ are even functions, meaning that $f(x)=f(-x)$, hence the coefficients of the odd powers $x$, $x^{3}$, $x^{5}$, $x^{7}$ and so on have to be zero and don't need to be calculated. The first few terms of the series are
    $\ln {\big1+\cos(x){\big )}=\ln(2)-{\frac {x^{2}}{4}}-{\frac {x^{4}}{96}}-{\frac {x^{6}}{1440}}-{\frac {17x^{8}}{322560}}-{\frac {31x^{10}}{7257600}}-\cdots$
The general coefficient can be represented using Faà di Bruno's formula. However, this representation does not seem to be particularly illuminating and is therefore omitted here.

#### Example 2

Suppose we want the Taylor series at 0 of the function
    $g(x)={\frac {e^{x}}{\cos(x)}}$
We have for the exponential function
    $e^{x}=\sum _{n=0}^{\infty }{\frac {x^{n}}{n!}}=1+x+{\frac {x^{2}}{2!}}+{\frac {x^{3}}{3!}}+{\frac {x^{4}}{4!}}+\cdots$
and, as in the first example,
    $\cos(x)=1-{\frac {x^{2}}{2!}}+{\frac {x^{4}}{4!}}-\cdots$
Assume the power series is
    ${\frac {e^{x}}{\cos(x)}}=c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+\cdots$
Then multiplication with the denominator and substitution of the series of the cosine yields
    $e^{x}$ $={\bigc_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+\cdots {\big )}\cos(x)$ $=\left(c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+c_{4}x^{4}+\cdots \right)\left(1-{\frac {x^{2}}{2!}}+{\frac {x^{4}}{4!}}-\cdots \right)$ $=c_{0}-{\frac {c_{0}}{2}}x^{2}+{\frac {c_{0}}{4!}}x^{4}+c_{1}x-{\frac {c_{1}}{2}}x^{3}+{\frac {c_{1}}{4!}}x^{5}+c_{2}x^{2}-{\frac {c_{2}}{2}}x^{4}+{\frac {c_{2}}{4!}}x^{6}+c_{3}x^{3}-{\frac {c_{3}}{2}}x^{5}+{\frac {c_{3}}{4!}}x^{7}+\cdots$
Collecting the terms up to fourth order yields
    $=c_{0}+c_{1}x+\left(c_{2}-{\frac {c_{0}}{2}}\right)x^{2}+\left(c_{3}-{\frac {c_{1}}{2}}\right)x^{3}+\left(c_{4}+{\frac {c_{0}}{4!}}-{\frac {c_{2}}{2}}\right)x^{4}+\cdots$
Comparing coefficients with the above series of the exponential function yields the desired Taylor series
    ${\frac {e^{x}}{\cos(x)}}=1+x+x^{2}+{\frac {2x^{3}}{3}}+{\frac {x^{4}}{2}}+\cdots$

## Generalized Mean Value Theorem

This page or section of Calculus is a stub. You can help Wikibooks by expanding it.