# Arranging sides of an equation [duplicate]

I have to create my own function to solve equations (first and second degree). Assuming you have any input equation, how can I do to bring everything to the first side of the equation?

Example. I have:

eq=3*x+2==-2*x^2+4


but I'd like to have:

eq=2*x^2+3*x-2==0


Thanks.

• (Subtract @@ eq) == 0 should work. – J. M.'s technical difficulties May 10 '16 at 12:03
• – Kuba May 10 '16 at 12:23
• I use the similar (eq /. Equal -> Subtract) == 0, which will work at any level of a list – KraZug May 10 '16 at 12:45
• @KraZug thanks for solution !! – RossFe May 10 '16 at 13:16
• Actually I should have said that (eq /. Equal -> Subtract) works at any level of the list, but setting it to be equal to 0 would need Thread applying at the appropriate levels. If you just want the left hand side it works fine. – KraZug May 10 '16 at 13:29

I tend to use Equal -> Subtract to move from equalities to having everything on the left hand side, i.e.

(eq /. Equal -> Subtract)
-2 + 3 x + 2 x^2


If you want them to back to equations then here is a function that will allow it to be applied at any level of a list (rather than needing to use Thread):

rearrangeLeft[a_, b_] := a - b == 0
rearrangeLeftApply[x_] := x /. Equal -> rearrangeLeft


So applying to a nested list:

rearrangeLeftApply[{eq, {eq}, {{{eq}}}}]
{-2 + 3 x + 2 x^2 == 0, {-2 + 3 x + 2 x^2 == 0}, {{{-2 + 3 x + 2 x^2 == 0}}}}

• Incidentally I'm terrible at naming functions, and couldn't figure out how to write the Apply function without defining the intermediate function – KraZug May 11 '16 at 12:45