integrate function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
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
0 commentaires
Plus de réponses (0)
Voir également
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!