From what I can see PolynomialQ will return False whenever some exponent is another variable such as here:
PolynomialQ[x^n, x]
Is there an alternative test that will return True for such a polynomial?
Motivation:
In another thread I need to use
Product[x^k (1 - x^k), {k, 1, n}]
for which Mathematica returns:
x^(1/2 n (1 + n)) QPochhammer[x, x, n]
However those two forms do not expand in the same way, for instance with $n=3$:
With[{n = 3},
Expand[{x^(1/2 n (1 + n)) QPochhammer[x, x, n], Product[x^k (1 - x^k), {k, 1, n}]}]]
(* {x^6 QPochhammer[x, x, 3], x^6 - x^7 - x^8 + x^10 + x^11 - x^12} *)
Indeed, Mathematica treats only the second expression as a polynomial:
With[{n = 3}, PolynomialQ[#, x] & /@
{x^(1/2 n (1 + n)) QPochhammer[x, x, n], Product[x^k (1 - x^k), {k, 1, n}]}]
(* {False, True} *)
even if I specify that n is integer as follows
f[x_, n_Integer] := x^(1/2 n (1 + n)) QPochhammer[x, x, n];
PolynomialQ[f[n], x]
(* False *)
polyafter replacing integer variables by 1. I would like to avoid being tricked if I testpQ[x^(1/n), x, n](returnsTrue). – A.G. Dec 23 '13 at 04:55FunctionExpandto expand the two expressions in the same way. – xzczd Dec 23 '13 at 06:17