pi as a sum

조회 수: 4 (최근 30일)
Alex Perisanidis
Alex Perisanidis 2018년 1월 23일
답변: Jos (10584) 2018년 1월 23일
. 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일
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)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by