Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
1  
The thing is: the tangent function has poles at the endpoints of your interval. Polynomials (which truncations of the Taylor series certainly are) can never have poles. You can thus expect that any series approximation for the tangent will be quite poor when you go away from the expansion point. –  J. M. Sep 26 '11 at 1:43
2  
Your strategy can be salvaged for the tangent function though. Halve the argument a certain number of times, up until you get a value that is near the expansion point. Evaluate your series there, and then repeatedly apply the double-angle formula the same number of time you halved your original argument. –  J. M. Sep 26 '11 at 1:45

2 Answers 2

up vote 1 down vote accepted

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

share|improve this answer
    
Thank you. I tried something like this before. However I found it to be a very pessimistic approach. For example to obtain an accuracy of $\epsilon = 0.01$ This formula suggests that we need 100 terms!! Since writing the question I found a much tighter bound for the remainder, namely $\left|R_n(x)\right|<\text{tan}(\pi /4)\left(\frac{1}{2}\right)^{n-1}$. To achieve the same accuracy this formula suggests that we only require 8 terms. –  aukie Sep 25 '11 at 15:35

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).

share|improve this answer
    
Thanks for the input, however I found the Lagrange remainder formula leads to a rather pessimistic approach. See comments after Sasha's post. –  aukie Sep 25 '11 at 15:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.