How to bound the truncation error for a Taylor polynomial approximation of $\tan(x)$

2.5k Views Asked by At

I am playing with Taylor series! I want to go beyond the basic text book examples ($\sin(x)$, $\cos(x)$, $\exp(x)$, $\ln(x)$, etc.) and try something different to improve my understanding. So I decided to write a program for approximating $\tan(x)$. But I am having difficulty.

I want to use the Taylor series of $\tan(x)$ to approximate the function on a closed subinterval of $(-\frac{\pi}{2},\frac{\pi}{2})$. But for a given accuracy $\epsilon$ how do I know what the degree of Taylor polynomial $N$ to take that guarantees an accuracy of $\epsilon$ ?

Given that $\tan^{(n+1)}(x)$, the $(n+1)^{th}$ derivative of $\tan(x)$ is unbounded on $(-\frac{\pi}{2},\frac{\pi}{2})$ I don't know how to put a bound on the Cauchy or Lagrange remainder terms so that I can determine $N$.

Say for example I choose to approximate on $[-\frac{\pi}{4},\frac{\pi}{4}]$. I would be content with this. But still determining $N$ for a given $\epsilon$ is unclear to me, any help would be appreciated.

Thanks for reading.

2

There are 2 best solutions below

1
On BEST ANSWER

The Darboux's formula provides an answer:

$$ \tan(x) = \sum_{m=0}^n \frac{x^m}{m!} \tan^{(m)}(0) + \frac{x^{n+1}}{n!} \int_0^1 (1-t)^n \tan^{(n+1)}( t x) \mathrm{d} t $$

Added: And since, for $-\frac{\pi}{4} \le x \le \frac{\pi}{4}$, $\left\vert x^{n+1} \tan^{(n+1)}(t x) \right\vert \le c = \left(\frac{\pi}{4}\right)^{n+1} \tan^{(n+1)}\left( \frac{\pi}{4} \right)$, we have

$$ \left\vert \frac{x^{n+1}}{n!} \int_0^1 (1-t)^n \tan^{(n+1)}( t x) \mathrm{d} t \right\vert \le \frac{c}{n!} \int_0^1 (1-t)^n = \frac{c}{(n+1)!} $$

1
On

The Taylor series for the tangent converges in the open interval $(-\pi/2,\pi/2)$, but does not converge at the endpoints, because the tangent has poles there, This generally means that the series will converge slower the closer you get to the endpoints, and there is no fixed number of terms that will get you a uniformly bounded error everywhere.

For $[-\pi/4,\pi/4]$, wouldn't the Lagrange remainder formula be sufficient to estimate the error for any given $N$?

Less ambitiously, you could also just graph the difference between your series approximation with the tangent you get from dividing series approximations to cosine and sine (whose error terms are easier to find).