Error in the integration result

조회 수: 2 (최근 30일)
Daigo
Daigo 2022년 2월 23일
댓글: Daigo 2022년 2월 23일
Given the joint p.d.f.:
for -\infty < x, y < \infty
I'm trying to compute the expected value: by the following code:
syms x y
pi = sym('pi');
fxy = (1/pi)*exp(-((x-1)^2+2*y*(x-1)+2*y^2));
Exy = int(int(x*y*fxy,x,-inf,inf),y,-inf,inf)
However, I got the following solution
I started to wonder if this function is not integrable in the first place. However, the answer was no. I computed the same integral by Wolfram Alpha (no offense...) and got the following result:
Am I doing something wrong in my code? Do you have any idea how to obtian the same result in MATLAB? I appreciate your help.

채택된 답변

Paul
Paul 2022년 2월 23일
편집: Paul 2022년 2월 23일
Expected result after expand() and simplify() of fxy. Don't know why these operations are needed.
syms x y
Pi = sym(pi); % modified
fxy = (1/Pi)*exp(-((x-1)^2+2*y*(x-1)+2*y^2));
Exy = int(int(x*y*simplify(expand(fxy)),x,-inf,inf),y,-inf,inf)
Exy = 
Actually, the simplify() is not needed
syms x y
Pi = sym(pi); % modified
fxy = (1/Pi)*exp(-((x-1)^2+2*y*(x-1)+2*y^2));
Exy = int(int(x*y*expand(fxy),x,-inf,inf),y,-inf,inf)
Exy = 
  댓글 수: 1
Daigo
Daigo 2022년 2월 23일
I have no idea why we have to expand the polynomial before integration...but I'm glad to know it works in this way. Thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by