How to calculate and plot ndefinite triple integral?
5 次查看(过去 30 天)
显示 更早的评论
I have a triple indefinite integral (image attached).
Here respectively sx = sy = s*sin(a)/sqrt(2) and sz= s*cos(a). Parameter s=0.1 and parameter a changes from 0 to pi/2 – 10 points can be chosen [0 10 20 30 40 50 60 70 80 90]. Is it possible to solve such integral and to obtain the curve – plot(a,F)?
s=0.1;
a = 0:10:90;
fun = @(x,y,z) ((x.*z)./((x.^2+y.^2+z.^2))).*((2*pi)^(3/2))*exp(-(0.5.*sqrt(x.^2+y.^2+z.^2))).*exp(1i.*x*(s*sin(p)/sqrt(2))-2*((x.^2+y.^2+z.^2)+((z.^2)./((x.^2+y.^2+z.^2))))).*exp(1i.*y*(s*sin(p)/sqrt(2))-2*((x.^2+y.^2+z.^2)+((z.^2)./((x.^2+y.^2+z.^2))))).*exp(1i.*z*(s*cos(p))-2*((x.^2+y.^2+z.^2)+((z.^2)./((x.^2+y.^2+z.^2)))));
f3 = arrayfun(@(p)integral3(@(x,y,z)fun(x,y,z,p)),a);
plot(a,f3);
3 个评论
Torsten
2023-4-12
I forgot about the coefficient (2*pi)^(3/2) before exponent, but it does not matter much.
There are many more differences.
In your formula:
exp(-0.5.*(x.^2+y.^2+z.^2))
In your code:
exp(-(0.5.*sqrt(x.^2+y.^2+z.^2)))
In your formula:
exp(1i.*x*(s*sin(p)/sqrt(2))+1i.*y*(s*sin(p)/sqrt(2))+1i*z.*(s*cos(p))-2*(x.^2+y.^2+z.^2+z.^2./(x.^2+y.^2+z.^2)))
In your code:
exp(1i.*x*(s*sin(p)/sqrt(2))-2*((x.^2+y.^2+z.^2)+((z.^2)./((x.^2+y.^2+z.^2))))).*exp(1i.*y*(s*sin(p)/sqrt(2))-2*((x.^2+y.^2+z.^2)+((z.^2)./((x.^2+y.^2+z.^2))))).*exp(1i.*z*(s*cos(p))-2*((x.^2+y.^2+z.^2)+((z.^2)./((x.^2+y.^2+z.^2)))))
采纳的回答
Torsten
2023-4-12
s = 0.1;
a = 0:5:360;
a = a*pi/180;
fun = @(x,y,z,p) x.*z./(x.^2+y.^2+z.^2).*exp(-0.5*(x.^2+y.^2+z.^2)).*exp(1i*x*(s*sin(p)/sqrt(2))+1i*y*(s*sin(p)/sqrt(2))+1i*z*(s*cos(p))-2*(x.^2+y.^2+z.^2+z.^2./(x.^2+y.^2+z.^2)));
f3 = (2*pi)^1.5*arrayfun(@(p)integral3(@(x,y,z)fun(x,y,z,p),0,Inf,0,2*pi,0,pi),a);
figure(1)
plot(a,real(f3))
figure(2)
plot(a,imag(f3))
8 个评论
Torsten
2023-4-19
编辑:Torsten
2023-4-19
Why do you replace s by k and not by m in your code ?
And if you loop over the elements of a, why do you use the arrayfun ? Arrayfun computes the values for f3 for the complete vector a over and over again. I can understand that your code takes a while to finish.
Since the results for f3 are complex-valued, you can only apply surf on abs(f3) or imag(f3) or real(f3), but not f3 itself.
n = 1;
t = 1;
r = 1;
S = 1:0.5:5;
P = 0:10:180;
P = P*pi/180;
for i = 1:numel(S)
s = S(i);
for j = 1:numel(P)
p = P(j);
fun = @(x,y,z) x.*z./(x.^2+y.^2+z.^2).*exp(-0.5*(x.^2+y.^2+z.^2)).*exp(1i*x*(s*sin(p)/sqrt(2))+1i*y*(s*sin(p)/sqrt(2))+1i*z* (s*cos(p))-2*(x.^2+y.^2+z.^2+z.^2./(x.^2+y.^2+z.^2)));
f3(i,j) = (2*pi)^1.5*integral3(fun,0,Inf,0,2*pi,0,pi);
end
end
f3
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!