4D integral with exponential value

조회 수: 15 (최근 30일)
Mümin ÖZPOLAT
Mümin ÖZPOLAT 2017년 3월 20일
댓글: Torsten 2017년 3월 23일
Hi,
I am trying to calculate this integral using indefinite integral functions.
1 1 / 1 1
/ / | / /
| | | | | 1
| | exp| | | ----------------------------------------------------------------------- dx dy
/ / | / / / 1 \ / 2 / 1 \2 \2
0 0 | 0 0 | ------------------------------ + 160 | | (w - z) + | y - x + - | |
| | / 2 / 1 \2 \2 | \ \ 2 / /
| | | (w - z) + | y - x + - | | |
\ \ \ \ 2 / / /
\
|
|
| dz dw
|
|
|
|
/
It is 4D integral. When I try to use indefinite integral function int Matlab cant calculate it.
int(int(exp(int(int(1/((1/((w - z)^2 + (y - x + 1/2)^2)^2 + 160)*((w - z)^2 + (y - x + 1/2)^2)^2), x, 0, 1), y, 0, 1)), z, 0, 1), w, 0, 1)
When I try to use integral2 function to calculate numerically, the z and w parameters are obstacles.
I cannot use 4D user defined integral function because there exp{} block between integrals.
Do you know how to solve that integral?

답변 (2개)

Torsten
Torsten 2017년 3월 21일
편집: Torsten 2017년 3월 21일
Brute-force method:
delta=0.01;
w=0:delta:1;
z=0:delta:1;
x=0:delta:1;
y=0:delta:1;
func=@(x,y,w,z)1/(1+160*(((w-z)^2+(y-x+0.5)^2)^2));
for i=1:numel(w)
wloc = w(i);
for j=1:numel(z)
zloc = z(j);
f = 0;
for k=1:numel(x)-1
xloc_l = x(k);
xloc_r = x(k+1);
for l=1:numel(y)-1
yloc_l = y(l);
yloc_r = y(l+1);
f = f + 0.25*(func(xloc_l,yloc_l,wloc,zloc)+func(xloc_l,yloc_r,wloc,zloc)+func(xloc_r,yloc_l,wloc,zloc)+func(xloc_r,yloc_r,wloc,zloc))*delta^2;
end
end
fxy(i,j) = exp(f);
end
end
integral = 0.0;
for i=1:numel(w)-1
for j=1:numel(z)-1
integral = integral + 0.25*(fxy(i,j)+fxy(i,j+1)+fxy(i+1,j)+fxy(i+1,j+1))*delta^2;
end
end
"integral" should be the value of the integral you are looking for.
You may want to choose a smaller value for "delta" to get a better approximation.
With delta=1/300 I get a value of 1,166618 for your integral.
Best wishes
Torsten.

Mümin ÖZPOLAT
Mümin ÖZPOLAT 2017년 3월 22일
편집: Mümin ÖZPOLAT 2017년 3월 22일
Thanks !
Seems like it is an implementation of Riemann Sum.
You use delta^2 because the integration is 2 layered and multiplicate it by 0.25 because you get average of 4 different result.
  댓글 수: 1
Torsten
Torsten 2017년 3월 23일
It's the two-dimensional trapezoidal rule, applied twice: once to the double inner integral, then to the double outer intergral.
Best wishes
Torsten.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by