How to verify Eulers Theory

3 ビュー (過去 30 日間)
Chris
Chris 2013 年 6 月 10 日
The mathematician Euler proved the following:
pi^2/6= 1+1/4+1/9+1/16 ...
Rather than finding a mathematical proof for this, verify whether the conjecture seems to be true or not by writing a loop until the sum is close to pi^2/6
I have trouble understanding loops. help please!

採用された回答

Julius
Julius 2013 年 6 月 10 日
sum = 0;
threshold = 1e-6;
for ii = 1 : 1 : 100000
sum = sum + 1/ii^2;
if abs(sum - pi^2/6) <= threshold
break;
end
end
disp(sprintf('%s iterations needed to approach pi^2/6',num2str(ii)));
  2 件のコメント
Chris
Chris 2013 年 6 月 10 日
could you explain what you did there? what exactly is the threshold and what did you do in line 5?
Walter Roberson
Walter Roberson 2013 年 6 月 10 日
Providing complete homework solutions is not advised.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by