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

per isakson
per isakson 2012년 6월 12일
Matlab release? Mathworks ceased using Maple a few years ago.
John D'Errico
John D'Errico 2012년 6월 12일
It works fine for me, using the current release of MATLAB.
bym
bym 2012년 6월 12일
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 * ...

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2012년 6월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by