I need help with a Triple Integral

42 views (last 30 days)
Francisco Ramirez
Francisco Ramirez on 30 Oct 2019
Answered: David Goodmanson on 21 Feb 2022
Im trying to do the next integral
With this code
fun = @(x,y,z) r
zmin = sqrt(2-(r^.2)/20)+12
zmax = 17.5-((r^.2)/3)
xmin = 0
xmax = 2*pi;
rmin = 0
rmax = 3.60767
result = integral3(fun,zmin,zmax,xmin,xmax,rmin,rmax);
Francisco Ramirez
Francisco Ramirez on 30 Oct 2019
And for some reason it just went off, anyways, ive tried using integral3, stright up doing Int 3 times but nothing seems to work, any help?
darova on 30 Oct 2019
What about arguments here?
zmin = sqrt(2-(r^.2)/20)+12 % @(r) sqrt ...
zmax = 17.5-((r^.2)/3)
Also you are writing here that arguments are (x,y,z) but function contains r
fun = @(x,y,z) r

Sign in to comment.

Answers (3)

Asvin Kumar
Asvin Kumar on 1 Nov 2019
Try using the following code:
fun = @(x,y,z) y; % y is r
zmin = @(u,v) sqrt(2-(v.^2)/20)+12; % z
zmax = @(u,v) 17.5-((v.^2)/3);
xmin = 0; % theta
xmax = 2*pi;
ymin = 0; % r
ymax = 3.60767;
result = integral3(fun,xmin,xmax,ymin,ymax,zmin,zmax)
This code rearranges the order of integration. This is done to support the order of computation of limits in integral3 keeping in mind dependency among variables. The limits of integration of ’z’ are dependent on values of ‘r’ while the limits of integration of ‘r’ and ‘theta’ are independent.
The documentation at https://www.mathworks.com/help/matlab/ref/integral3.html#btbbw_k-1-fun explains how the limits are computed. The limits ymin and ymax are computed using x, which is ‘theta’ in this case, and the limits zmin and zmax are computed using x, y, which are ‘theta’ and ‘r’ in this case.
That is why the code given above passes arguments in the order: ‘theta’ , ‘r’ , ‘z’. Note also that the code can be modified to pass the arguments such that ‘r’ comes first followed by ‘z' and then ‘theta’. ‘fun’ would then need to be appropriately modified but that approach could also produce the desired output.
Additionally, refer to the example at https://www.mathworks.com/help/matlab/ref/integral3.html#btdgkz_ for better understanding.
There exists an alternate approach to compute the triple integral. It uses the Symbolic Math Toolbox. Code attached below for reference:
syms z x r
tmp = int(r,z,sqrt(2-(r.^2)/20)+12,17.5-((r.^2)/3));
tmp = int(tmp,x,0,2*pi);
tmp = int(tmp,r,0,3.60767);
val = vpa(tmp)

Ajay R
Ajay R on 21 Feb 2022
Syms x, y, z int(int(int(1,z,[0,sqrt(a²-x²-y²)]),y,[0,sqrt(a²-x²)]),x,[0,a])

David Goodmanson
David Goodmanson on 21 Feb 2022
Hi Francisco.
this is really just a 1d integral. Since nothing depends on theta, the theta integration instantly gives an overall factor of 2pi. Since nothing depends on z, the z integration just gives the value at the upper limit minus the value at the lower limit, or
17.5-((r.^2)/3) - (sqrt(2-(r.^2)/20)+12)
There is an extra factor of r in the integrand, so all this reduces to
f = @(r) ( 17.5-((r.^2)/3) - (sqrt(2-(r.^2)/20)+12) ).*r
I = 2*pi*integral(f,0,3.60767)
I = 83.3625


Community Treasure Hunt

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

Start Hunting!