# calculating $\sin x$ in floating point arithmetic

I would like some help in the following exercise: In floating point arithmetic we want to calculate $\sin 30$ using the type $$\sin x=\sum_{k=0}^{N}t_{k}$$ where $t_{0}=x,t_{k}=-t_{k-1}\frac{x^2}{(2k+2)(2k+3)}$. For $N\ge 40$ the result remains the same $-0.204857 \cdot 10^5$. Now I am asked to explain this phenomenon. I thought that this is happening because $t_{40},t_{41},...$ are too small in comparison to the sum till $k=39$, but how do I prove it in a formal way?

• $30^\circ$ and $30$ radians are very different things. Which one? – J. M. isn't a mathematician Jun 3 '16 at 10:55
• just 30, not radians – asdf Jun 3 '16 at 10:57
• So, $\pi/6$? What happens if you plug that into your expression? – J. M. isn't a mathematician Jun 3 '16 at 10:58
• Your recursive formula is wrong: you have $t_1=-x^3/20$ but it should be $-x^3/6$. Your denominator should be $(2k)(2k+1)$ instead. – Ian Jun 3 '16 at 11:49

You are wrong, the terms are not too small but to large. Actually you compute the Taylor series of $\sin(x)$ for $x=30$. The largest term is for $k=14$ and is about $7.762\times 10^{11}.$
To actually compute the sum with say double-precision floating point arithmetic, all your large terms must cancel to give a value $\approx -0.99.$
This is almost impossible because your terms are not computed exactly and there will be truncation errors of order at least $10^{12}$ machine epsilons.
• There are two different things occurring: 1. the earlier terms are too large and of opposite sign, so you have catastrophic cancellation; 2. the later terms are too small to have any numerical impact on the earlier terms. The second one explains why the answer doesn't change when you ramp up $N$ past a certain point. The first one explains part of why the answer is so horribly wrong. (The other major part is that the formula for the summands is wrong.) – Ian Jun 3 '16 at 11:48