Cleve Moler- Computing pi

Hi guys,
I tried the chud_pi function in Cleve Moler's Computing Pi webpage ( http://www.mathworks.com/company/newsletters/articles/clevescorner-computing-pi.html?s_v1=37969458_1-EEGYAZ). Function reproduced below:
function P = chud_pi(d)
% CHUD_PI Chudnovsky algorithm for pi.
% chud_pi(d) produces d decimal digits.
k = sym(0);
s = sym(0);
sig = sym(1);
n = ceil(d/14);
for j = 1:n
s = s + sig * prod(3*k+1:6*k)/prod(1:k)^3 * ...
(13591409+545140134*k) / 640320^(3*k+3/2);
k = k+1;
sig = -sig;
end
S = 1/(12*s);
P = vpa(S,d);
However, I got back the error messages:
??? Error using ==> maple
Error, (in linsolve) 1st argument fails to evaluate to a matrix
Error in ==> sym.mldivide at 28
X = maple('linsolve',char(A),char(B),'''_rank''');
Error in ==> sym.mrdivide at 27
X = (A.'\B.').';
Error in ==> chud_pi at 10
s = s + sig * prod(3*k+1:6*k)/prod(1:k)^3 * ...
Any ideas?
Thanks!
-Rick

3 commentaires

per isakson
per isakson le 12 Juin 2012
Matlab release? Mathworks ceased using Maple a few years ago.
John D'Errico
John D'Errico le 12 Juin 2012
It works fine for me, using the current release of MATLAB.
bym
bym le 12 Juin 2012
errors on mine (R2008b using Mupad)
chud_pi(50)
??? Index exceeds matrix dimensions.
Error in ==> sym.mldivide at 45
X = fullshape(out(1));
Error in ==> sym.mrdivide at 34
X = (A.'\B.').';
Error in ==> chud_pi at 15
s = s + sig * prod(3*k+1:6*k)/prod(1:k)^3 * ...

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Tags

Question posée :

le 11 Juin 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by