# Factored R¶

fr.spad line 1 [edit on github]

Factored creates a domain whose objects are kept in factored form as long as possible. Thus certain operations like multiplication and `gcd`

are relatively easy to do. Others, like addition require somewhat more work, and unless the argument domain provides a factor function, the result may not be completely factored. Each object consists of a unit and a list of factors, where a factor has a member of `R`

(the “base”), and exponent and a flag indicating what is known about the base. A flag may be one of “nil”, “sqfr”, “irred” or “prime”, which respectively mean that nothing is known about the base, it is square-free, it is irreducible, or it is prime. The current restriction to integral domains allows simplification to be performed without worrying about multiplication order.

- 0: %
from AbelianMonoid

- 1: %
from MagmaWithUnit

- *: (%, %) -> %
from LeftModule %

- *: (%, R) -> %
from RightModule R

- *: (Integer, %) -> %
from AbelianGroup

- *: (NonNegativeInteger, %) -> %
from AbelianMonoid

- *: (PositiveInteger, %) -> %
from AbelianSemiGroup

- *: (R, %) -> %
from LeftModule R

- +: (%, %) -> %
from AbelianSemiGroup

- -: % -> %
from AbelianGroup

- -: (%, %) -> %
from AbelianGroup

- ^: (%, NonNegativeInteger) -> %
from MagmaWithUnit

- ^: (%, PositiveInteger) -> %
from Magma

- annihilate?: (%, %) -> Boolean
from Rng

- antiCommutator: (%, %) -> %

- associates?: (%, %) -> Boolean
from EntireRing

- associator: (%, %, %) -> %
from NonAssociativeRng

- characteristic: () -> NonNegativeInteger
from NonAssociativeRing

- coerce: % -> %
from Algebra %

- coerce: % -> OutputForm
from CoercibleTo OutputForm

- coerce: Fraction Integer -> % if R has RetractableTo Fraction Integer
from CoercibleFrom Fraction Integer

- coerce: Integer -> %
from NonAssociativeRing

- coerce: R -> %
from CoercibleFrom R

- commutator: (%, %) -> %
from NonAssociativeRng

- convert: % -> DoubleFloat if R has RealConstant
from ConvertibleTo DoubleFloat

- convert: % -> Float if R has RealConstant
from ConvertibleTo Float

- convert: % -> InputForm if R has ConvertibleTo InputForm
from ConvertibleTo InputForm

- D: % -> % if R has DifferentialRing
from DifferentialRing

- D: (%, List Symbol) -> % if R has PartialDifferentialRing Symbol
- D: (%, List Symbol, List NonNegativeInteger) -> % if R has PartialDifferentialRing Symbol
- D: (%, NonNegativeInteger) -> % if R has DifferentialRing
from DifferentialRing

- D: (%, R -> R) -> %
from DifferentialExtension R

- D: (%, R -> R, NonNegativeInteger) -> %
from DifferentialExtension R

- D: (%, Symbol) -> % if R has PartialDifferentialRing Symbol
- D: (%, Symbol, NonNegativeInteger) -> % if R has PartialDifferentialRing Symbol

- differentiate: % -> % if R has DifferentialRing
from DifferentialRing

- differentiate: (%, List Symbol) -> % if R has PartialDifferentialRing Symbol
- differentiate: (%, List Symbol, List NonNegativeInteger) -> % if R has PartialDifferentialRing Symbol
- differentiate: (%, NonNegativeInteger) -> % if R has DifferentialRing
from DifferentialRing

- differentiate: (%, R -> R) -> %
from DifferentialExtension R

- differentiate: (%, R -> R, NonNegativeInteger) -> %
from DifferentialExtension R

- differentiate: (%, Symbol) -> % if R has PartialDifferentialRing Symbol
- differentiate: (%, Symbol, NonNegativeInteger) -> % if R has PartialDifferentialRing Symbol

- elt: (%, %) -> % if R has Eltable(%, %)
from Eltable(%, %)

- elt: (%, R) -> % if R has Eltable(R, R)
from Eltable(R, %)

- eval: (%, %, %) -> % if R has Evalable %
from InnerEvalable(%, %)

