MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Printing digits of Pi

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46710] Re: Printing digits of Pi
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Tue, 2 Mar 2004 19:10:08 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <c215vo$8gv$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <c215vo$8gv$1 at smc.vnet.net>, cmduncan at mines.edu wrote:

> Hello!  I am having an issue with printing the digits of Pi that mathematica 
> calculates.  I can get a screen print of the digits to about 20 million but 
> interested in ~32 million digits. 

You really are printing out 20 million digits? Why are you doing this? I 
mean, why not compute and save the digits and then you can work with any 
block of digits you want.

Also, I wonder what is the application. You are probably aware of 

  http://mathworld.wolfram.com/PiFormulas.html

and

 http://www.sciencenews.org/pages/sn_arc98/2_28_98/mathland.htm

> Using the N command, I can get Mathematica 
> to determine the ~32 million digits but not print them to the screen.  I get 
> a message "Out of Memory".  Running at 4GB of physical memory should be 
> sufficient?  Right?  

There are (sometimes very large) overheads in formatting output. 
However, exceeding 4GB seems a little extreme. 

Using MemoryInUse (which gives the number of bytes currently being used 
to store all data in the curren session -- which does not tell the full 
story) we see that about 1 extra MByte is required to print out 1 
million digits.

   mem = MemoryInUse[];

   N[Pi, 10^6]
   <  output omitted >

   MemoryInUse[] - mem
   3579624

   mem = MemoryInUse[];

   N[Pi, 10^6]; 

   MemoryInUse[] - mem
   2579496

Depending on your operating system, there are (external) ways to see how 
much (total) memory Mathematica is using for computation, formatting, 
and output.

> Is there a way for Mathematica to create an output file 
> to print the digits for a given amount (i.e. 10 million versus 100 million)? 

You can easily create output files: lookup Put, Write, and Export. You 
can also work within Mathematica. For example, here is a way to examine 
the 1000 digits starting at the millionth digit after the decimal point:

  pi = RealDigits[N[Pi, 32 10^6]]; 
  
  pi[[1,Range[10^6+1,10^6+10^3]]]

> Is there a way to allow Mathematica to utilitize more physical memory than 
> defaulted?  

Surely this is an operating system issue, not a Mathematica issue?

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: How to calculate the derivative of matrix w.r.t another matrix?
  • Next by Date: Mathematica to Word
  • Previous by thread: Re: Printing digits of Pi
  • Next by thread: Re: need help with writing algorithm for polynomial gcd!