improper integral
Show older comments
Hi!!I need help in the calculation of the integral of the function below
function out = fun(u,a,b)
out = exp(-a.* exp(2.*u)).*exp(-(u + b.^2).^2./2.*b.^2)/...
(sqrt(2.*pi.*b.^2));
end
a=0; b=1; *quad('fun',-Inf,Inf,[],[],a,b);
Is there any idea? where is the mistake?
3 Comments
Andrew Newell
on 5 Apr 2011
What version of MATLAB are you using? The syntax you are using for QUAD is outdated.
Asatur Khurshudyan
on 30 Dec 2012
I guess you have to calculate the principal value (by Cauchy) of that integral, otherwise you`ll have Nan`s or Infinity`s. I also have such a problem with 3D plotting improper integrals with infinite upper limit. Have anyone did something like that?
Roger Stafford
on 30 Dec 2012
For a = 0 this becomes just the integral of a normal distribution density function over its full range, and of course it must then be equal to 1. It is when a is greater than zero that the integral becomes more interesting. For negative a the integral is divergent.
Accepted Answer
More Answers (1)
Matt Fig
on 5 Apr 2011
quadgk(@(x) fun(x,0,1),-inf,inf) % 0 is a, 1 is b.
But for a = 0, b = 1, we encounter an infinite number or nan. Are these numbers correct? If so, you could try this:
quadgk(@(x) fun(x,0,1),-10,10) % Exponentially decreasing values.
Or look at QUADL.
quadl(@(x) fun(x,0,1),-200,200,1e-15)
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!