# How is the error term in the Taylor expansion of a function arrived at?

$f(x)= \sum_{k=0}^{n} \frac{f^k(a)}{k!}(x-a)^k + \frac{ f^{n+1}(c) }{ (n+1)! } (x-a)^{n+1}$

I have some trouble understanding this, as it seems to imply that

$\frac{ f^{n+1}(c) }{ (n+1)! } (x-a)^{n+1} = \sum_{k=n+1}^{\infty} \frac{f^k(a)}{k!}(x-a)^k$

Because by the Taylor expansion of $f(x)$ at a:

$f(x)= \sum_{k=0}^{ \infty} \frac{f^k(a)}{k!}(x-a)^k$

This seems to be very similar to the mean value theorem, but I'm not sure how to prove the equation using it as it includes x to powers other than 1, and I only know $\frac{f(b)-f(a)}{b-a}=f'(a \le k \le b)$. As it may be of help here for me to understand the answer: how can the mean value theorem be derived from the Taylor series (if it can at all), and can this be generalised to higher derivitaves (how?)?

-

First off, note that you can't say that $f(x)=\displaystyle \sum_{k=0}^\infty \frac{f^k(a)}{k!}(x-a)^k$ holds unless you assume $f$ is analytic; that is, that the Taylor series converges. This isn't really related to the heart of your question, so I'm just including it as a note.

The source of confusion is that when you write $f(x)=\displaystyle \sum_{k=0}^n \frac{f^k(a)}{k!}(x-a)^k + \frac{f^{n+1}(c)}{(n+1)!} (x-a)^{n+1}$, you are saying that this equation, for a particular value of $x$ holds for some $c$ in the interval $[a,x]$ (assuming $a<x$). However, the value of $c$ depends on $x$. It might make more sense to subscript $c$ as $c_x$ to indicate the dependence on $x$.

Now when you write $\displaystyle\frac{f^{n+1}(c_x)}{(n+1)!} (x-a)^{n+1}=\sum_{k=n+1}^\infty \frac{f^k(a)}{k!}(x-a)^k$, there's no problem. This equation holds for a particular value of $x$; it's an equation about two numbers, not two functions, again assuming the Taylor series for $f$ converges at $x$.

We can think of both sides as functions of $x$, but $c_x$ can have very complicated dependence on $x$ (all we know about $c_x$ is that $a<c_x < x$ for $a<x$ and $x<c_x < a$ for $x<a$). If you do this, then assuming $f$ is analytic and the Taylor series converges everywhere, then the equation $\displaystyle\frac{f^{n+1}(c_x)}{(n+1)!} (x-a)^{n+1}=\sum_{k=n+1}^\infty \frac{f^k(a)}{k!}(x-a)^k$ holds as equality of functions.

-
Should that be $x>a$ in the middle paragraph, and isn't $a<x$ equivalent to $x>a$? With regards to the answer itself: is it true to say that the $n+1$ in $f^{n+1}(c_x)$ is arbitrary? Given that $c_x$ is a very complicated function of x, could $f^{n+1}(c_x)$ be replaced by $f^{q}(b_x)$, with $b_x$ having very complicated bounds? The main problem I had with this was why it has to be n+1. – Alyosha Oct 18 '12 at 16:43
All the inequalities should be fixed. Sorry about that. The $n+1$ isn't arbitrary. For $f(x)=x$, for example, if you take the 0th-order Taylor polynomial, it's just $a$. But it's not possible, for any $x \ne a$, to write $f(x)=a+\frac{f^2(b)}{2!}(x-a)^2$, or any higher power, because $f^2(b)=0$ regardless of $b$, so the right hand side will always be $a$ and the left hand side is $x$. Of course, for some functions you might be able to do what you are saying, but not in general. As for why you can get it to work with $n+1$, the proof of Taylor's theorem itself is a pretty good explanation... – Logan Maingi Oct 18 '12 at 17:02
Sorry, I forgot that $f^{p}(k)$ is a constant. Thanks for the heading to an explanation, it's perfect. – Alyosha Oct 18 '12 at 17:12
Here's a sketch of a proof of Taylor's theorem in case anyone else is having trouble understanding. $f(x)=f(a)+ \int_a^x f'(t) dt$. Integrating by parts $n$ times gives $f(x)=f(a)+(x-a)f'(a)+ \cdots + \frac{f^{n}(a)}{n!}(x-a)^n + \int_a^x \frac{f^{n+1}(t)}{(n+1)!}(x-t)^{n} dt$. Now it's easy to see that this integral is at most (in absolute value) $|\frac{\max_t f^{n+1}(t)}{(n+1)!} (x-a)^{n+1}|$ (where the maximum is for $t$ in the inerval $[a,x]$), and with just a little bit of messing around we can get to the form you've provided (namely by applying the intermediate value theorem on this). – Logan Maingi Oct 18 '12 at 17:14
I've never seen the proof phrased like that before- very elegant! – Alyosha Oct 18 '12 at 20:47