Terribly in Need, Matlab... - Sajha Mobile
SAJHA MOBILE
Terribly in Need, Matlab...
Posts 4 · Viewed 5485 · Go to Last Post
guchcha chor
· Snapshot
Like · Likedby · 0
Hello MatLab /C++ gurus out there,
I tried to do it.. I couldn't. Please help me....
F22
· Snapshot
Like · Liked by · 0
Its in no way complete and hasn't been verified but should be enough of a pointer to get you in the right track if using Matlab:

clear
clc
N = 2;
e = 100;
e1 = 10^-5;
piii(1)= 1/0.75;
while e >= e1
pii=0;
for k=1:N
piii1= ((-1)^(k+1))/(0.5*k-0.25);
pii=piii1+pii;
end
piii(N)=pii;
e=abs(piii(N)-piii(N-1))/piii(N-1);
N=N+1;
end

On a second note you could tell the Prof., " I can use pi function of Matlab to get the damn number, why worry about doing the homework"
santosh1984
· Snapshot
Like · Liked by · 0
Here is the code. It is perfectly running and does converge to 3.1416 for e=10^-8 with N= 63661979. Do the same for 10^-1 thru 10^-8. Hope you know how to make plots after this. Make sure the name of mat-file is pii.m and enjoy!!!!

function pii


clc


N=2;


pii=((-1)^2)/(0.5*1-0.25);


e=1;


 


while e>=10^-8;


    pii_old=pii;


    k=N;


    pii1= ((-1)^(k+1))/(0.5*k-0.25);


    N=N+1;


    pii=pii_old+pii1;


    e=abs(pii-pii_old)/pii_old;


end


pii_old


pii


N


e


guchcha chor
· Snapshot
Like · Liked by · 0
Thank you very much F22 and Santosh1984. I was dying to get the right answer...
Thank you
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 1 · Viewed 64
· Posts 1 · Viewed 70
· Posts 11 · Viewed 965 · Likes 1
· Posts 1 · Viewed 60
· Posts 1 · Viewed 65
· Posts 4 · Viewed 322
· Posts 9 · Viewed 1356
· Posts 1 · Viewed 111
· Posts 1 · Viewed 113
· Posts 1 · Viewed 86



Your Banner Here
Travel Partners
Travel House Nepal