Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Good to about 45 places; spigot algorithm

by tmoertel (Chaplain)
on Jul 21, 2004 at 18:02 UTC ( [id://376340]=note: print w/replies, xml ) Need Help??


in reply to e with continued fractions

The output of the obfuscated code seems to be good for about 45 places (at least on my box running Perl v5.8.3 built for i386-linux-thread-multi) before it differs from the reference values from the On-Line Encyclopedia of Integer Sequences.

If you want more precision, you might be interested in Unbounded Spigot Algorithms for the Digits of π by Jeremy Gibbons. It's a fun read, and you can adapt the methods presented in his paper to computing e digit by digit.

  • Comment on Good to about 45 places; spigot algorithm

Replies are listed 'Best First'.
Re: Good to about 45 places; spigot algorithm
by jdalbec (Deacon) on Jul 22, 2004 at 03:06 UTC

    The inaccuracy appears to be the result of roundoff error; use bigint; or use Math::BigInt ':constant'; (as suggested by tachyon and bageler) fixes that also.

    Also, my algorithm is streaming in Gibbons' sense. It represents the continued fraction as a composition of linear fractional transformations.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found