OT sine recursion (was: Re: Parsing infinite streams style)
Tue Mar 9 12:37:20 CET 2004
On Tue, Mar 09, 2004 at 11:16:27AM +0100, Joe Armstrong wrote:
> I learnt this in school, but it was called something different.
> I learnt this:
> sin(2A) = 2sin(A)cos(A)
> cos(2A) = 1 - 2sin^(X)
cos(2A) = 1 - 2sin^2(A)
> sin(0) = 0
> cos(0) = 1
> So to compute sin(X) we have to compute sin(X/2) and cos(X/2)
> and to compute cos(X) we have to compute sin(X/2)
> this is the recursive case where the argument gets smaller.
> The base case is sin(0) = 0 or cos(0) = 1 (actually it's a small
> angle not zero)
Ah, but then you will have to control the error. Actually, this will
not work, because the above equations are also satisfied by
sin(x) = 0, cos(x) = 1, for all x.
To get a (numerically) working recursion you will have to replace
`sin(x)=0 for small x' by `sin x \approx x' for small x. I have not
checked the numerics of this one, though.
To all readers of Irvine Welsh: ``Smart-alec is a posh word for a
...'' Stopping here to avoid spam filters :-)
Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin
PGP/GPG key on the pgp.net key servers,
fingerprint on my home page.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the erlang-questions