File Exchange

image thumbnail

Calculate PI with Gauss-Legendre

version 1.0.0.0 (709 Bytes) by Daniel Serrano
Calculate pi to "c" decimal places using the Gauss-Legendre algorithm.

0 Downloads

Updated 23 Dec 2001

No License

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.

Comments and Ratings (10)

A Millo

A Millo (view profile)

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)

A Millo

A Millo (view profile)

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

A Millo

A Millo (view profile)

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.

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.

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.

Felipe Queipo

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

fiona nxumalo

the best but please translate the language

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.

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.

MATLAB Release Compatibility
Created with R10
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor