I have a large list list of integer polynomials, all of which are the output of Factor. So my list looks something like this: {... x^2 + 1, (-1 + x)(x^2 + x + 1) ...}

Now I want to do further analysis of the reducible elements of list. The problem is that I do not want to check each polynomial again by IrreduciblePolynomialQ because I already know which are irreducible (they are the ones which are not factored.)

Q: What efficient way is there to check if a polynomial is in factored form? I.e. a function isF such that isF[(-1 + x)(1 + x + x^2)] returns True but isF[-1 + x^3] and isF[1 + x + x^2] return False. I suppose isF could simply check if ( appears in its input, but I'm not sure how to do that.


1 Answer 1


You can check whether the Head of the expression is Plus, which is associated with a non-factored polynomial:

list = {  1 + x^2,
        (-1 + x) (1 + x + x^2),
        (1 + x)^2,
        2 (2 + x + x^2), 
        2 (2 + x)^2

isF[Times[_Integer, poly_]] := isF[poly]
isF[poly_] := Head[poly] =!= Plus
SetAttributes[isF, Listable]


(* Out: {False, True, True, False, True} *)
  • $\begingroup$ What about something like the output of Factor[2 x + 2 x^2 + 4]? $\endgroup$
    – Carl Woll
    Mar 16, 2021 at 17:50
  • $\begingroup$ @Carl Good point. I added a definition to handle that. $\endgroup$
    – MarcoB
    Mar 16, 2021 at 18:00

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.