Numerical calculation of nested integral with no analytical solution
2 views (last 30 days)
Show older comments
Dear all,
I have a question related to nested integral calculation when the first integral to be calculated has no analytical solution in terms of elemental functions.
The nested integral I would like to solve is:

where there is an integral in the denominator of the integral which has no analytical solution. The limits of this integral in the denominator include
, so cannot be estimated numerically (in a direct manner, but should in the nested integral). Although not related, I could solve this integral numerically by using double integrals in MATLAB (integral2(fun, z1, e/2, 0, v1) command), but this is obviously not applicable since this is not a double but a nested integral.
Thus, the nested integral depends on both v and z (all the other parameters are constants). Doees anyone know if this nested integral can be solved in Matlab? I never tried something like this before. I provide a piece of code and my attempt. Perhaps I am just not correctly typing something and Matlab solves this easily, so please sorry about any mistake (I leave some commented lines which are commands I tried and thought they'd work):
R2=0.00012721; Ox = -8.39166666666673e-05;
theta2 = 0.369784726547689; a = 0.000251315;
D1 = 0.00024821; h1 = 0.000167833333333335;
A = 4.323429908e-07; e = 0.000589216666666665;
%+++++
%+++++Function and limits of integrals+++++
fun= @(z,v) ((R2^2*sin(v).^2)./sqrt(1-((z-Ox)./(a+R2.*cos(v))).^2));
v1 = @(z) (pi - acos((a - z + Ox )./R2)); %this is function of z
z1 = (R2+D1).*cos(theta2)-h1/2; %this is a number
%+++++
% ++++ Attempts +++++
% m=@(z) integral(fun, 0, v1);
% integral(1/(A-2*m), z1, e/2);
%integral(1/(A-2*(integral(@(z,v) ((R2^2*sin(v).^2)./sqrt(1-((z-Ox)./(a+R2.*cos(v))).^2)), 0, v1))), z1, e/2) ;
integral(1/(A-2*(integral(@(z,v) ((R2^2*sin(v).^2)./sqrt(1-((z-Ox)./(a+R2.*cos(v))).^2)), 0, v1))), z1, e/2) ;
From this code, I get the following error:
Error using integral (line 85)
A and B must be floating-point scalars.
Any help is pretty much appreciated since I am a bit desperated. I do not even know whether MATLAB is able to solve this!
Best regards
0 Comments
Accepted Answer
Torsten
on 24 Dec 2021
Edited: Torsten
on 25 Dec 2021
function main
R2=0.00012721; Ox = -8.39166666666673e-05;
theta2 = 0.369784726547689; a = 0.000251315;
D1 = 0.00024821; h1 = 0.000167833333333335;
A = 4.323429908e-07; e = 0.000589216666666665;
zmin = (R2+D1)*cos(theta2)-h1/2;
zmax = e/2;
Ifun = integral(@(z)fun(z,R2,Ox,theta2,a,D1,h1,A,e),zmin,zmax,'ArrayValued',true)
end
function y = fun(z,R2,Ox,theta2,a,D1,h1,A,e)
v1 = pi - acos((a-z+Ox)/R2)
fun2 = @(v) R2^2*sin(v).^2./sqrt(1-((z-Ox)./(a+R2*cos(v))).^2);
vmin = 0;
vmax = v1;
Ifun2 = integral(fun2,vmin,vmax)
y = 1/(A-2*Ifun2)
end
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!