Taylor's polynomial maximum power

Given a power series where I get the Taylor's polynomial. Can I define what should be the maximum power which gives me the approximate value with an estimated margin of error?

Let me be a bit more clear about the situation where I find myself.

I had: $$f(x) = \frac{1}{(x-1)}$$

I know the series expansion at x0=0 which is $$-1 - x - x^2 - x^3 - x^4 - x^5 + ...$$

ps. I'm not going to put here the convergence radius, however all the values used are within this radius.

I expanded my polynomial till power of 5, so my maximum power here is 5. Then I tried to calculate $f(0,2)$, and it gave me $-1,24992$, and for this same $x = 0,2$. The result was $-1,25$, so I have a margin of error of $0,00008$, which is a pretty decent value for the task I need this values.

Then I had $$g(x) = e^{2x}$$. The series expansion at x0=0 is $$1 + 2 x + 2 x^2 + \frac{4x^3}{3} + \frac{2 x^4}{3} + \frac{4 x^5}{15}$$

The maximum power of this expansion is still 5, however when I tried to calculate the value of 1 and the evaluated $\frac{109}{15}$ or in floating point $7.2\overline6$, and $e^2$ evaluates to approximately $7.389056$, however if I expand this series to the power of 10, the value it evaluates to me is approximately $7.388994$, which is decent, instead of the other one.

So for different taylor's polynomial we have to use different maximum powers in order to achieve the same or almost equal margin of error.

So my final question is: is there a formal (that isn't bruteforce) way I can get what should be the value of the maximum power I need to get an result with a margin of error set by me. Something like 0,00001 or so.

Yes there is a formula for this, and it’s known as the Lagrange Error Bound. The formula is as follows:

Let $$f$$ have a Taylor Polynomial centered at $$c$$ and let $$p_n(x)$$ be the polynomial that approximates the Taylor polynomial by truncating after the $$(x-c)^k$$ term. Then we have that the error for approximating $$f(a)$$ using $$n$$ terms is: $$R_n(a):=|f(a)-p_n(a)|\leq\frac{f^{(n+1)}_{max}}{(n+1)!}|a-c|^{n+1}$$ Where $$c$$ is the center and $$f^{(n+1)}_{max}$$ is the maximum value of the $$n+1^{st}$$ derivative of $$f$$ on a closed interval containing $$c$$ and $$a$$.

If you can come up with a general expression for the $$n^{th}$$ derivative, then you can solve this upper bound for $$n$$ to find out how many terms you need to get below a certain amount. Let’s look at an example:

Let $$f(x)=e^x$$, $$c=0$$, and lets only look at the interval $$(-1,1)$$. Then we have that $$f^{(n+1)}(x)=e^x$$ which is maximized at $$f^{(n+1)}(1)=1$$ for all $$n$$. Thus we get $$R_n(x)\leq\frac{|x|^{n+1}}{(n+1)!}$$. Suppose we want to know what $$n$$ we need to get an error below $$0.001$$ for $$x=0.3$$. Then we need an $$n$$ such that $$\frac{0.3^{n+1}}{(n+1)!}\leq 0.001$$, which gives us $$3^{n+1}\leq (n+1)!10^{n-2}$$ after a little algebra. You can use whatever technique you wish to solve for $$n$$, but numerical experimentation is often effective. Plugging in $$n=3$$ shows that this inequality holds, so we know that with four terms (max degree $$3$$) in the Taylor polynomial we will have the desired error bound.

Working with this errr bound is a standard type of question in computational calculus, and googling “Lagrange Error Bound” brings up a number of instructional videos with worked out examples. Here is an example with sine from Khan Academy.

———

In the case where the terms of the Taylor Polynomial alternate in sign, you can also use the alternating series error bound, which is easier to calculate and strictly better (that is, produced a smaller upper bound).

• Or "Taylor's formula with remainder". – Gerry Myerson Dec 11 '17 at 6:00
• It was better than I thought it would be, had no idea there was such a handy formal way. – João Dec 11 '17 at 13:45