Re: no tests for trigonometric functions? need help / hints how to adapt tests for gnumeric 'long' version,



On Sat, May 28, 2022 at 12:43:45AM -0700, John Denker via gnumeric-list wrote:

In any serious application it would be better to use tanpi(0.5)
which produces #NUM! which is IMHO the right answer. Note that
cospi(0.5) is exactly zero, as it should be.

Can you point me at the source code for cospi please?


OTOH if for some reason we can't do that, the value of pi()/2
is 1.5707963267948966192313217 (to high accuracy). However an
IEEE double cannot represent that; the closest it can come is
1.5707963267948965579989817

If you take the tangent of that (to high accuracy) you get
16331239353195369.755 for which the closest IEEE double is
16331239353195370. So I don't consider that a failure.

Using Python 3.10 on Linux, I get tan(pi/2) as

1.633123935319537e+16

which matches your result.

tan() produces an output that is grossly
nonlinear (indeed wildly non-monotonic).

Why is that? The mathematical function tan is monotonically increasing 
in the range [0, π/2). Shouldn't tan() be the same?

Using Python (as above), and starting at pi/2 and working backwards, I 
was unable to find any non-monotonic behaviour in tan() in the range
1.5707963260321207 through pi/2. (That's 3435237 doubles.)

Obviously this result can depend on the quality of your platform's maths 
library. Do you have any examples of where it fails?


Thanks,


-- 
Steve


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]