3
$\begingroup$

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$$

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

2 Answers 2

3
$\begingroup$
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 *)
$\endgroup$
4
  • $\begingroup$ 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. :-) $\endgroup$
    – Mr.Wizard
    Commented Apr 15, 2015 at 17:20
  • $\begingroup$ @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 -:) $\endgroup$
    – kglr
    Commented Apr 15, 2015 at 17:31
  • $\begingroup$ It's good that you're ready to step up in case a brick falls on my head or something. ;^) $\endgroup$
    – Mr.Wizard
    Commented Apr 15, 2015 at 17:34
  • $\begingroup$ Lord forbid Mr.W. $\endgroup$
    – kglr
    Commented Apr 15, 2015 at 17:43
0
$\begingroup$
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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.