assume(x^2 == y) doesn't work
조회 수: 2 (최근 30일)
이전 댓글 표시
I have the following code:
syms x y;
assume(x^2 == y);
assume(x*y == y*x);
t = isequaln(x^2, y);
s = isequaln(x*y, y*x);
The value for t is 0, so it doesn't seem like isequaln(x^2, y) is working correctly. (The value for s is 1, so it seems like assume(x*y == y*x) is working fine.) I've also tried simplify(x^2 + y) and this just returns x^2 + y. So there must be some exception with assumptions that involve the same variable twice?
Any help would be appreciated. Thanks.
댓글 수: 0
답변 (1개)
Tommy
2020년 5월 18일
편집: Tommy
2020년 5월 19일
"assume is not additive. Instead, it automatically deletes all previous assumptions on the variables in condition."
Here is a simple test of isequaln and isAlways:
>> syms x y
>> assume(x^2 == y)
>> assumeAlso(x*y == y*x)
>> assumptions
ans =
[ x*y == x*y, x^2 == y]
>> isequaln(x*y,y*x)
ans =
logical
1
% (I'm guessing this is true because multiplication of complex numbers is commutative,
% not because of the above assumption.)
>> isequaln(x*x,y)
ans =
logical
0
>> isAlways(x*x==y)
ans =
logical
1
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!