3.5

3.5 | 8 ratings Rate this file 6 Downloads (last 30 days) File Size: 1.01 KB File ID: #1202

Calculate PI with Gauss-Legendre

by Daniel Serrano

 

23 Dec 2001

Calculate pi to "c" decimal places using the Gauss-Legendre algorithm.

| Watch this File

File Information
Description

Calculate pi using the Gaussian-Legendre algorithm. The function PIGL.M produces an ASCII file containing the number of decimals requested. The maximum number depends on free disk space and the RAM available.

Required Products Symbolic Math Toolbox
MATLAB release MATLAB 5.2 (R10)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
29 Jan 2002 Vassili Pastushenko

I doubt that the program works properly above 16 digits of precision standard for
Matlab, because the calculations of a,b , t and p are made with standard accuracy.

29 Jan 2002 Vassili Pastushenko

I doubt that the program works properly above 16 digits of precision standard for
Matlab, because the calculations of a,b , t and p are made with standard accuracy.
 In addition, there is no code for function VPA.

27 Mar 2004 fiona nxumalo

the best but please translate the language

31 Mar 2004 Felipe Queipo

Tranquilo chaval que eres mu bueno.... y al otro ni caso

02 Aug 2004 Boris Malutov

Comment to comment number 3 and 4 - it does work much further than the first 16 digits surprisingly - I checked it up to the first 60 digits. Vassili - if you say something - it might be worthwhile to check that, you lazy bum.

09 Aug 2005 Jonathon Smith

It should be noted that this function requires the Matlab Symbolic Math Toolbox. The 'vpa' function refers to the Variable Precision Arithmetic functionality there.

26 Feb 2006 John D'Errico

Vassili is absolutely correct here. Computation in 16 digit arithmetic, then calling vpa at the very end will NOT generate 60 CORRECT digits of precision. That claim is ridiculous. Boris is kidding himself, as is the author. My statement would be different had the computations been done from the start with VPA.

28 Oct 2009 A Millo  
28 Oct 2009 A Millo

I thoght that Vassili and John were right but I checked.
It works very well, even to 100000 digits.

29 Oct 2009 A Millo

Ha, now I get it.
vpa function is a smart one, it regocnize pi by the first 16 digits and calculate pi to whatever digits you want.
try this:
my_pi = 3.141592653589793;
now compare:
vpa(pi,50)
and
vpa(my_pi)

also try
vpa(my_pi+1,50)

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
approximation Daniel Serrano 22 Oct 2008 06:40:02
interpolation Daniel Serrano 22 Oct 2008 06:40:02
gausslegendre Daniel Serrano 22 Oct 2008 06:40:02
pi calculation Daniel Serrano 22 Oct 2008 06:40:02
mathematics Daniel Serrano 22 Oct 2008 06:40:02

Contact us at files@mathworks.com