Calculating double integral of two variable

18 views (last 30 days)
I am having some issues calculation a double integral with two variable. my function F= {{sinc^2(X)sinc^2(Y)} *{sin^2(phi)+cos^2(theta)cos^2(phi)}}(sin(theta)).
I define X=(pi/2).*sin(theta).*cos(phi) and Y=(pi/2).*sin(theta).*sin(phi); and theta=[0 pi/2]; phi=[0 2*pi].
So, I have started
syms X Y theta phi
theta=linspace(0,pi/2);
phi=linspace(0,2*pi);
X=(pi/2).*sin(theta).*cos(phi);
Y=(pi/2).*sin(theta).*sin(phi);
func1=(sinc(X/pi).*sinc(Y/pi)).^2;
func2={(sin(theta))^2}+{cos(theta)cos(phi)}^2;
func=func1*func2;
func3=sin(theta);
Function1=vpa(int(func,0,2*pi),5)*vpa(int(func3,0,pi/2),5)
But I have also tried to rewrite
syms X Y theta phi
X=(pi/2).*sin(theta).*cos(phi);
Y=(pi/2).*sin(theta).*sin(phi);
Function1=@(theta,phi) ((sinc(X/pi).*sinc(Y/pi))^2 *((sin(phi))^2+(cos(theta)*cos(phi))^2))*(sin(theta));
E=integral2(Function1,0,pi/2,0,2*pi)

Answers (1)

Devineni Aslesha
Devineni Aslesha on 22 Jun 2020
Edited: Devineni Aslesha on 22 Jun 2020
Hi Ismael,
To calculate the double integral of a two variable function, integral2 accepts only numeric variables. So, the entire function with two variable is defined as a single inline executable expression (anonymous function handles) as shown below.
Function1 = @(theta,phi) (((sinc((pi/2).*sin(theta).*cos(phi)).*sinc((pi/2).*sin(theta).*sin(phi))).^2).*((sin(phi)).^2+(cos(theta).*cos(phi)).^2)).*(sin(theta));
E = integral2(Function1,0,pi/2,0,2*pi)
For more information, refer the following link
  2 Comments
madhan ravi
madhan ravi on 22 Jun 2020
The first statement contradicts the fact that int(...) with two calls exist if there’s an explicit solution.
Devineni Aslesha
Devineni Aslesha on 22 Jun 2020
Edited: Devineni Aslesha on 22 Jun 2020
int can accept both numeric and symbolic variables, whereas integral2 accepts only numeric variables as integral2 solves the integral numerically. Also, thanks for pointing that out, I can edit the answer specific to integral2.

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!