## Taylor Polynomials

1. So last time we concluded discussing Taylor series with constructing a polynomial using the first ${n}$ terms in the Taylor series. This “Taylor polynomial” approximated our function, and we want to know how well does it approximate?

We will derive the Taylor series differently. Our derivation will give us a natural error term.

2. Set Up. Lets consider ${f(x)}$ which is sufficiently nice around ${x=0}$ (i.e., it has enough derivatives at ${x=0}$). The fundamental theorem of calculus tells us that
(1)$\displaystyle f(x) = f(0) + \int^{x}_{0}f'(t)\,\mathrm{d} t.$
Wonderful.

3. Linear Approximation. We now use integration by parts for the integral in Equation (1):
(2)\displaystyle \begin{aligned} \int^{x}_{0}f'(t)\,\mathrm{d} t &= \left.tf'(t)\right|^{x}_{0}-\int^{x}_{0}tf''(t)\,\mathrm{d} t\\ &= xf'(x)-0f'(0) - \int^{x}_{0}tf''(t)\,\mathrm{d} t\\ &= xf'(x) - \int^{x}_{0}tf''(t)\,\mathrm{d} t. \end{aligned}
Now we can plug in Equation (1) for the first term in the right hand side:
(3)\displaystyle \begin{aligned} xf'(x) - \int^{x}_{0}tf''(t)\,\mathrm{d} t &= x\left(f'(0)+\int^{x}_{0}f'(t)\,\mathrm{d} t\right) - \int^{x}_{0}tf''(t)\,\mathrm{d} t\\ &= xf'(0) - \int^{x}_{0}(t-x)f''(t)\,\mathrm{d} t. \end{aligned}
We plug this back into Equation (1)
(4)\displaystyle \begin{aligned} f(x) &= f(0) + \int^{x}_{0}f'(t)\,\mathrm{d} t\\ &= f(0) +\left[ xf'(0) - \int^{x}_{0}(t-x)f''(t)\,\mathrm{d} t\right]. \end{aligned}
Observe the first two terms are precisely the linear approximation to ${f(x)}$. What’s the third term? The error term! But we’re not done yet!

4. Inductive Procedure. We can iterate a procedure to get a better and better approximation. Performing integration by parts on
(5)$\displaystyle \int^{x}_{0}(t-x)f''(t)\,\mathrm{d} t$
will give us the next term in our approximation plus an integral. The integral gives us the error for using a quadratic approximation.

Lets do it! We use integration by parts
(6)\displaystyle \begin{aligned} \int^{x}_{0}(t-x)f''(t)\,\mathrm{d} t &= \left.\frac{(t-x)^{2}}{2!}f''(t)\right|^{x}_{0}-\int^{x}_{0}\frac{(t-x)^{2}}{2!}f'''(t)\,\mathrm{d} t\\ &=\frac{-(-x)^{2}}{2!}f''(0)-\int^{x}_{0}\frac{(t-x)^{2}}{2!}f'''(t)\,\mathrm{d} t \end{aligned}
So our approximation becomes
(7)\displaystyle \begin{aligned} f(x) &= f(0) + xf'(0) - \left[\int^{x}_{0}(t-x)f''(t)\,\mathrm{d} t\right]\\ &=f(0) + xf'(0) - \left[\frac{-(-x)^{2}}{2!}f''(0)-\int^{x}_{0}\frac{(t-x)^{2}}{2!}f'''(t)\,\mathrm{d} t\right]\\ &=f(0) + xf'(0) + \frac{x^{2}}{2!}f''(0)+\left[\int^{x}_{0}\frac{(t-x)^{2}}{2!}f'''(t)\,\mathrm{d} t\right] \end{aligned}
The bracketed term in the final line is the error term for using the quadratic approximation. But look: the quadratic approximation corresponds to the first 3 terms of the Taylor series! When we do this iterative procedure on the error term, integrating by parts will produce a higher order approximation. And for free, we get the error term telling us how good our approximation is!