limit to infinity of Left Riemann Sum
Mostra commenti meno recenti
Hi there,
Lets say I have created a function Sn=LeftRiemannSum(f,left,right,N) ,that computes the left riemann sum over the interval left to right with N subdomains.i.e.:
Sn=sum(f(xi)*h) for all subdomains i=0 to N-1. f is my function and xi=left+i*h , so the input arguments left=x0 and right=xN.
Let f be my anonymous function (ex f=@(x)(x.*log(1+x)) .
I also estimated the Sn for varying N, from N=10 to 100000.
Now, I simply want to compute the value of the series Sn when N -> infinity. Inside the function I have a for loop [ for i=0:(N-1)] so I will have endless loop ..
Can I pass the function somehow to the 'limit' command? Any clues?
Thanx!
PS: The main part of the code of my function LeftRiemann Sum is the following:
if true
for i=0:(N-1)
x=x0+i.*h;
y=f(x);
A=y.*h;
S=S+A
end
Sn=S
end
Risposta accettata
Più risposte (1)
Torsten
il 3 Nov 2014
0 voti
Use
S_inf = integral(f,left,right)
to get the limit.
Best wishes
Torsten.
3 Commenti
Zoltán Csáti
il 3 Nov 2014
Yes, it is straightforward. But I think it is homework problem for better understanding of limit and MATLAB.
Stelina
il 3 Nov 2014
Torsten
il 3 Nov 2014
If you use "int", MATLAB tries to analytically determine a function F such that F'=f.
In your case, F(x)=0.25*(2*(x^2-1)*log(1+x)-(x-2)*x).
Thus in the limit you get F(1)-F(0)=0.25.
Best wishes
Torsten.
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!