# How can I transform linear equations into the form $a\,x+b\,y+c=0$?

I have a bunch of line equations generated by the following code:

Clear[eq, pts]
eq = Simplify[Det[{{x, y}, -Subtract @@ #}] == Det[#]] &;
pts =
{{{0, 3}, {4, 0}}, {{-1, -2}, {4, -2}}, {{3, 4}, {3, -2}}, {{1, -2}, {5, 1}}};
eq /@ pts


The outputs are given as follows.

{3 x + 4 y == 12, 2 + y == 0, x == 3, 3 x == 11 + 4 y}


### Question

How can I reformat the outputs to be in the form of $$a\,x+b\,y+c=0$$?

Note that, although the form $$a\,x + b\,y + c == 0$$ is fine, I would accept the form $$a\,x + b\,y + c = 0$$.

• TeXForm /@ ((eq /@ pts) /. x__ == y__ :> x - y == 0). Sep 1 '20 at 7:42
• @Montevideo: Very good! Thank you. Do you want to post it as your answer? Or I delete the question? Sep 1 '20 at 7:44

You can use SubtractSides:

SubtractSides /@ {3 x + 4 y == 12, 2 + y == 0, x == 3, 3 x == 11 + 4 y}

  {-12 + 3 x + 4 y == 0, 2 + y == 0, -3 + x == 0, -11 + 3 x - 4 y == 0}

TraditionalForm /@ % Alternatively, you can modify eq using a custom ComplexityFunction in Simplify:

Clear[eq2]
cF = LeafCount[#] + 5000 Count[#, HoldPattern@Equal[_, Except], All] &;

eq2 = Simplify[Det[{{x, y}, -Subtract @@ #}] == Det[#], ComplexityFunction -> cF] &; Clear[eq, pts]
eq = Defer@*Plus @@ MonomialList[FactorList[Det[{#1 - #2, #2 - {x, y}}]][[2, 1]]] == 0 &;
pts = {{{0, 3}, {4, 0}}, {{-1, -2}, {4, -2}}, {{3, 4}, {3, -2}}, {{1, -2}, {5, 1}}};
eq @@@ pts You can solve this problem by:

TeXForm /@ ((eq /@ pts) /. x__ == y__ :> x - y == 0)