I wonder that which command can rearrange one side of a equation into 0, e.g. "ax==by" into "ax-by==0".
Here are a couple of ways:
#1 - #2 == 0 & @@ (a x == b y) (* a x - b y == 0 *) #[] - #[] == 0 &@ (a x == b y) (* a x - b y == 0 *)
As far as I can tell, they're going to work on any equation, with no modification. And it's straightforward to define
lhsequals0 = #[] - #[] == 0 &
so that, for example
lhsequals0[3 x^2 + 2 y - 4 == 6 xy^2 - 4 x^2 + Cos[Sqrt[y]]] (* -4 + 7 x^2 - 6 xy^2 + 2 y - Cos[Sqrt[y]] == 0 *)
Just to give a sense of how and why this works, look at the
FullForm for your equation:
FullForm[a x == b y] (* Equal[Times[a, x], Times[b, y]] *)
An equation will always have the head
Equal, with the first argument (
#1, depending) being the lhs and the second (
#2) being the rhs. So all both of the above functions are doing is subtracting the rhs from the lhs and setting
Equal to zero.
Do see @kglr's link in the comments for some more in-depth answers.