Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: [OT] Function to do x**y for |y|<1 w/o ** operator.

by BrowserUk (Pope)
on Feb 19, 2013 at 19:47 UTC ( #1019650=note: print w/ replies, xml ) Need Help??


in reply to Re^2: [OT] Function to do x**y for |y|<1 w/o ** operator.
in thread [OT] Function to do x**y for |y|<1 w/o ** operator.

If you don't need fast or accurate:

#! perl -slw use strict; sub myExp{ my $e = 1 + ( shift() / 10000000 ); my $r = $e; $r *= $e for 2 .. 10000000; $r; } printf "%30.20g : %30.20g\n", exp( $_ ), myExp( $_ ) for map log( 10**$_ ), -10 .. 10; __END__ C:\test>exp 9.9999999999999965e-011 : 9.9997349036884958e-011 1.0000000000000007e-009 : 9.9997852777366009e-010 9.999999999999982e-009 : 9.9998303391048947e-009 9.9999999999999943e-008 : 9.9998700988200641e-008 1.0000000000000004e-006 : 9.9999045679358269e-007 9.9999999999999974e-006 : 9.9999337241854084e-006 0.00010000000000000009 : 9.9999575897369183e-005 0.0010000000000000002 : 0.00099999761423453593 0.010000000000000005 : 0.0099999893930861859 0.10000000000000002 : 0.099999973530420908 1 : 1 10.000000000000002 : 9.9999973561653093 100.00000000000004 : 99.999893882330838 999.99999999999977 : 999.99761406302275 10000.000000000009 : 9999.9575911775646 100000.00000000001 : 99999.337176962814 999999.99999999953 : 999990.45646420098 10000000.000000006 : 9999870.1098560225 100000000.00000018 : 99998303.311974689 999999999.99999928 : 999978527.31280696 10000000000.000004 : 9999734913.5273266

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^3: [OT] Function to do x**y for |y|<1 w/o ** operator.
Download Code
Re^4: [OT] Function to do x**y for |y|<1 w/o ** operator.
by swampyankee (Parson) on Feb 19, 2013 at 21:44 UTC

    Can I post a link to your code? It's on cosmoquest.org, which used to be the Bad Astronomy & Universe Today forum.


    Information about American English usage here and here. Floating point issues? Please read this before posting. — emc

      Sure.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (16)
As of 2014-12-18 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (59 votes), past polls