http://qs1969.pair.com?node_id=11133641


in reply to Re^6: Euler's identity in Raku
in thread Euler's identity in Raku

There may be a world where a language can do identity / symbol math ...

WRT sin() and cos(), I believe it's actually fairly simple to have them return the exact rational result when applicable - as, UIM, this is only ever applicable for arguments 0, pi/6 (sin only), pi/3 (cos only), pi/2 and pi.
These cases can be hard coded to return the exact correct value. (Of course, that coding has to also allow for integer multiples of those values.)
It also calls for a function that takes a rational (p/q) value as it's arg.

So, instead of calling sin(1 * 3.1415926535897931) and getting a non-zero result, we call (say) sinpi(1) and have it return the hard coded result of zero.
If the arg given to our sinpi() function is not one of these "special values" (ie 0, 1/6, 1/3, 1/2 or 1 - or a multiple thereof), then sinpi($arg) simply returns sin($arg * 3.1415926535897931)

... - indeed there are cpan packages for this kind of thing

Do you know if there are any there that have sin/cos implementations that return exact results for all of those special values ?

Cheers,
Rob