integrate function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hey,
i want to integrate the function di on an interval from 1 to infinity. di=(sinh((b.*x)./a)./sinh((pi.*x)./a));
However while using quadgk matlab returns the following error code: Warning: Infinite or Not-a-Number value encountered.
Is there a possibility to change to change the code so maybe that it lowers accuracy however a result is obtained? Or is there another function that evaluates integrals up to infinity?
Thanks in advance.
0 Kommentare
Akzeptierte Antwort
Mike Hosea
am 6 Jun. 2012
The problem has nothing to do with the integrator, rather with the way you have written the integrand:
>> a = 1; b = 1;
>> di= @(x)(sinh((b.*x)./a)./sinh((pi.*x)./a));
>> di(1000)
ans =
NaN
You're giving the integrator NaN values, so there's not much it, or any other code, can do with that. Try multiplying your integrand numerator and denominator by exp(-pi*x) and simplifying. I get
>> dj= @(x)(exp((b-pi)*x) - exp(-(b+pi)*x))./(1-exp(-2*pi*x))
dj =
@(x)(exp((b-pi)*x)-exp(-(b+pi)*x))./(1-exp(-2*pi*x))
>> dj(1000)
ans =
0
>> quadgk(dj,1,inf)
ans =
0.051035297097439
-- Mike
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation 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!