Cleve Moler- Computing pi
Mostrar comentarios más antiguos
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 comentarios
per isakson
el 12 de Jun. de 2012
Matlab release? Mathworks ceased using Maple a few years ago.
John D'Errico
el 12 de Jun. de 2012
It works fine for me, using the current release of MATLAB.
bym
el 12 de Jun. de 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 * ...
Respuestas (0)
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!