4
$\begingroup$

I have the polynomial

5x^4 - 6x^3*y - 3x^2*y^2 - 3x*y^3 - y^4 + x^8 + x^7 + x^7*y + 4x^6*y^2 + x^6*y^2 + x^6*y + x^6 + x^5*y^3 + 4x^5*y^3 + 4x^5*y^2 - x^5*y^2 + x^5*y + x^4*y^4 + x^4*y^4 + x^4*y^4 + x^4*y^3 - x^4*y^3 + x^4*y^2 + 3x^4*y^2 + 3x^3*y^5 + x^3*y^5 + x^3*y^4 - x^3*y^4 + x^3*y^3 + x^3*y^3 + x^2*y^6 + x^2*y^6 - x^2*y^5 + x^2*y^4 + x^2*y^4 + x*y^7 - x*y^6 + 6x*y^5 + y^8 + y^6 - x^3 + x*y^2 + 5x^6 + x^5 - 4x^4*y^2 + 3x^4 - 7x^3*y^2 + x^2*y^4 + x^2*y^2 - x*y^4 + y^4

how can I get a list with all the pairs of its exponents?

$\endgroup$
1
  • 4
    $\begingroup$ Denoting your polynomial as expr, then CoefficientRules[expr][[All,1]] returns {{8,0},{7,1},{7,0},{6,2},{6,1},{6,0},<<18>>,{1,4},{1,3},{1,2},{0,8},{0,6}} $\endgroup$
    – Lacia
    Commented Sep 14, 2022 at 22:30

3 Answers 3

4
$\begingroup$

I get a list with all the pairs of its exponents?

One way could be

p = 5 x^4 - 6 x^3*y - 3 x^2*y^2 - 3 x*y^3 - y^4 + x^8 + x^7 + x^7*y + 
  4 x^6*y^2 + x^6*y^2 + x^6*y + x^6 + x^5*y^3 + 4 x^5*y^3 + 
  4 x^5*y^2 - x^5*y^2 + x^5*y + x^4*y^4 + x^4*y^4 + x^4*y^4 + 
  x^4*y^3 - x^4*y^3 + x^4*y^2 + 3 x^4*y^2 + 3 x^3*y^5 + x^3*y^5 + 
  x^3*y^4 - x^3*y^4 + x^3*y^3 + x^3*y^3 + x^2*y^6 + x^2*y^6 - 
  x^2*y^5 + x^2*y^4 + x^2*y^4 + x*y^7 - x*y^6 + 6 x*y^5 + y^8 + y^6 - 
  x^3 + x*y^2 + 5 x^6 + x^5 - 4 x^4*y^2 + 3 x^4 - 7 x^3*y^2 + 
  x^2*y^4 + x^2*y^2 - x*y^4 + y^4

Mathematica graphics

