필터 지우기
필터 지우기

assume(x^2 == y) doesn't work

조회 수: 2 (최근 30일)
David Cui
David Cui 2020년 5월 18일
편집: Tommy 2020년 5월 19일
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.

답변 (1개)

Tommy
Tommy 2020년 5월 18일
편집: Tommy 2020년 5월 19일
From the docs,
"assume is not additive. Instead, it automatically deletes all previous assumptions on the variables in condition."
(edit) Also, take a look at this post.
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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by