# Revision history [back]

Actually, it's just that factor isn't defined on univariate polynomials over SR. If charpoly were returned as an element of SR, there could be trouble if the matrix already contains an x, as in matrix([SR('x')]).charpoly(). You can put it in SR and then you can factor it:

sage: factor(f(SR('x')))
(a^2 + a*b + b*c - 2*a*x - b*x + x^2)*(x - 1)


Actually, it's just that factor isn't defined on univariate polynomials over SR. If charpoly were returned as an element of SR, there could be trouble if the matrix already contains an x, as in matrix([SR('x')]).charpoly(). You can put it in SR and then you can factor it:

sage: factor(f(SR('x')))
(a^2 + a*b + b*c - 2*a*x - b*x + x^2)*(x - 1)


As you can see:

sage: parent(f)
Univariate Polynomial Ring in x over Symbolic Ring


the polynomial f doesn't lie in SR, but in a univariate polynomial over SR. By evaluating the polynomial in an element of SR we can map it into SR, though. With SR('x') you create the symbol x. You can also use SR.var('x') if you prefer. It's different from the variable in which f is expressed, even though they print the same:

sage: parent(f).0
x
sage: parent(f).0 == SR('x')
False