I used the following snippet to simplify an equation:
syms P Q R S T U V A B C D E F G X Y
simplify((X - A)^2 + (Y - B)^2 - (X - B)^2 - (Y + A)^2)
Which gives me the result:
2*B*X - 2*A*Y - 2*A*X - 2*B*Y
On the other hand,
simplify((X - A)^2 + (Y - B)^2 - (X - B)^2 - (Y + 2*A)^2)
gives the same result after just re-ordering:
(A - X)^2 - (B - X)^2 - (2*A + Y)^2 + (B - Y)^2
What changed between these two equations? Am I not using the function correctly?
Any help would be appreciated.
As per the documentation, you can increase the amount of simplification "steps" using:
simplify(expr,'Steps',nSteps); % e.g. nSteps = 50
You can also try other functions (combine
, expand
, factor
, ...) for rearranging an expression.
I have the Maple symbolic toolbox for MATLAB and I get different results than you:
>> syms P Q R S T U V A B C D E F G X Y
>> simplify((X - A)^2 + (Y - B)^2 - (X - B)^2 - (Y + A)^2)
ans =
(-2 X - 2 Y) A + 2 B (X - Y)
>> simplify((X - A)^2 + (Y - B)^2 - (X - B)^2 - (Y + 2*A)^2)
ans =
2
-3 A + (-2 X - 4 Y) A + 2 B (X - Y)
In conclusion - it works as expected, you should give other functions/tools a try.