Taylor series (source code)

= Taylor series
{c}
{title2=$\sum_{n=0}^\infty f^{(n)}(a)(x-a)^n/n!$}
{wiki}

For a <function> with <derivatives> of every order at $a$, its <Taylor series> is the <power series>
$$
\sum_{n=0}^{\infty}\frac{f^{(n)}(a)}{n!}(x-a)^n.
$$
Its <partial sums> are <Taylor polynomials>. At $a=0$ it is called a <Maclaurin series>. Forming the coefficients, proving that its <partial sums> form a <convergent sequence>, and proving that their <limit> equals $f(x)$ are separate tasks. A <smooth function> provides all the coefficients, but a <real analytic function> is additionally represented locally by the resulting <power series>.

For the <exponential function>, every <derivative> of $e^x$ at zero equals one, giving
$$
e^x=\sum_{n=0}^{\infty}\frac{x^n}{n!}.
$$
Here equality holds for every real $x$: the <Taylor remainder> is bounded by $e^{|x|}|x|^{N+1}/(N+1)!$, which tends to zero for each fixed $x$. At $x=1$, the degree-five <Taylor polynomial> is $163/60\approx2.71666667$, and the absolute difference from $e$ is less than $e/720$. The <factorial> denominator eventually overwhelms every fixed power, allowing local <derivative> information to reconstruct this <function> throughout the real line.

The <geometric series> shows why the region of validity matters. For $f(x)=1/(1-x)$, the <Taylor series> at zero is $\sum_{k\geq0}x^k$, with <radius of convergence> one. For $x\ne1$, its finite <Taylor polynomial> satisfies the exact identity
$$
\frac1{1-x}-\sum_{k=0}^N x^k=\frac{x^{N+1}}{1-x}.
$$
At $x=1/2$ and $N=5$, the remainder is $1/32$. At $x=0.9$, the same degree-five <polynomial> has value $4.68559$ and remainder $5.31441$, although the <Taylor series> still converges to $10$ there. Convergence of the infinite expression does not guarantee accuracy from a particular small number of terms. For $|x|>1$, even the terms fail to tend to zero, so this <power series> cannot represent the <function>. The standard expansions and the conditions for <convergent series> are discussed in https://openstax.org/books/calculus-volume-2/pages/6-4-working-with-taylor-series[OpenStax, working with Taylor series].

\Image[/taylor-series-convergence-and-flatness.png]
{title=Geometric partial sums converge slowly near their convergence boundary, while a smooth flat function has an identically zero Taylor series}

A stronger caution comes from the <flat function>
$$
h(x)=\begin{cases}e^{-1/x^2},&x\ne0,\\0,&x=0.\end{cases}
$$
It is a <smooth function> with $h^{(n)}(0)=0$ for every $n$, so every <Taylor polynomial> at zero is zero and its <Taylor series> converges everywhere to zero. Nevertheless $h(1/2)=e^{-4}>0$. Off zero, repeated <differentiation> produces a <polynomial> in $1/x$ times $e^{-1/x^2}$; the exponential decay makes each required <limit> at zero vanish. This explains how all the local coefficients can miss a positive <function> arbitrarily close to the centre. <Real analyticity> supplies the additional condition that rules out this behavior.