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

5 views (last 30 days)
David Cui
David Cui on 18 May 2020
Edited: Tommy on 19 May 2020
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.

Answers (1)

Tommy
Tommy on 18 May 2020
Edited: Tommy on 19 May 2020
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

Tags

Community Treasure Hunt

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

Start Hunting!