# Is there a function for "flattening out" and setting to 0 an expression?

For example if I have some complicated expression (all variables are positive integers) but I want to multiply everything out so there are no denominators and then rearrange so that it is equal to 0, is there a flattening function for this?

To provide an example:

$$x/y + x/y^2 + x/y^3 + x/y^4 = 4/x$$

I want to force it into form

$$x^2y^3 + x^2y^2 + x^2y + x^2 - 4y^4 = 0$$

• If you supply an example and your attempt to work it through, you will likely receive more assistance. Commented Apr 15, 2015 at 15:25
• @zentient Added an example
– AJJ
Commented Apr 15, 2015 at 15:58

eqn = x/y + x/y^2 + x/y^3 + x/y^4 == 4/x;

Numerator[Together[eqn /. Equal -> Subtract]] == 0


x^2+x^2 y+x^2 y^2+x^2 y^3-4 y^4==0

%// TeXForm


$x^2 y^3+x^2 y^2+x^2 y+x^2-4 y^4=0$

Or,

flttnF = Numerator[Together[# /. Equal -> Subtract]] == 0 &;
flttnF@eqn
(* same result *)

• By the way I see that you've surpassed Szabolcs on the boards and it looks like belisarius is next. It seems I may have a successor. :-) Commented Apr 15, 2015 at 17:20
• @Mr.Wizard, may be in a few months -- and that assuming belisarius, Szabolcs, Leonid or rm-rf will stay on vacation mode in the meantime -:)
– kglr
Commented Apr 15, 2015 at 17:31
• It's good that you're ready to step up in case a brick falls on my head or something. ;^) Commented Apr 15, 2015 at 17:34
• Lord forbid Mr.W.
– kglr
Commented Apr 15, 2015 at 17:43
flattenEqn[eqn_Equal] := Module[
{factor = Times @@ Denominator /@ (eqn // Together), eqn2},
eqn2 = factor*# & /@ eqn;
eqn2[[1]] - eqn2[[-1]] == 0 // Expand]

eqn = x/y + x/y^2 + x/y^3 + x/y^4 == 4/x;

flattenEqn[eqn]


x^2 + x^2*y + x^2*y^2 + x^2*y^3 - 4*y^4 == 0

Collect[#, x] & /@ %


-4*y^4 + x^2*(1 + y + y^2 + y^3) == 0