On Jan 6, 2010, at 4:37 PM, Florent Hivert wrote:
Hi there,
According to this:
http://news.bbc.co.uk/1/hi/technology/8442255.stm
someone has just computed pi to 2.7 trillion digits on a "desktop
computer". The article does not mention software.
How well would Sage do?
I don't know of any "off the shelf" programs that provide efficient on-
disk integer arithmetic operations. I find this interesting because it
is essentially the same problem we were trying to solve
(multiplication only) for the congruent number computation--minimizing
the (disk) I/O.
I once tried to find the shortest program which compute pi in sage,
with the
requirement that your are not allowed to use any precomputed value
(except
perhaps a number of iterations for the required precision). I came
up with the
following incredibly simple program which use only additions and
memory except
a multiplication and a division at the end. Moreover the convergence
is
reasonably fast (close to one decimal every other iterations). Note
that the
following code is meant to be as short as possible, it could be easily
optimized:
sage: nLoop = 60
sage: l = [1]
sage: for n in range(2, nLoop):
... ll = [sum(l[:i]) for i in range(n-1, -1, -1)]
... l = ll
...
sage: RealField(100)(2*ll[0]*len(ll)/sum(ll))
3.1415926535897932384626433830
I'd be interested if someone knows a short pythonic way to write the
line
ll = [sum(l[:i]) for i in range(n-1, -1, -1)]
without recomputing the sums.
How about
sage: n = 60
sage: l = [1]
sage: for t in range(2, n):
... ll = [0]
... for a in l: ll.append(ll[-1] + a)
... l = ll[::-1]
- Robert
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org