double integral infinite limits

is there any idea how can i calculate the integral of this function with infinite limits -00,+00
function Fr = int_frustration_function2(x,Kt,i)
Fr = dblquad(@(v,u)fun2(v,u,x,Kt,i),-Inf,Inf,-Inf,Inf);
end
where for fun2
function fun2 = fun2(v,u,x,Kt,i)
global SNR sigma_a q
k= 1./(sqrt(2.*pi.*((sigma_a./q).^(2))));
temp1=((log(v)+((sigma_a./q).^(2))).^(2)); temp2=(2.*((sigma_a./q).^(2))); temp3=exp(-temp1./temp2);
temp4=((B1N(Kt,0,u,i).*SNR.*x)./4);
fun2 = k.*exp(-(u.^2)).*(besseli(0,0).*exp(-temp4.*(v.^(2))).*temp3);%
end
please help!!!

 Accepted Answer

This is easy to modify if you want c and/or d to be a function handle, like for QUAD2D. Also, it should be easy to add tolerances or whatever options you would like.
function y = mydblquad(fun,a,b,c,d)
% Double integral using QUADGK.
innerintegral = @(x)arrayfun( ...
@(xi,y1i,y2i)quadgk(@(y)fun(xi*ones(size(y)),y),y1i,y2i), ...
x,c*ones(size(x)),d*ones(size(x)));
y = quadgk(innerintegral,a,b);
>> mydblquad(@(x,y)1./(1+x.^4+y.^4),-inf,inf,-inf,inf)
ans =
5.824747385361142

6 Comments

my function is fun2(v,u,x,Kt,i) and i want to integrate it for the variables v,u from -Inf,Inf both of them..
How can i do it in the way you've sai above..Its a bit complicated for me because i 'm beginner..
Use Mike's mydblquad function, and call it as
mydblquad(@(v,u) fun2(v,u,x,Kt,i),-inf,inf,-inf,inf)
thanks a lot! in case i want to calculate the integral only inegrationg the variable v from -inf,Inf???
could you suggest me the best way???
thanks
If u appears in the calculation of fun2(v,u,x,Kt,i) then integrating only along v would require an expression in u as the output. That would require symbolic integration rather than numeric integration. Symbolic integration is possible with the Symbolic Toolbox using the int() function.
Gautam
Gautam on 10 Aug 2012
Edited: Gautam on 10 Aug 2012
This was a very helpful post as I was wondering how I would achieve a double integration where the limits could be Inf. Following on Mike's post, I just wanted to confirm that the following modification to Mike's code to handle the case where the upper limit of the inner integral (the integration variable being y) is a function of x:
function y = mydblquad(fun,a,b,c,d) innerintegral = @(x) arrayfun(... @(xi,yli,y2i)quadgk(@(y)fun(xi*ones(size(y)),y),yli,y2i),... x,c*ones(size(x)),feval(d,x)); y = quadgk(innerintegral,a,b);
I tried the above and it seems to work fine. Any comments would be appreciated.
- Gautam
One can indeed extend that method to use arbitrary lower and upper limit functions on the inner integral. I should note that the answer I gave above is somewhat old now. If you have the 2012a release of MATLAB you can use INTEGRAL2 "out of the box".

Sign in to comment.

More Answers (1)

the cyclist
the cyclist on 25 Aug 2011
There is some discussion here that may help you:
Be sure to look at the comments, too, particular the ones from Walter.

Community Treasure Hunt

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

Start Hunting!