3
$\begingroup$

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
    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.2011-09-26

2 Answers 2

1

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

  • 0
    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.2011-09-25
1

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

  • 0
    Thanks for the input, however I found the Lagrange remainder formula leads to a rather pessimistic approach. See comments after Sasha's post.2011-09-25