In the first part of the code, plot the approximation of π as a function of N, the number of terms in the series, for N between 1 and 15. The function to be used is (pi^2-8)/1​6=Summatio​n(n=1:N)(1​/((2n-1)^2​*(2n+1)^2)​)

I basically do not have any idea how to start. any help would be appreciated.

1 件のコメント

How would you calculate the approximation of Pi if N is 1? How would you calculate it if N is 2? How would you plot the approximations?

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

回答 (1 件)

Jie
Jie 2013 年 10 月 26 日
編集済み: Jie 2013 年 10 月 26 日
wish this could help.
% the formula could be rewrote as pi=sqrt(sum(16/((2*n-1)^2*(2*n+1)^2)+8)
N=[1:15, 20, 30];
my_pi=[];
for n=N
x=1:n;
tmp=sqrt(sum(16./((2*x-1).^2.*(2*x+1).^2))+8);
my_pi=[my_pi, tmp];
end
figure;h=axes('color',[.5,.5,.9],'fontangle','italic','fontname','Times New Roman','xcolor',[0,0,.7]);hold on; grid on,
plot(N,my_pi)
title('approcimation of \pi')

2 件のコメント

Jie, please do not give complete solutions to homework assignments.
Jie
Jie 2013 年 10 月 31 日
Sorry Walter, I did not know it was homework...

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

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

質問済み:

2013 年 10 月 26 日

コメント済み:

Jie
2013 年 10 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by