| 1 | initial version |
The short (albeit not very interesting) answer is that E as a symbolic expression (first case), has a very different factor method than E as a polynomial (second case).
For example, consider:
sage: var('y t'); E = -2/3*y + 2/3 * t; type(E)
(y, t)
<type 'sage.symbolic.expression.Expression'>
Type one question mark to get the help (docstring), or two question marks to see what happens "under the hood" (read the code just after the docstring):
sage: E.factor()
2/3*t - 2/3*y
sage: E.factor??
Source:
def factor(self, dontfactor=[]):
"""
Factor the expression, containing any number of variables or functions, into
factors irreducible over the integers.
...
from sage.calculus.calculus import symbolic_expression_from_maxima_string, symbolic_expression_from_string
....
So factor here dispatches a suitable function from the Maxima interface.
Now, let's cast that symbolic expression into a polynomial
sage: P = E.polynomial(QQ); type(P)
<type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
sage: P.factor()
(2/3) * (t - y)
sage: P.factor??
Source:
def factor(self, proof=True):
"""
Return the factorization of this polynomial.
...
cdef ring *_ring = self._parent_ring
....
cdef MPolynomialRing_libsingular parent = self._parent
....
.... return Factorization(list(U) + FF, unit=U.unit())
so if i get it right, in this case Sage makes use of the Factorization function of the CAS for polynomial computations Singular.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.