Using symbolic integration: Why does my double integral returns different numerical values depending on integration order?
이전 댓글 표시
I have the double integral
. Using int and double to numerically evaluate this I get:
. Using int and double to numerically evaluate this I get: syms x y
fun1 = @(x, y) (112).*exp(-7.*x-9.*y);
a = int(int(fun1, y, 1/4), y, 0, 1);
double(a)
ans = 0.6911
If I change the order of integration and integrate
, I get the correct answer.
, I get the correct answer. syms x y
fun = @(x, y) (112).*exp(-7.*x-9.*y);
b = int(int(fun, y, 0, x), x, 0, 1/4);
double(b)
ans = 0.7053
Why is this the case?
채택된 답변
추가 답변 (1개)
Walter Roberson
2021년 11월 20일
편집: Walter Roberson
2021년 11월 20일
syms x y
fun1 = @(x, y) (112).*exp(-7.*x-9.*y);
int(fun1, y, 1/4)
Which variable did it integrate with respect to? Answer: x by default, since x is the first variable returned by symvar()
symvar(sym(fun1))
So we can put the variable in explicitly
a = int(int(fun1, x, y, 1/4, 'hold', true), y, 0, 1, 'hold', true)
and that matches the formula you asked to integrate.
Now let us try your other version:
fun = @(x, y) (112).*exp(-7.*x-9.*y);
b = int(int(fun, y, 0, x, 'hold', true), x, 0, 1/4, 'hold',true)
Is that the same? Notice that the -7 here matches to the integration range 0 to 1/4, whereas the original that you said you wanted to integrate, the -7 is associated with the integration range y to 1/4 .
The two are not equivalent.
댓글 수: 6
Jame Tran
2021년 11월 20일
syms x y
fun1 = @(x, y) (112).*exp(-7.*x-9.*y)
a = int(int(fun1, x, y, 1/4, 'hold', true), y, 0, 1, 'hold', true)
b = int(int(fun1, y, 0, 1, 'hold', true), x, y, 1/4, 'hold', true)
ar = simplify(release(a))
br = simplify(release(b))
double(ar)
double(br)
What happened? Well, when you swap the order of integration without rewriting the expression, then y in the limit for the integral x becomes a "different" y then the y being integrated over first.
Jame Tran
2021년 11월 20일
Walter Roberson
2021년 11월 20일
In the first version, fun1, the dependent variable whose bounds are expressed in terms of the other variable, is associated with the -7 multiplier in the exp()
In the second version, fun, the dependent variable whose bounds are expressed in terms of the other variable, is associated with the -9 multiplier in the exp()
Unless you are saying that you believe that they should calculate the same result through two different methods? I would have to think about that a bit.
Jame Tran
2021년 11월 20일
Walter Roberson
2021년 11월 20일
Both integrals are over the triangular area defined by y < x < 1/4, 0 < y < 1 right?
No. Your second integral implies y <= x, but your first integral implies x <= y
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

