Error in double integration
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Athira T Das
am 18 Apr. 2023
Bearbeitet: Athira T Das
am 25 Apr. 2023
I need to evaluate a double integration but showing some error
lam=532*10^-9;
z=100;
k=2*pi/lam;
omega=30;s=5;
r=linspace(0,100,100);
w0=0.002;m=1;rho=1;p=1;
E = 1./(w0^2) + (1i*k)./(2*z);
Con1=(1i./(2*lam*z))*exp((omega^2./2 + r.^2 + omega)./E).*exp((-1i.*k.*r.^2)./(2*z)).*(pi./E).*(1./(2*1i*sqrt(E)))^m;
Con2=(1i./(2*lam*z))*exp((omega^2./2 + r.^2 + omega)./conj(E)).*exp((-1i.*k.*r.^2)./(2*z)).*(pi./conj(E)).*(1./(2*1i*sqrt(conj(E)))).^m;
syms ph phi
for l=0:m
E0 = Con1.*((exp(-r.*(cos(ph)+sin(ph))).*hermiteH(l,1i*(omega./2 - r*cos(ph))./sqrt(E)).*hermiteH(m-l,1i*(omega./2 - r*sin(ph))./sqrt(E))) - (exp(r.*(cos(ph)+sin(ph))).*hermiteH(l,-1i*(omega./2 + r*cos(ph))./sqrt(E)).*hermiteH(m-l,-1i*(omega./2 + r*sin(ph))./sqrt(E))));
E0s = Con2.*((exp(-r.*(cos(phi)+sin(phi))).*hermiteH(l,1i*(omega./2 - r*cos(phi))./sqrt(conj(E))).*hermiteH(m-l,1i*(omega./2 - r*sin(phi))./sqrt(conj(E)))) - (exp(r.*(cos(phi)+sin(phi))).*hermiteH(l,-1i*(omega./2 + r.*cos(phi))./sqrt(conj(E))).*hermiteH(m-l,-1i*(omega./2 + r*sin(phi))./sqrt(conj(E)))));
I = ((1i*p).^(m-l)).*nchoosek(m,l).*E0.*E0s.*exp(-1i.*s.*(ph-phi)).*exp(((-2.*r.^2)-(2.*r.^2.*cos(phi-ph)))./(rho.^2));
end
IQ = I;
ph_min = 0;
ph_max = 2*pi;
phi_min = 0;
phi_max = 2*pi;
fun = matlabFunction(IQ,'Vars',[ph,phi]);
result = integral2(fun, ph_min, ph_max, phi_min, phi_max);
0 Kommentare
Akzeptierte Antwort
Torsten
am 22 Apr. 2023
Bearbeitet: Torsten
am 22 Apr. 2023
syms r ph phi
lam=532*10^-9;
z=100;
k=2*pi/lam;
omega=30;
w0=0.002;m=1;rho=1;p=1;
E = 1./(w0^2) + (1i*k)./(2*z);
Con1=(1i./(2*lam*z))*exp((omega^2./2 + r.^2 + omega)./E).*exp((-1i.*k.*r.^2)./(2*z)).*(pi./E).*(1./(2*1i*sqrt(E)))^m;
Con2=(1i./(2*lam*z))*exp((omega^2./2 + r.^2 + omega)./conj(E)).*exp((-1i.*k.*r.^2)./(2*z)).*(pi./conj(E)).*(1./(2*1i*sqrt(conj(E)))).^m;
for l=0:m
E0 = Con1.*((exp(-r.*(cos(ph)+sin(ph))).*hermiteH(l,1i*(omega./2 - r*cos(ph))./sqrt(E)).*hermiteH(m-l,1i*(omega./2 - r*sin(ph))./sqrt(E))) - (exp(r.*(cos(ph)+sin(ph))).*hermiteH(l,-1i*(omega./2 + r*cos(ph))./sqrt(E)).*hermiteH(m-l,-1i*(omega./2 + r*sin(ph))./sqrt(E))));
E0s = Con2.*((exp(-r.*(cos(phi)+sin(phi))).*hermiteH(l,1i*(omega./2 - r*cos(phi))./sqrt(conj(E))).*hermiteH(m-l,1i*(omega./2 - r*sin(phi))./sqrt(conj(E)))) - (exp(r.*(cos(phi)+sin(phi))).*hermiteH(l,-1i*(omega./2 + r.*cos(phi))./sqrt(conj(E))).*hermiteH(m-l,-1i*(omega./2 + r*sin(phi))./sqrt(conj(E)))));
I = ((1i*p).^(m-l)).*nchoosek(m,l).*E0.*E0s.*exp(-1i.*l.*(ph-phi)).*exp(((-2.*r.^2)-(2.*r.^2.*cos(phi-ph)))./(rho.^2));
end
IQ = I;
ph_min = 0;
ph_max = 2*pi;
phi_min = 0;
phi_max = 2*pi;
fun = matlabFunction(IQ,'Vars',[ph,phi,r]);
r_array = linspace(0,10,100);
result = arrayfun(@(r)integral2(@(ph,phi)fun(ph,phi,r),ph_min, ph_max, phi_min, phi_max),r_array)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!