# Factored RΒΆ

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 Magma
- *: (%, R) -> %
- from RightModule R
- *: (Integer, %) -> %
- from AbelianGroup
- *: (NonNegativeInteger, %) -> %
- from AbelianMonoid
- *: (PositiveInteger, %) -> %
- from AbelianSemiGroup
- *: (R, %) -> %
- from LeftModule R
- +: (%, %) -> %
- from AbelianSemiGroup
- -: % -> %
- from AbelianGroup
- -: (%, %) -> %
- from AbelianGroup
- =: (%, %) -> Boolean
- from BasicType
- ^: (%, NonNegativeInteger) -> %
- from MagmaWithUnit
- ^: (%, PositiveInteger) -> %
- from Magma
- ~=: (%, %) -> Boolean
- from BasicType
- annihilate?: (%, %) -> Boolean
- from Rng
- antiCommutator: (%, %) -> %
- from NonAssociativeSemiRng
- 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 RetractableTo Fraction Integer
- coerce: Integer -> %
- from NonAssociativeRing
- coerce: R -> %
- from RetractableTo 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
- from PartialDifferentialRing Symbol
- D: (%, List Symbol, List NonNegativeInteger) -> % if R has PartialDifferentialRing Symbol
- from 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
- from PartialDifferentialRing Symbol
- D: (%, Symbol, NonNegativeInteger) -> % if R has PartialDifferentialRing Symbol
- from PartialDifferentialRing Symbol
- differentiate: % -> % if R has DifferentialRing
- from DifferentialRing
- differentiate: (%, List Symbol) -> % if R has PartialDifferentialRing Symbol
- from PartialDifferentialRing Symbol
- differentiate: (%, List Symbol, List NonNegativeInteger) -> % if R has PartialDifferentialRing Symbol
- from 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
- from PartialDifferentialRing Symbol
- differentiate: (%, Symbol, NonNegativeInteger) -> % if R has PartialDifferentialRing Symbol
- from 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.

- exponent: % -> Integer
`exponent(u)`

returns the exponent of the first factor of spadvar{`u`

}, or 0 if the factored form consists solely of a unit.- exquo: (%, %) -> Union(%, failed)
- from EntireRing
- factor: % -> Factored % if R has UniqueFactorizationDomain
- from UniqueFactorizationDomain

- factorList: % -> List Record(flg: Union(nil, sqfr, irred, prime), fctr: R, xpnt: Integer)
`factorList(u)`

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

- factors: % -> List Record(factor: R, exponent: Integer)
`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, Integer, 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.- gcd: (%, %) -> % if R has GcdDomain
- from GcdDomain
- gcd: List % -> % if R has GcdDomain
- from GcdDomain
- gcdPolynomial: (SparseUnivariatePolynomial %, SparseUnivariatePolynomial %) -> SparseUnivariatePolynomial % if R has GcdDomain
- from GcdDomain
- hash: % -> SingleInteger
- from SetCategory
- hashUpdate!: (HashState, %) -> HashState
- from SetCategory

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

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

is asserted to be irreducible (flag = “irred”).- latex: % -> String
- from SetCategory
- lcm: (%, %) -> % if R has GcdDomain
- from GcdDomain
- lcm: List % -> % if R has GcdDomain
- from GcdDomain
- 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(flg: Union(nil, sqfr, irred, prime), fctr: R, xpnt: Integer)) -> %
`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.

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

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

(flag = “nil”).

- nthExponent: (%, Integer) -> Integer
`nthExponent(u, n)`

returns the exponent of the`n`

th factor of spadvar{`u`

}. If spadvar{`n`

} is not a valid index for a factor (for example, less than 1 or too big), 0 is returned.

- nthFactor: (%, Integer) -> R
`nthFactor(u, n)`

returns the base of the`n`

th factor of spadvar{`u`

}. If spadvar{`n`

} is not a valid index for a factor (for example, less than 1 or too big), 1 is returned. If spadvar{`u`

} consists only of a unit, the unit is returned.

- nthFlag: (%, Integer) -> Union(nil, sqfr, irred, prime)
`nthFlag(u, n)`

returns the information flag of the`n`

th factor of spadvar{`u`

}. If spadvar{`n`

} is not a valid index for a factor (for example, less than 1 or too big), “nil” is returned.

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

returns the number of factors in spadvar{`u`

}.- one?: % -> Boolean
- from MagmaWithUnit
- opposite?: (%, %) -> Boolean
- from AbelianMonoid
- prime?: % -> Boolean if R has UniqueFactorizationDomain
- from UniqueFactorizationDomain

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

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

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

- 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).

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

tests if spadvar{`u`

} is actually a 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, Integer) -> %
`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
- from UniqueFactorizationDomain
- squareFreePart: % -> % if R has UniqueFactorizationDomain
- from UniqueFactorizationDomain
- subtractIfCan: (%, %) -> Union(%, failed)
- from CancellationAbelianMonoid

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

extracts the unit part of the factorization.- unit?: % -> Boolean
- from EntireRing
- 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)

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