# How can I write the equation 9 x == 5 y + 8 z + 27 in the form 9x - 5y - 8z - 27=0?

I use

myeq = CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 6, 3}, {x, y, z}}]


9 x == 27 + 5 y + 8 z

I am trying to write myeq in the form $$9x-5y-8z-27 = 0$$. I tried

TraditionalForm[myeq]


or

PolynomialForm[myeq]


and

PolynomialForm[myeq, TraditionalOrder -> True]


I can not get the form $$9x-5y-8z-27=0$$.

How can I write the equation 9 x == 5 y + 8 z + 27 in the form 9x - 5y - 8z - 27 = 0?

• TraditionalForm[Subtract@@myeq == 0]? Jan 6 at 2:45
• Your method is true for my question. But this is not true myeq = CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 3, 6}, {x, y, z}}]; TraditionalForm[Subtract @@ myeq == 0] Jan 6 at 3:16
• SubtractSides[myeq] or if you prefer SubtractSides[Reverse@myeq] Jan 6 at 8:03

Another way using ReplaceAll:

TraditionalForm[myeq /. a_ == b_ :>ExpandAll[a - b] == 0]

(*9 x-5 y-8 z-27==0*)


The second example:

myeq = CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 3, 6}, {x, y, z}}];

TraditionalForm[myeq /. a_ == b_ :>ExpandAll[a - b] == 0]

(*9 x-2 y-5 z-45==0*)

• This is not true when I use your code myeq = CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 3, 6}, {x, y, z}}]; TraditionalForm[myeq /. a_ == b_ :> a - b == 0] Jan 6 at 3:17
• I tried myeq = Expand[ CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 3, 6}, {x, y, z}}]]; TraditionalForm[myeq /. a_ == b_ :> a - b == 0] it works. Jan 6 at 3:19

SubtractSides was added some versions back for this common operation. Combine with ExpandAll if you want it expanded:

eqn = CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 3, 6}, {x, y, z}}]

(* 9 x == 2 y + 5 (9 + z) *)

ExpandAll@SubtractSides@eqn

(* -45 + 9 x - 2 y - 5 z == 0 *)


If you really want fine control over output formatting, you might want to break down the equation algebraically and use boxes for the output:

Flatten@Reverse[
{1, {x, y, z}} CoefficientArrays[eqn, {x, y, z}]] //
DeleteCases[0] // Replace[{
List[a__] :> RawBoxes@MakeBoxes[Plus[a] == 0, StandardForm],
List[] :> True}]

(* 9 x - 2 y - 5 z - 45 == 0 *)


List[] can occur if everything in the equation cancels out. Of course, if TraditionalForm work for you, it's easier than boxes. In a simple Defer works, too:

Flatten@Reverse[
{1, {x, y, z}} CoefficientArrays[eqn, {x, y, z}]] //
DeleteCases[0] // Replace[{
List[a__] :> Defer[Plus[a] == 0],
List[] :> True}]

(* 9 x - 2 y - 5 z - 45 == 0 *)

• I use eqn = CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 3, 6}, {x, y, z}}]; TraditionalForm@ExpandAll@SubtractSides@eqn It works. Thank you very much. Jan 6 at 7:45

I use two functions for this sort of thing:

lhs[eq_Equal] := Expand[eq[[1]]]
rhs[eq_Equal] := Expand[eq[[2]] ]


## Example 1

myeq=CoplanarPoints[{{7,4,2},{8,1,5},{9,6,3},{x,y,z}}];
myeq = lhs[myeq] - rhs[myeq] == 0;


## Example 2

myeq = CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 3, 6}, {x, y, z}}]


I prefer rhs and lhs since it is more explicit and more clear for me than other methods (even though other methods might require less typing).

• With your Example 2, I only get 9 x == 2 y + 5 (9 + z). I have to add myeq = CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 3, 6}, {x, y, z}}]; TraditionalForm[Expand[lhs[myeq] - rhs[myeq]] == 0] Jan 6 at 3:59
• @ThuyNguyen This is strange. in my V 13.3.1 it works as is. Here is screen shot !Mathematica graphics make sure to use the updated code with the Expand in it. Jan 6 at 4:05
• @ThuyNguyen which version of Mathematica are you using? Try from clean kernel if you have not done this. Jan 6 at 4:10
• Old version. I try that. Thanks again. Jan 6 at 4:12
• With your Example 2, I get the same your result without using Expand Jan 6 at 7:35

One simple method is using SubtractSides or AddSides

eq = 9 x == 5 y + 8 z + 27;
eqZeroForm = SubtractSides[eq, Last[eq]]
eqZeroForm1 = SubtractSides[eq, First[eq]]

myeq = CoplanarPoints[{{7, 4, 2}, {8, 1, 5}, {9, 6, 3}, {x, y, z}}]

(myeq /. Equal :> Subtract) == 0