1
$\begingroup$

I have a list of rational equations and I would like to convert it to a list of polynomial equations. I know that none of the variables and none of the denominators could ever be 0. So far I have tried:

removeDenom[ a_ == b_ ] := Numerator[a]Denominator[b] == Numerator[b]Denominator[a];

ratToPol[eqn_] := removeDenom @* Together @ eqn; 

Which seems to do the trick for rational equations with small exponents of the variables but for larger ones, e.g.

x[1]^24566482 x[2]^25894864 x[3]^36056313 x[5]^2 x[6]^2==(x[1]^10050244 x[2]^10878704 x[3]^15147675 x[6]^8)/x[5]^4+x[1]^39374641 x[2]^41453905 x[3]^57720898 x[5]^4 x[6]^2 x[7]^2

I get the error General::lrgexp Exponent is out of bounds for function 1.

Any ideas on how to proceed? It would be nice if there was a way without using Simplify or other higher-level functions for which it is unknown how they operate exactly.

$\endgroup$
2
  • 1
    $\begingroup$ Could use Numerator[Together[expressionList]].though this too will balk at large exponents. $\endgroup$ Commented Feb 23, 2020 at 16:28
  • $\begingroup$ How about 0 == (eqn /. Equal -> Subtract /. x[i_]^(j_ /; j > 0) -> x[i, j] // Together // Numerator) /. x[i_, j_] -> x[i]^j ? $\endgroup$
    – Akku14
    Commented Oct 20, 2020 at 10:33

2 Answers 2

1
$\begingroup$
Clear["Global`*"]

ratToPol[eqn_Equal] := Module[
  {prod = Times @@ Cases[eqn, t_ :> Denominator[t], 2]},
  Assuming[prod != 0, MultiplySides[eqn, prod] //
    Simplify]]

eqn = x[1]^24566482 x[2]^25894864 x[3]^36056313 x[5]^2 x[
      6]^2 ==
   (x[1]^10050244 x[2]^10878704 x[3]^15147675 x[6]^8)/
     x[5]^4 + 
    x[1]^39374641 x[2]^41453905 x[3]^57720898 x[5]^4 x[6]^2 x[7]^2;

Format[x[n_]] := Subscript[x, n]

eqn2 = ratToPol@eqn

enter image description here

Simplify[Or @@ Thread[(List @@ eqn2[[1]]) == 0]]

enter image description here

$\endgroup$
0
$\begingroup$

This function works for the example expression

removeDenom[a_ == b_] := Block[{
   u = Times @@ Denominator /@ a,
   v = Times @@ Denominator /@ b},
  Expand[u a v] == Expand[u b v]
  ]

It multiplies the LHS by all the denominators it finds on the RHS and vice versa.

The polynomialGCD error occurs in Together, so don't use ratToPol. Just use removeDenom[p]

Also, removeDenom does NOT play nice with subscripted variables u and v, but it seems to work with x.

$\endgroup$
1
  • $\begingroup$ Expand has the same problems. Also the code doesn't work: removeDenom[x + y - z + 1 == 1/x] returns 4+4x+4y-4z == 4/x :/ This because mapping Denominator on a sum gives the sum of the denominators. An alternative implementation using List@@ would be removedenom[a_ == b_] := With[{eq = a - b}, #[[1]]==#[[2]]&[ Times @@ Denominator[List @@ (eq + 1)]*# & /@ eq ] ] but then the result is unexpanded and indeed: Expand returns Expand::lrgexp: Exponent is out of bounds for function Expand. (although not consistently...) $\endgroup$
    – Gert
    Commented Oct 28, 2019 at 12:41

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.