Skip to main content
added 386 characters in body
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198

The number of polynomials is not so great in your original case: just generate them all programmatically, and test each one for irreducibility using IrreduciblePolynomialQ, which seems faster than actually doing the factorization using Factor:

p[x_, y_] = Total[Table[a[i, j] x^(i - 1) y^(j - 1), {i, 1, 3}, {j, 1, 3}], 2];
polynomials = p[x, y] /. Thread[Flatten[Array[a, {3, 3}]] -> #] & /@ Tuples[{1, -1}, {9}];

# -> IrreduciblePolynomialQ[#] & /@ polynomials

(* Out:

{1 + x + x^2 + y + x y + x^2 y + y^2 + x y^2 + x^2 y^2 -> False, 
 1 + x + x^2 + y + x y + x^2 y + y^2 + x y^2 - x^2 y^2 -> True, 
 1 + x + x^2 + y + x y - x^2 y + y^2 + x y^2 + x^2 y^2 -> True, 
 1 + x + x^2 + y + x y - x^2 y + y^2 + x y^2 - x^2 y^2 -> True, 
 1 + x - x^2 + y + x y + x^2 y + y^2 + x y^2 + x^2 y^2 -> True, 
 ...
}
*)

The process is relatively fast with this relatively small number of expression:

# -> IrreduciblePolynomialQ[#] & /@ polynomials; // RepeatedTiming

(* Out: {0.383, Null} *)

The number of polynomials is not so great: just generate them all programmatically, and test each one for irreducibility:

p[x_, y_] = Total[Table[a[i, j] x^(i - 1) y^(j - 1), {i, 1, 3}, {j, 1, 3}], 2];
polynomials = p[x, y] /. Thread[Flatten[Array[a, {3, 3}]] -> #] & /@ Tuples[{1, -1}, {9}];

# -> IrreduciblePolynomialQ[#] & /@ polynomials

(* Out:

{1 + x + x^2 + y + x y + x^2 y + y^2 + x y^2 + x^2 y^2 -> False, 
 1 + x + x^2 + y + x y + x^2 y + y^2 + x y^2 - x^2 y^2 -> True, 
 1 + x + x^2 + y + x y - x^2 y + y^2 + x y^2 + x^2 y^2 -> True, 
 1 + x + x^2 + y + x y - x^2 y + y^2 + x y^2 - x^2 y^2 -> True, 
 1 + x - x^2 + y + x y + x^2 y + y^2 + x y^2 + x^2 y^2 -> True, 
 ...
}
*)

The number of polynomials is not so great in your original case: just generate them all programmatically, and test each one for irreducibility using IrreduciblePolynomialQ, which seems faster than actually doing the factorization using Factor:

p[x_, y_] = Total[Table[a[i, j] x^(i - 1) y^(j - 1), {i, 1, 3}, {j, 1, 3}], 2];
polynomials = p[x, y] /. Thread[Flatten[Array[a, {3, 3}]] -> #] & /@ Tuples[{1, -1}, {9}];

# -> IrreduciblePolynomialQ[#] & /@ polynomials

(* Out:

{1 + x + x^2 + y + x y + x^2 y + y^2 + x y^2 + x^2 y^2 -> False, 
 1 + x + x^2 + y + x y + x^2 y + y^2 + x y^2 - x^2 y^2 -> True, 
 1 + x + x^2 + y + x y - x^2 y + y^2 + x y^2 + x^2 y^2 -> True, 
 1 + x + x^2 + y + x y - x^2 y + y^2 + x y^2 - x^2 y^2 -> True, 
 1 + x - x^2 + y + x y + x^2 y + y^2 + x y^2 + x^2 y^2 -> True, 
 ...
}
*)

The process is relatively fast with this relatively small number of expression:

# -> IrreduciblePolynomialQ[#] & /@ polynomials; // RepeatedTiming

(* Out: {0.383, Null} *)
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198

The number of polynomials is not so great: just generate them all programmatically, and test each one for irreducibility:

p[x_, y_] = Total[Table[a[i, j] x^(i - 1) y^(j - 1), {i, 1, 3}, {j, 1, 3}], 2];
polynomials = p[x, y] /. Thread[Flatten[Array[a, {3, 3}]] -> #] & /@ Tuples[{1, -1}, {9}];

# -> IrreduciblePolynomialQ[#] & /@ polynomials

(* Out:

{1 + x + x^2 + y + x y + x^2 y + y^2 + x y^2 + x^2 y^2 -> False, 
 1 + x + x^2 + y + x y + x^2 y + y^2 + x y^2 - x^2 y^2 -> True, 
 1 + x + x^2 + y + x y - x^2 y + y^2 + x y^2 + x^2 y^2 -> True, 
 1 + x + x^2 + y + x y - x^2 y + y^2 + x y^2 - x^2 y^2 -> True, 
 1 + x - x^2 + y + x y + x^2 y + y^2 + x y^2 + x^2 y^2 -> True, 
 ...
}
*)