Module: sage.structure.factorization
Author: William Stein (2006-01-22): added unit part as suggested by D Kohel.
This example illustrates that the unit part is not discarded from factorizations.
sage: x = QQ['x'].0 sage: f = -5*(x-2)*(x-3) sage: f -5*x^2 + 25*x - 30 sage: F = f.factor(); F (-5) * (x - 3) * (x - 2) sage: F.unit() -5 sage: mul(F) # or F.mul() or F.prod() -5*x^2 + 25*x - 30
The underlying list is the list of pairs
, where
is prime and
is an integer. The unit part is discarded by
the list.
sage: list(F) [(x - 3, 1), (x - 2, 1)] sage: len(F) 2 sage: F[1] (x - 2, 1)
In the ring
, the integer
is not a unit, so the
factorization has three factors:
sage: x = ZZ['x'].0 sage: f = -5*(x-2)*(x-3) sage: f -5*x^2 + 25*x - 30 sage: F = f.factor(); F (-5) * (x - 3) * (x - 2) sage: F.unit() 1 sage: list(F) [(-5, 1), (x - 3, 1), (x - 2, 1)] sage: mul(F) # or F.mul() or F.prod() -5*x^2 + 25*x - 30 sage: len(F) 3
On the other hand, -1 is a unit in
, so it is included in the unit.
sage: x = ZZ['x'].0 sage: f = -1*(x-2)*(x-3) sage: F = f.factor(); F (-1) * (x - 3) * (x - 2) sage: F.unit() -1 sage: list(F) [(x - 3, 1), (x - 2, 1)]
Module-level Functions
x, mul) |
Class: Factorization
sage: N = 2006 sage: F = N.factor(); F 2 * 17 * 59 sage: F.unit() 1 sage: F = factor(-2006); F -1 * 2 * 17 * 59 sage: F.unit() -1 sage: loads(F.dumps()) == F True
self, x, [unit=None]) |
Functions: mul,
prod,
unit,
unit_part,
value
self) |
Same as self.mul()
.
self) |
Return the unit part of this factorization.
sage: F = factor(-2006); F -1 * 2 * 17 * 59 sage: F.unit() -1
self) |
Same as self.unit()
.
self) |
Return the product of the factors in the factorization, multiplied out.
sage: F = factor(2006); F 2 * 17 * 59 sage: F.value() 2006
Special Functions: __add__,
__mul__,
__reduce__,
__sub__,
_latex_,
_repr_
self, other) |
Return the sum of self and other.
sage: factor(-10) + 16 6 sage: factor(10) - 16 -6
self, other) |
Return the product of two factorizations.
sage: factor(-10) *factor(-16) 2^5 * 5 sage: factor(-10) *factor(16) -1 * 2^5 * 5
self, other) |
Return the sum of self and other.
sage: factor(-10) + 16 6 sage: factor(10) - 16 -6
See About this document... for information on suggesting changes.