Cosine Function Returns Wrong Answer!
wrote...
Gnumeric may do a better job with Gammaln, but it gives exactly
the same results as Excel with the Cos function.
....
Unavoidable when arguments are in radians. Integer degrees are
rational fractions of PI in radians, and since PI is transcendental,
there's no hope for exact finite representation in any radix. And it's
much less reliable to try to special-case fractional values than
integer values.
FWIW, both SIN and COS get flaky near multiples of PI/2 where they
should be zero, but the other function gives +/-1. So if a few more
functions would be acceptable,
COS(x):
=IF(ABS(MOD(DEGREES(x),180)-90)0.5,COS(x),
SIGN(COS(x))*SQRT(1-SIN(x)^2))
SIN(x):
=IF(ABS(MOD(DEGREES(x)-90,180)-90)0.5,SIN(x),
SIGN(SIN(x))*SQRT(1-COS(x)^2))
|