Numerical calculation of nested integral with no analytical solution

2 vues (au cours des 30 derniers jours)
Pak Illo
Pak Illo le 24 Déc 2021
Modifié(e) : Torsten le 25 Déc 2021
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

Réponse acceptée

Torsten
Torsten le 24 Déc 2021
Modifié(e) : Torsten le 25 Déc 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
  1 commentaire
Pak Illo
Pak Illo le 25 Déc 2021
Many thanks for your very prompt answer!!! I have check the code and it works.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by