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?
I need help with a Triple Integral
51 次查看(过去 30 天)
显示 更早的评论
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);
2 个评论
darova
2019-10-30
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
回答(3 个)
Asvin Kumar
2019-11-1
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)
0 个评论
David Goodmanson
2022-2-21
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!