How can the Taylor expansion of sine converge for all x?

996 Views Asked by At

So, I am writing a C++ program that sum the series expansion of sin(x). But for large values of x my program fails.

$\sin(x)=x-(x^3/3!)+(x^5/5!)-...=$$\sum_{n=0}^n (-1)^n\frac{x^{2n+1}}{(2n+1)!}$

I don't understand, how can we say that the sum converge for all x?

If $\lim_{x\to \infty}$ then the terms in the series blows up towards infinity and the sum diverges. What is it that I don't understand?

3

There are 3 best solutions below

5
On

Check the Lagrange Remainder of your Taylor series $$R_n = \frac {f^{(n+1)}(\alpha) x^{n+1}}{(n+1)!}$$

Since you have ${(n+1)!}$ dominating $x^{n+1}$, the remainder will approach zero and your series converge.

You can also look at the series as an alternating series whose terms are approaching zero, so it converges.

For larger $x$ values you need more terms to get good approximation.

0
On

To avoid an overflow which makes the series diverging, use recursive functions

to compute powers $x^n$ and factorials $n!$.

use the formulas $$x^i=x^{i-1}.x$$ and

$$n!=(n-1)!.n$$

0
On

The ratio of consecutive terms is $-\frac{x^2}{2(n+1)(2n+3)}$, which $\to 0$ as $n\to\infty$ regardless of the value of $x$, so the series always converges. I'm not sure why you're having trouble programming it, but multiplying the latest term by the required ratio may help. You might also find it helpful to use a series for small $|x|$, while recursing down the size of $x$ using identities such as $\sin 3x=\sin x(3-4\sin^2 x)$. (You're probably experienced enough programming for this tip to be unnecessary, but just in case: cash $\sin x$ in the above so you don't have to compute it twice, or you'll increase the algorithm's computational complexity.)