plotting libnez taylor series
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
hi there i have tried to plot libnez's taylor series as a line graph but it will not show up. correctly it only plots the same reslut value for all terms given. I want to plot 20 terms but am have difficultly doing so. Can anyone help me out?
the function is : pi= 4- 4/3+ 4/5- 4/7....
This is what I have so far thanks to Youssef KHMOU ...
value= input('how many values would you like:');
result=zeros(20,1);
signchange= 1;
result(1)=4;
for k= 1:value
term = signchange * 4/(2*k-1);
result(k+1) =result(k)+ term;
signchange = signchange * (-1) ;
end
plot(result)
the only problem is that I want it to plot somehow from terms 0:20
2 Kommentare
Youssef Khmou
am 11 Feb. 2013
write the index form of the series : per example :
N
-
\ n*(n+1)
/ --------
- (n+3)* n
n=0
Akzeptierte Antwort
Youssef Khmou
am 11 Feb. 2013
esult=0.0 ;
signchange= 1;
for k = 1:1:value
term = signchange * 4/(2*k-1);
result = (result + term)
signchange = signchange * -1 ;
x=1:1: value;
y=result;
plot(x,y,'ok'); hold on end
hold off
2 Kommentare
Youssef Khmou
am 11 Feb. 2013
yes, but you have to specify your question, Taylor LEIBNIZ series is general form, you want apply the formula on what function : per example :
sin(x) = Sum (n=0, infinity) (-1)^n * (x^2n+1) / (2n+1)!
, take a look at the answer below .
Weitere Antworten (1)
Youssef Khmou
am 11 Feb. 2013
Bearbeitet: Youssef Khmou
am 11 Feb. 2013
AngelsaAtWar :
You have to re-post the question with the function you want use and give a general index forumla :
here is you code with 400 iterations :
value=400;
result=zeros(40,1);
signchange= 1;
result(1)=4;
for k = 1:value-1
term = signchange * 4/(2*k-1);
result(k+1) =result(k)+ term;
signchange = signchange * (-1) ;
end
plot(result)
2 Kommentare
Youssef Khmou
am 12 Feb. 2013
Bearbeitet: Youssef Khmou
am 12 Feb. 2013
ok,
what about the last code, is that what you want ( damped sinusoidal function like) ?
if you only want to plot 20, then give 20 as input to value . Or can you give 100000 , but plot only 20 or truncate other elements starting from 21 to end , you have may options,
plot(result(1:20)) % if you gave more than 20 to values or :
result(21:end)=[], plot(result)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!