4
$\begingroup$

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.

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

In maxima (the algebra/calculus motor in SAGE) what I've done is to collect the roots in an array and then redo the polynomial as the product of its factors. This is messy to write as a function, but then you can just use it.

$\endgroup$
  • $\begingroup$ Hi @vonbrand! So if you already wrote that function, would be able to share it here? I'd really appreciate it :-D $\endgroup$ – Rodrigo Apr 12 '14 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.