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.