# Taylor polynomial

The degree-$n$ Taylor polynomial of a function $f(x)$ about $x = a$ is the unique polynomial of degree $n$ whose value and first $n$ derivatives match the value and first $n$ derivatives of $f(x)$ at $x = a$.

The formula for a degree-$n$ Taylor polynomial of $f(x)$ about $x = a$ is $$\sum_{k=0}^{n} \frac{f^{(k)}(a)(x-a)^k}{k!} = f(a) + f'(a)(x - a) + \frac{f''(a)(x-a)^2}{2} + \dots + \frac{f^{(n)}(a)(x-a)^n}{n!}.$$ In the formula above, $f^{(k)}$ denotes the order-$k$ derivative of $f$.

Taylor polynomials are often used to approximate non-polynomial functions that cannot be calculated exactly, such as trigonometric functions, exponential functions, and logarithms.

## Derivation of the formula

We want the Taylor polynomial to have $k$-th derivative $f^{(k)}(a)$ at $x = a$. The Power Rule for derivatives gives that the derivative of $(x-a)^j$ is $j(x-a)^{j-1}$ for all positive integers $j$, and $0$ for $j = 0$ (because when $j = 0$ the function is a constant $1$). Here the Chain Rule is used implicitly with the fact that $x - a$ has derivative $1$ for all $x$.

For $m < k$, the degree-$m$ term in $x - a$ has $k$th derivative $0$, because after $k$ differentiations the degree of the term will have reached $0$ and then at least one more differentiation ensures that the term is eliminated.

For $m > k$, the degree-$m$ term in $x - a$ has $k$th derivative $0$ at $x = a$, because the $k$ differentiations leave a term with a positive power of $(x - a)$, which is zero at $x = a$.

The degree-$k$ term undergoes $k$ differentiations, leaving a constant term and accumulating all of the factors $j$ for $k \geq j \geq 1$. As such, its $k$th derivative is $k!$ times its original coefficient for all $x$, so the coefficient of $(x-a)^k$ should be defined as $\frac{f^{(k)}(a)}{k!}$.

## Special cases

### Maclaurin polynomial

A Maclaurin polynomial is a Taylor series with $a = 0$. Setting $a = 0$ simplifies the appearance of the polynomial somewhat, since every instance of $(x-a)$ in the formula is replaced with $x$.

For some functions, like $e^x$ and $\sin x$, Maclaurin polynomials are generally effective across the domain (although using a different $a$-value might allow greater accuracy for the same choice of degree). However, for functions like $\ln x$, Maclaurin polynomials cannot be defined because the function and its derivatives are undefined at $x = 0$. For other functions, Maclaurin polynomials can be defined, but do not in general approximate the function well (see Taylor series), so a value of $a$ closer to the $x$-value of the desired approximation must be chosen.

### Tangent-line approximation

A tangent-line approximation is a first-degree Taylor polynomial, given by $f(a) + f'(a)(x - a)$. The name "tangent-line approximation" comes from the fact that the graph is a line tangent to the graph of $f(x)$ at $x = a$. Tangent-line approximations are used in Euler's method and Newton's method.

## Error bound

Letting $P_n$ be the degree-$n$ Taylor polynomial of $f$ about $a$, the Lagrange Error Bound states that $$\lvert f(x) - P_n(x) \rvert \leq \left\lvert \frac{(x-a)^{n+1}M}{(n+1)!} \right\rvert$$ if $f^{(n+1)}(x)$ is defined and has absolute value at most $M$ on the entire interval $(a,x)$ if $x > a$ or $(x,a)$ if $x < a$.

The Lagrange Error Bound bounds the true value of $f(x)$ both above and below.

## Taylor series

The Taylor series of an infinitely differentiable function $f(x)$ is the infinite series $$\sum_{k=0}^{\infty} \frac{f^{(k)}(x-a)}{k!} = f(a) + f'(a)(x - a) + \frac{f''(a)(x-a)^2}{2} + \dots.$$ The partial sums of the Taylor series are the Taylor polynomials of $f(x)$ about $x = a$ of each degree.

The Maclaurin series is the Taylor series chosen with $a = 0$. The partial sums of the Maclaurin series are the Maclaurin polynomials of $f(x)$ of each degree.