3.4 Factorizations

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 $ (p_i, e_i)$ , where $ p_i$ is prime and $ e_i$ 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 $ \mathbf{Z}[x]$ , the integer $ -5$ 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 $ \mathbf{Z}$ , 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

Factorization_deduce_unit( x, mul)

Class: Factorization

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

Factorization( self, x, [unit=None])

Functions: mul,$  $ prod,$  $ unit,$  $ unit_part,$  $ value

prod( self)

Same as self.mul().

unit( self)

Return the unit part of this factorization.

sage: F = factor(-2006); F
-1 * 2 * 17 * 59
sage: F.unit()
-1

unit_part( self)

Same as self.unit().

value( 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_

__add__( self, other)

Return the sum of self and other.

sage: factor(-10) + 16
6
sage: factor(10) - 16
-6

__mul__( 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

__sub__( 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.