Integration takes time too long

28 次查看(过去 30 天)
Hi, i want to integrate this equation C(x,y,t) but it takes too long and I did not get the solution . What can I do ?
This is my code that I have try
x=-2:1:6;
y=0.4;
t=0.75;
v=1.5;
alpha=0.1;
gamma=1/(1-alpha);
syms r;
A=exp(v/2*(x+y)-alpha*gamma*t);
B=(r^3)/(r.^2+gamma+v^2/2)^2;
D=exp((alpha*gamma.^2*t)/(r.^2+gamma+v^2/2));
K=besselj(0,r*sqrt(x.^2+y.^2));
L=besselj(2,r*sqrt(x.^2+y.^2));
M=B*D.*(K+L);
C=(alpha*(gamma^2)*y*A).*int(M,r,0,inf);
plot(x,C)

采纳的回答

Torsten
Torsten 2022-6-8
X=-2:0.1:6;
y=0.4;
t=0.75;
v=1.5;
alpha=0.1;
for i=1:numel(X)
x = X(i);
Fun = @(r)fun(r,x,y,t,v,alpha);
C(i) = integral(Fun,0,Inf);
end
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 5.9e-09. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 6.5e-09. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 6.7e-09. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 7.1e-09. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 7.4e-09. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 8.1e-09. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 8.3e-09. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 9.4e-09. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 9.7e-09. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.0e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.1e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.2e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.2e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.3e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.4e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.6e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.6e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.7e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.9e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 2.0e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 2.2e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 2.3e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 2.4e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 2.6e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 2.8e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 3.0e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 3.2e-08. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
plot(X,C)
function value = fun(r,x,y,t,v,alpha)
gamma=1/(1-alpha);
A=exp(v/2*(x+y)-alpha*gamma*t);
B=(r.^3)./(r.^2+gamma+v^2/2).^2;
D=exp((alpha*gamma.^2*t)./(r.^2+gamma+v^2/2));
K=besselj(0,r.*sqrt(x.^2+y.^2));
L=besselj(2,r.*sqrt(x.^2+y.^2));
M=B.*D.*(K+L);
value = alpha*gamma^2*y*A*M;
end

更多回答(1 个)

SALAH ALRABEEI
SALAH ALRABEEI 2022-6-8
Matlab is not good enough to symoblically ( analyitcally) integarate or solve such complex equations). If you want the the analytical integaration, it is better to simplify it yourslf by hand. However, you integarte (numerical approximation) over a truncated domain from [0, infinity) to [0, M], where M is a large number. This approached is already done by @Torsten here

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by