Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^7: Euler's identity in Raku

by syphilis (Archbishop)
on Jun 08, 2021 at 01:32 UTC ( #11133641=note: print w/replies, xml ) Need Help??

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 ?


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11133641]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2023-09-28 11:47 GMT
Find Nodes?
    Voting Booth?

    No recent polls found