Finding the sum of a series
Ältere Kommentare anzeigen
Hey! This is probably a "stupid" question with an easy obvious answer but I've looked at all kinds of online examples of getting the sum of a series in Matlab and just can't figure out why I'm getting the wrong result.
This is the series I'm using to approximate pi and here is my latest attempt at code for it

*I realize 10 is a really small range for m, part of what I'm doing is showing how using a smaller to larger range changes the approximation. But no matter what I plug in I haven't yet found a way to put it into the series that actually works
1 Kommentar
Paulogna
am 18 Sep. 2015
Antworten (1)
Kirby Fears
am 18 Sep. 2015
Bearbeitet: Kirby Fears
am 18 Sep. 2015
Your code works fine, but you forgot about the k=0 term in your summation. I've simplified your summation somewhat, but the only change in methodology is to add 1 inside of the sum (the k=0 term).
pi=4*(1+sum(((-1).^m)./(2*m+1)));
With m=1:100, I get the following pi value:
pi =
3.1515
Hope this helps.
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!