Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: cos (100000000.0)

by bart (Canon)
on Sep 02, 2009 at 07:59 UTC ( [id://792839]=note: print w/replies, xml ) Need Help??


in reply to Re: cos (100000000.0)
in thread cos (100000000.0)

Why are you taking the cosine of 100 million radians? I cannot think of any valid reason for doing that.

Amen to that.

To the OP: trigonometric functions are about the most unreliable calculations that you can do on a computer. I think it is just not reasonable to expect very precise results, for such a huge parameter value. Actually, the difference in results between the different implementations is a lot smaller, than I had anticipated.

Floating point in Perl has about 15 significant digits. For a function like cos, the digits before the decimal point don't really matter, as you may just as well use the parameter value modulo 2*PI, and (ideally) expect the same outcome. That means that for this parameter, with 8 digits wasted, you have about 6-7 significant digits left. That is how close you may expect the result of the calculation of cos to be.

I am guessing you just made that parameter up, as a silly test.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-26 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found