%% Evaluate Double Integral in Polar Coordinates
% Define the function
% f \left( \theta,r \right) = \frac{r}{\sqrt{r \cos \theta + r \sin
% \theta} \left( 1+r \cos \theta + r \sin \theta \right) ^2}

fun = @(x,y) 1./( sqrt(x + y) .* (1 + x + y).^2 );
polarfun = @(theta,r) fun(r.*cos(theta),r.*sin(theta)).*r;

%
% Define a function for the upper limit of r.

rmax = @(theta) 1./(sin(theta) + cos(theta));

%
% Integrate over the region bounded by 0 \le \theta \le \pi/2 and 0 \le r \le r_{max}.

q = integral2(polarfun,0,pi/2,0,rmax)

% Copyright 2012 The MathWorks, Inc.