. Leibniz discovered that π can be approximated using the formula
π = 4 * ∑((-1)^k)/(2k+1)
(a) Write a MATLAB function pi_approx1(n) that returns the approximation of π using the first n terms of the Leibniz series above.

1 件のコメント

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 1 月 23 日
Check here
https://in.mathworks.com/matlabcentral/answers/355872-approximating-pi-using-a-series?s_tid=answers_rc1-2_p2_MLT

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

回答 (1 件)

Jos (10584)
Jos (10584) 2018 年 1 月 23 日

0 投票

My take would be to " Write a matlab function ":
function p = LeibnizPi(n)
p = 0 ;
for k = 1:n
p = p + % fill in formula here ...
end
and call it from the command line like
>> LeibnizPi(4)

カテゴリ

ヘルプ センター および File ExchangeOperating on Diagonal Matrices についてさらに検索

質問済み:

2018 年 1 月 23 日

回答済み:

2018 年 1 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by