I don't think quad ever allowed infinite limits. quadgk does. The answer you need depends on how old your MATLAB version is. I am going to express an answer in more recent syntax. If you try
a=0; b=1;
fun = @(u) exp(-a.* exp(2.*u)).*exp(-(u + b.^2).^2./2.*b.^2)/...
(sqrt(2.*pi.*b.^2));
quad(fun,-Inf,Inf)
then you get this message:
Warning: Infinite or Not-a-Number function value encountered.
and the answer is NaN. The likely reason is that there is underflow in these exponential expressions:
However, if you plot this function, you can see that this function approaches zero very rapidly. For example,
Therefore, you can do this calculation:
quadl(fun,-100,100)
ans =
1.0000
This is 1 to an accuracy of about 10^-8.
Best Answer