# Why is this not a polynomial?

Subscript[x, 1] = (a x + b)/(c x + d);
CoefficientList[
Simplify[(α + β Subscript[x, 1] + γ Subscript[x,
1]^2) (D[Subscript[x, 1], x]^-1)] /. a d - b c -> 1, x]


gives

General::poly: "(d+c\x)^2\ (α+((b+a\x)(d\β+c\x\β+(b+a\x)\γ))/(d+c\x)^2) is not a polynomial."

This is strange, because

Simplify[(α + β Subscript[x, 1] + γ Subscript[x,
1]^2) (D[Subscript[x, 1], x]^-1)] /. a d - b c -> 1


always give

(c x+d)^2 (((a x+b) (γ (a x+b)+β c x+β d))/(c x+d)^2+α)

which should be the more simpler version

(a x+b) (γ (a x+b)+β c x+β d)+α (c x+d)^2

which is a polynomial.

BTW, how to get this question better formatted?

• You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this this meta Q&A helpful – Michael E2 Sep 16 '15 at 12:43

What you have there is in the form of a rational function:

Simplify[(α + β Subscript[x, 1] + γ Subscript[x, 1]^2) (D[Subscript[x, 1], x]^-1)]


If you Expand and then Simplify, you get a polynomial.

Subscript[x, 1] = (a x + b)/(c x + d);
CoefficientList[
Simplify@Expand[(α + β Subscript[x, 1] +
γ Subscript[x, 1]^2) (D[Subscript[x, 1], x]^-1)] /. a d - b c -> 1, x]
(*
{d^2 α + b d β + b^2 γ,
2 c d α + b c β + a d β + 2 a b γ,
c^2 α + a c β + a^2 γ}
*)


Checking the pieces of your computation, as in the first step above, is a good way to debug one's code.

• This appears to be a weakness in CoefficientList since its documentation states "CoefficientList works whether or not poly is explicitly given in expanded form." – Bob Hanlon Sep 16 '15 at 13:07
• @BobHanlon: I think "expanded" there means "multiplied out", which is what Expand does; Simplify is what cancels the factors in the denominator. Internally, CoefficientList probably tests for a polynomial by looking for an expression made out of Plus and Power objects the latter of which need to have positive second arguments. (Actually, it probably just calls PolynomialQ, but I would imagine that the above is what that latter function does internally.) – Michael Seifert Sep 16 '15 at 14:16
• That was great! Expand works very well. – eccstartup Sep 18 '15 at 10:47