4 ms·
sine is easy because the series is globally convergent and fast converging
by paulpauper 3y ago
sine is easy because the series is globally convergent and fast converging
- ot 3y agoDid you read the article? It is specifically about how the series looks simple, but the error is actually very bad if you do things naively.
- paulpauper 3y agoThat still makes it easier compared to computing constants in which the series are not globally convergent, like inverse trig functions. Obviously, you would have to break it apart to speed convergence.
- zgs 3y agoIt would also be extremely inaccurate. The x^n numerators grow very quickly and digits get lost because unlimited precision isn't available. Likewise, the n! denominators also grow rapidly. Then the series is alternating which means cancellation is happening for every added term. If you don't believe me try for x=10.
- deleted 3y ago[deleted]
- planede 3y agoYou need around 26 terms for x=10 if you do it without reduction and you want an accuratish result for double precision. You wouldn't evaluate the terms naively from left-to-right. x - x^3/3! + x^5/5! - ... = x * (1 - x^2/(2*3) * (1 - x^2/(4*5) * ... ) ) I just checked in python and you get a result that is around 1000*machine epsilon off. Not great, not terrible.