From: Bradley on
How would it be possible to compute a double integral with a variable lower limit on the inner integral but with infinite upper limits, given that quad2d does not accept infinite limits?

Specifically, the integrand is a function of a and h;

y = @(a,h) a*lognpdf(a,mu_a,sigma_a)*lognpdf(h,mu_h,sigma_h)

and the inner limits are f(h) and inf, where f is some (simple linear) function of h, and the outer limits are (b,inf). So after specifying f(h), I *would like* to write

quad2d(@(a,h) a.*lognpdf(a,mu_a,sigma_a).*lognpdf(h,mu_h,sigma_h),f(h),inf,b,inf)

but cannot because the limits must be finite.

The alternative method I've tried is to use the "int" function to do the double integral after having declared a and h as symbolic variables. (The lognormal distributions must be written out explicitly because MATLAB does not appear to accept symbolic inputs to the distribution functions.) But MATLAB cannot find an explicit integral and neither can it convert the result through the "double" function.

Thanks for any help.
From: Walter Roberson on
Bradley wrote:
> How would it be possible to compute a double integral with a variable
> lower limit on the inner integral but with infinite upper limits, given
> that quad2d does not accept infinite limits?

There's the usual trick: do a change of variables on the limit that
needs to be infinite, replacing the variable x by 1/xr . The upper limit
of infinity on x would then become a lower limit of 0 on xr.
From: Bradley on
Walter Roberson <roberson(a)hushmail.com> wrote in message <AOXDn.344587$K81.85375(a)newsfe18.iad>...
> Bradley wrote:
> > How would it be possible to compute a double integral with a variable
> > lower limit on the inner integral but with infinite upper limits, given
> > that quad2d does not accept infinite limits?
>
> There's the usual trick: do a change of variables on the limit that
> needs to be infinite, replacing the variable x by 1/xr . The upper limit
> of infinity on x would then become a lower limit of 0 on xr.


Sorry for the late reply, but thank you for this. You're right.