# In SAGE, what function factors a polynomial whose coefficients are parameters?

In SAGE the function "factor" will factorize elementary polynomials with coefficients in $\Bbb Q$. For example:

x,y = var('x,y')

poly = x^3-y^2*x

factor(poly)

SAGE: x*(x-y)*(x+y)

Apparently, "factor" will also handle any univariate polynomial with roots in $\Bbb Q$ (I applied factor to things like $\prod_{i\in I}(x-i)$, for subsets $I\subset \Bbb Q$ with cardinality up to 10.) I assume the function factor just clears the denominators and then tries any factor of the constant coefficient as a root, for as soon as I wrote some algebraic number like $\sqrt 3$ for one of the $i$'s, "factor" refused to do anything to my expanded expression. To be precise, it still factored $(x-1)(x-\sqrt 3)$, but neither $x^2-2$ nor $(x-1)(x-\sqrt 3)(x-2)$.

This is very frustrating since very often I have some small degree polynomial that I want to factor whose coefficients depend on several parameters. Is there another function in SAGE that will just plug these other parameters into the well-known formulas for the roots of quadratic, cubic and quartic and factor my polynomial for me? I know the alternative of using solve, but it has the draw back that I need to copy and paste each one of the roots and rewrite my polynomial.

• Have you tried asking here? ask.sagemath.org/questions – wckronholm Apr 11 '14 at 20:31
• @wckronholm yeah but unfortunately I need some karma points to ask my first question :-( – Rodrigo Apr 12 '14 at 0:59