calculating $\sin x$ in floating point arithmetic

303 Views Asked by At

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?

1

There are 1 best solutions below

1
On

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.