integrate function

1 vue (au cours des 30 derniers jours)
Raphael
Raphael le 5 Juin 2012
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.

Réponse acceptée

Mike Hosea
Mike Hosea le 6 Juin 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

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by