Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Here's the Taylor series version, but it converges much less quickly and achieved less accuracy (at least for very small x):

#! perl -slw use strict; our $N //= 32; sub myExp2 { my $x = shift; my( $r, $top, $bot ) = ( 1, $x, 1 ); $r += $top / $bot, $top *= $x, $bot *= $_ for 2 .. $N; $r; } printf "%30.20g : %30.20g \n", exp( $_ ), myExp2( $_ ) #, myExp2( $_ ) + - exp( $_ ) for map log( 10**$_ ), -10 .. 10; __END__ C:\test>exp -N=227 9.9999999999999965e-011 : -9.2662709999185665e-008 1.0000000000000007e-009 : -8.6393006494132869e-009 9.999999999999982e-009 : 1.1100933780704416e-008 9.9999999999999943e-008 : 9.9888569074918635e-008 1.0000000000000004e-006 : 1.0000228347576172e-006 9.9999999999999974e-006 : 1.0000001331927489e-005 0.00010000000000000009 : 0.00010000000018884082 0.0010000000000000002 : 0.0010000000000062366 0.010000000000000005 : 0.0099999999999984095 0.10000000000000002 : 0.099999999999999867 1 : 1 10.000000000000002 : 10.000000000000004 100.00000000000004 : 100 999.99999999999977 : 999.99999999999955 10000.000000000009 : 10000.000000000007 100000.00000000001 : 100000.00000000004 999999.99999999953 : 999999.99999999977 10000000.000000006 : 10000000.000000009 100000000.00000018 : 100000000.00000022 999999999.99999928 : 999999999.99999964 10000000000.000004 : 10000000000.000002

Try going higher with the iterations and things turn to #inf.


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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (13)
    As of 2015-07-02 19:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (45 votes), past polls