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

Re^2: Irrational numbers

by grondilu (Friar)
on Dec 17, 2012 at 22:20 UTC ( [id://1009251]=note: print w/replies, xml ) Need Help??


in reply to Re: Irrational numbers
in thread Irrational numbers

I'm afraid you missed the point I was trying to make. Pi could be represented as a lazy yet infinite list of rationals converging towards pi. So could any irrational numbers, including those who are transcendental.

Representing real numbers seems like a very natural use case of lazy lists.

Replies are listed 'Best First'.
Re^3: Irrational numbers
by tobyink (Canon) on Dec 18, 2012 at 08:35 UTC

    Let's say you want pi to a million digits. Using a lazy list populated by the Machin's formula will take you several hours of calculation. But a hard-coded decimal representation of a million digits will take less than a megabyte of memory/disk space, even if inefficiently stored as one digit per byte and can be retrieved virtually instantly.

    In practice, there's little reason to need that sort of precision. A 64-bit float has about 20 decimal digits of precision, which is enough to calculate the circumference of the Earth to less than a hair's breadth. Apparently 61 digits of pi is enough to calculate the circumference of the observable universe to within one Planck length.

    In practice, floats are simply good enough for most purposes.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

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

    No recent polls found