finding solution to two variable function
조회 수: 13 (최근 30일)
이전 댓글 표시
i am trying to compute the critical point of my function using partial derrivatives
syms x
syms y
f=@(x,y) x*log(x*y)-y;
fpx=@(x,y) diff(f(x,y),x);
fpy=@(x,y) diff(f(x,y),y);
crit_x = solve(fpx(x,y));
crit_y = solve(fpy(x,y));
댓글 수: 2
Star Strider
2022년 10월 31일
What seems to be the problem?
syms x
syms y
f=@(x,y) x*log(x*y)-y;
fpx=@(x,y) diff(f(x,y),x);
fpy=@(x,y) diff(f(x,y),y);
crit_x = solve(fpx(x,y))
crit_y = solve(fpy(x,y))
.
Dyuman Joshi
2022년 10월 31일
@Star Strider, wouldn't it be better to not use function handles with syms?
And make symbolic function like this, if syms is to be used already?
syms f(x,y)
f(x,y)=x*log(x*y)-y;
fpx=diff(f,x);
fpy=diff(f,y);
critx=solve(fpx)
crity=solve(fpy)
답변 (1개)
Walter Roberson
2022년 10월 31일
When you solve() a set of equations of multiple variables without specifying which variables to solve for, MATLAB automatically chooses which variables to solve for, preferring first x then y then z and then the rest of the alphabet. So in both cases MATLAB automatically selected x to solve for. But you wanted to solve one of them for y.
You need to decide which kind of critical point you are searching for. A point (or line) might be critical in one direction but possibly not in another, or might be a different kind of critical. x^2 - y^2 for example has maxima for one direction but minima for a different direction.
If you are looking simultaneous critical points then you cannot always get that (at least in real) if there are interactions between the variables. But if you want to try then you would ask to solve the two derivatives simultaneously
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Variables, Expressions, Functions, and Settings에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!