Trying to make symsum work.
古いコメントを表示
I am having problems getting symsum to calculate the following sumation within this equation:

I am using the following code to get pi:
function piram
%approximates and prints pi with Ramanujan's formula
%called as piram or piram()
%doesn't return a value, but a print
k=sym('k');
sumpart=symsum((factorial(4*k)*(1103+26390*k))/(((factorial(k))^4)*(396^(4*k))),k,0,inf);
inverted=sumpart*((2*sqrt(2))/9801);
approxpi=1/inverted;
fprintf('Using Ramanujan''s formula, a good approximation is %.6f\n',approxpi)
end
Can anyone help with this?
採用された回答
その他の回答 (1 件)
madhan ravi
2018 年 11 月 27 日
function piram
syms k
sumpart=symsum((factorial(4*k)*(1103+26390*k))/(((factorial(k))^4)*(396^(4*k))),k,0,inf);
inverted=sumpart*((2*sqrt(2))/9801);
approxpi=1/inverted;
fprintf('Using Ramanujan''s formula, a good approximation is %.6f\n',approxpi)
end
15 件のコメント
Jacob Oleshchuk
2018 年 11 月 27 日
Jacob Oleshchuk
2018 年 11 月 27 日
madhan ravi
2018 年 11 月 27 日
編集済み: madhan ravi
2018 年 11 月 27 日
clear all at the very beginning of the code , I got the answer in terms of pi as a decimal value , see attached picture

Jacob Oleshchuk
2018 年 11 月 27 日
Jacob Oleshchuk
2018 年 11 月 27 日
編集済み: Jacob Oleshchuk
2018 年 11 月 27 日
madhan ravi
2018 年 11 月 27 日
編集済み: madhan ravi
2018 年 11 月 27 日
I didn‘t have any trouble getting the result after running your code , ok type whos k in command window and paste the result here. or try
syms k positive
leaving the rest of the code unchanged
Jacob Oleshchuk
2018 年 11 月 27 日
madhan ravi
2018 年 11 月 27 日
I have no clue what mistake you did
Jacob Oleshchuk
2018 年 11 月 27 日
Jacob Oleshchuk
2018 年 11 月 27 日
madhan ravi
2018 年 11 月 27 日
whos factorial
which -all factorial
in command window what does it show?
Jacob Oleshchuk
2018 年 11 月 27 日
madhan ravi
2018 年 11 月 27 日
Did you try
syms k positive %?
Walter Roberson
2018 年 11 月 27 日
What shows up for
which factorial(k)
Question: is it possible that you have Maple installed but not the MATLAB Symbolic Toolbox ?
madhan ravi
2018 年 11 月 27 日
@Jacob please respond to sir Walters question
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!