Then

 Map[Exponent[#, {x, y}] &, List @@ p]

Mathematica graphics

$\endgroup$
1
$\begingroup$
expr = 5 x^4 - 6 x^3*y - 3 x^2*y^2 - 3 x*y^3 - y^4 + x^8 + x^7 + 
  x^7*y + 4 x^6*y^2 + x^6*y^2 + x^6*y + x^6 + x^5*y^3 + 4 x^5*y^3 + 
  4 x^5*y^2 - x^5*y^2 + x^5*y + x^4*y^4 + x^4*y^4 + x^4*y^4 + 
  x^4*y^3 - x^4*y^3 + x^4*y^2 + 3 x^4*y^2 + 3 x^3*y^5 + x^3*y^5 + 
  x^3*y^4 - x^3*y^4 + x^3*y^3 + x^3*y^3 + x^2*y^6 + x^2*y^6 - 
  x^2*y^5 + x^2*y^4 + x^2*y^4 + x*y^7 - x*y^6 + 6 x*y^5 + y^8 + y^6 - 
  x^3 + x*y^2 + 5 x^6 + x^5 - 4 x^4*y^2 + 3 x^4 - 7 x^3*y^2 + 
  x^2*y^4 + x^2*y^2 - x*y^4 + y^4;

As an exercise in pattern matching:

expr /. {Plus -> List
  , Times[_, Power[x, b_], Power[y, c_]] :> {b, c}
  , Times[___, x, Power[y, c_]] :> {1, c}
  , Times[___, Power[x, b_], y] :> {b, 1}
  , Times[_, Power[x, b_]] :> {b, 0}
  , Times[_, Power[y, c_]] :> {0, c}
  , Power[x, b_] :> {b, 0}
  , Power[y, b_] :> {0, b}
  }

Result

{{3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {3, 1}, {5, 1}, {6, 
  1}, {7, 1}, {1, 2}, {2, 2}, {3, 2}, {5, 2}, {6, 2}, {1, 3}, {3, 
  3}, {5, 3}, {1, 4}, {2, 4}, {4, 4}, {1, 5}, {2, 5}, {3, 5}, {0, 
  6}, {1, 6}, {2, 6}, {1, 7}, {0, 8}}
$\endgroup$
1
$\begingroup$

I assume that the polynomial does not need to be held in the form you list? It simplifies to:

-x^3 + 8 x^4 + x^5 + 6 x^6 + x^7 + x^8 - 6 x^3 y + x^5 y + x^6 y + x^7 y + x y^2 - 2 x^2 y^2 - 7 x^3 y^2 + 3 x^5 y^2 + 5 x^6 y^2 - 3 x y^3 + 2 x^3 y^3 + 5 x^5 y^3 - x y^4 + 3 x^2 y^4 + 3 x^4 y^4 + 6 x y^5 - x^2 y^5 + 4 x^3 y^5 + y^6 - x y^6 + 2 x^2 y^6 + x y^7 + y^8

In that case:

a = 5 x^4 - 6 x^3*y - 3 x^2*y^2 - 3 x*y^3 - y^4 + x^8 + x^7 + x^7*y + 
   4 x^6*y^2 + x^6*y^2 + x^6*y + x^6 + x^5*y^3 + 4 x^5*y^3 + 
   4 x^5*y^2 - x^5*y^2 + x^5*y + x^4*y^4 + x^4*y^4 + x^4*y^4 + 
   x^4*y^3 - x^4*y^3 + x^4*y^2 + 3 x^4*y^2 + 3 x^3*y^5 + x^3*y^5 + 
   x^3*y^4 - x^3*y^4 + x^3*y^3 + x^3*y^3 + x^2*y^6 + x^2*y^6 - 
   x^2*y^5 + x^2*y^4 + x^2*y^4 + x*y^7 - x*y^6 + 6 x*y^5 + y^8 + y^6 -
    x^3 + x*y^2 + 5 x^6 + x^5 - 4 x^4*y^2 + 3 x^4 - 7 x^3*y^2 + 
   x^2*y^4 + x^2*y^2 - x*y^4 + y^4;

b = a /. _Integer*z_ -> 1*z

c = b /. {Times[Power[x, a_], y] -> HoldForm[{a, 1}]}

d = c /. (x^a_*y^b_) -> HoldForm[{a, b}]

e = d /. {x^a_ -> HoldForm[{a, 0}], y^b_ -> HoldForm[{0, b}]}

f = e /. Times[x, HoldForm[List[a_, b_]]] -> HoldForm[{a + 1, b}]

g = List @@ f

h = g /. HoldForm -> Sequence

Results in:

{{0, 6}, {0, 8}, {2, 2}, {2, 4}, {2, 5}, {2, 6}, {3, 0}, {3, 1}, {3, 
  2}, {3, 3}, {3, 5}, {4, 0}, {4, 4}, {5, 0}, {5, 1}, {5, 2}, {5, 
  3}, {6, 0}, {6, 1}, {6, 2}, {7, 0}, {7, 1}, {8, 0}, {1, 2}, {1, 
  3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}}

ETA: if you carry out g = List @@ f at the start, you won't need the HoldForm commands which keep Plus from evaluating.

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