- eval: (%, Equation %) -> % if R has Evalable %
from Evalable %

- eval: (%, Equation R) -> % if R has Evalable R
from Evalable R

- eval: (%, List %, List %) -> % if R has Evalable %
from InnerEvalable(%, %)

- eval: (%, List Equation %) -> % if R has Evalable %
from Evalable %

- eval: (%, List Equation R) -> % if R has Evalable R
from Evalable R

- eval: (%, List R, List R) -> % if R has Evalable R
from InnerEvalable(R, R)

- eval: (%, List Symbol, List %) -> % if R has InnerEvalable(Symbol, %)
from InnerEvalable(Symbol, %)

- eval: (%, List Symbol, List R) -> % if R has InnerEvalable(Symbol, R)
from InnerEvalable(Symbol, R)

- eval: (%, R, R) -> % if R has Evalable R
from InnerEvalable(R, R)

- eval: (%, Symbol, %) -> % if R has InnerEvalable(Symbol, %)
from InnerEvalable(Symbol, %)

- eval: (%, Symbol, R) -> % if R has InnerEvalable(Symbol, R)
from InnerEvalable(Symbol, R)

- expand: % -> R
`expand(f)`

multiplies the unit and factors together, yielding an “unfactored” object. Note: this is purposely not called coerce which would cause the interpreter to do this automatically.

- exquo: (%, %) -> Union(%, failed)
from EntireRing

- factor: % -> Factored % if R has UniqueFactorizationDomain

- factorList: % -> List Record(flag: Union(nil, sqfr, irred, prime), factor: R, exponent: NonNegativeInteger)
`factorList(u)`

returns the list of factors with flags (for use by factoring code).

- factors: % -> List Record(factor: R, exponent: NonNegativeInteger)
`factors(u)`

returns a list of the factors in a form suitable for iteration. That is, it returns a list where each element is a record containing a base and exponent. The original object is the product of all the factors and the unit (which can be extracted by`unit(u)`

).

- flagFactor: (R, NonNegativeInteger, Union(nil, sqfr, irred, prime)) -> %
`flagFactor(base, exponent, flag)`

creates a factored object with a single factor whose`base`

is asserted to be properly described by the information flag.

- gcdPolynomial: (SparseUnivariatePolynomial %, SparseUnivariatePolynomial %) -> SparseUnivariatePolynomial % if R has GcdDomain
from GcdDomain

- irreducibleFactor: (R, NonNegativeInteger) -> %
`irreducibleFactor(base, exponent)`

creates a factored object with a single factor whose`base`

is asserted to be irreducible (flag = “irred”).

- latex: % -> String
from SetCategory

- lcmCoef: (%, %) -> Record(llcm_res: %, coeff1: %, coeff2: %) if R has GcdDomain
from LeftOreRing

- leftPower: (%, NonNegativeInteger) -> %
from MagmaWithUnit

- leftPower: (%, PositiveInteger) -> %
from Magma

- leftRecip: % -> Union(%, failed)
from MagmaWithUnit

- makeFR: (R, List Record(flag: Union(nil, sqfr, irred, prime), factor: R, exponent: NonNegativeInteger)) -> %
`makeFR(unit, listOfFactors)`

creates a factored object (for use by factoring code).

- map: (R -> R, %) -> %
`map(fn, u)`

maps the function userfun{`fn`

} across the factors of spadvar{`u`

} and creates a new factored object. Note: this clears the information flags (sets them to “nil”) because the effect of userfun{`fn`

} is clearly not known in general.

- mergeFactors: (%, %) -> %
`mergeFactors(u, v)`

is used when the factorizations of spadvar{`u`

} and spadvar{`v`

} are known to be disjoint, e.g. resulting from a content/primitive part split. Essentially, it creates a new factored object by multiplying the units together and appending the lists of factors.

- nilFactor: (R, NonNegativeInteger) -> %
`nilFactor(base, exponent)`

creates a factored object with a single factor with no information about the kind of`base`

(flag = “nil”).

- numberOfFactors: % -> NonNegativeInteger
`numberOfFactors(u)`

returns the number of factors in spadvar{`u`

}.

