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

approximationpower seriessequences-and-series

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.

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)!} $$

Related Question