- one?: % -> Boolean
from MagmaWithUnit

- opposite?: (%, %) -> Boolean
from AbelianMonoid

- plenaryPower: (%, PositiveInteger) -> %
from NonAssociativeAlgebra %

- prime?: % -> Boolean if R has UniqueFactorizationDomain

- primeFactor: (R, NonNegativeInteger) -> %
`primeFactor(base, exponent)`

creates a factored object with a single factor whose`base`

is asserted to be prime (flag = “prime”).

- rational?: % -> Boolean if R has IntegerNumberSystem
`rational?(u)`

tests if spadvar{`u`

} is actually a rational number (see Fraction Integer).

- rational: % -> Fraction Integer if R has IntegerNumberSystem
`rational(u)`

assumes spadvar{`u`

} is actually a rational number and does the conversion to rational number (see Fraction Integer).

- rationalIfCan: % -> Union(Fraction Integer, failed) if R has IntegerNumberSystem
`rationalIfCan(u)`

returns a rational number if`u`

really is one, and “failed” otherwise.

- recip: % -> Union(%, failed)
from MagmaWithUnit

- retract: % -> Fraction Integer if R has RetractableTo Fraction Integer
from RetractableTo Fraction Integer

- retract: % -> Integer if R has RetractableTo Integer
from RetractableTo Integer

- retract: % -> R
from RetractableTo R

- retractIfCan: % -> Union(Fraction Integer, failed) if R has RetractableTo Fraction Integer
from RetractableTo Fraction Integer

- retractIfCan: % -> Union(Integer, failed) if R has RetractableTo Integer
from RetractableTo Integer

- retractIfCan: % -> Union(R, failed)
from RetractableTo R

- rightPower: (%, NonNegativeInteger) -> %
from MagmaWithUnit

- rightPower: (%, PositiveInteger) -> %
from Magma

- rightRecip: % -> Union(%, failed)
from MagmaWithUnit

- sample: %
from AbelianMonoid

- sqfrFactor: (R, NonNegativeInteger) -> %
`sqfrFactor(base, exponent)`

creates a factored object with a single factor whose`base`

is asserted to be square-free (flag = “sqfr”).

- squareFree: % -> Factored % if R has UniqueFactorizationDomain

- squareFreePart: % -> % if R has UniqueFactorizationDomain

- subtractIfCan: (%, %) -> Union(%, failed)

- unit?: % -> Boolean
from EntireRing

- unit: % -> R
`unit(u)`

extracts the unit part of the factorization.

- unitCanonical: % -> %
from EntireRing

- unitNormal: % -> Record(unit: %, canonical: %, associate: %)
from EntireRing

- unitNormalize: % -> %
`unitNormalize(u)`

normalizes the unit part of the factorization. For example, when working with factored integers, this operation will ensure that the bases are all positive integers.

- zero?: % -> Boolean
from AbelianMonoid

Algebra %

Algebra R

BiModule(%, %)

BiModule(R, R)

CoercibleFrom Fraction Integer if R has RetractableTo Fraction Integer

CoercibleFrom Integer if R has RetractableTo Integer

ConvertibleTo DoubleFloat if R has RealConstant

ConvertibleTo Float if R has RealConstant

ConvertibleTo InputForm if R has ConvertibleTo InputForm

DifferentialRing if R has DifferentialRing

Eltable(%, %) if R has Eltable(%, %)

Eltable(R, %) if R has Eltable(R, R)

Evalable % if R has Evalable %

Evalable R if R has Evalable R

InnerEvalable(%, %) if R has Evalable %

InnerEvalable(R, R) if R has Evalable R

InnerEvalable(Symbol, %) if R has InnerEvalable(Symbol, %)

InnerEvalable(Symbol, R) if R has InnerEvalable(Symbol, R)

LeftOreRing if R has GcdDomain

Module %

Module R

PartialDifferentialRing Symbol if R has PartialDifferentialRing Symbol

RealConstant if R has RealConstant

RetractableTo Fraction Integer if R has RetractableTo Fraction Integer

RetractableTo Integer if R has RetractableTo Integer

UniqueFactorizationDomain if R has UniqueFactorizationDomain