Documentation Center |
Objects kept in factored form
This functionality does not run in MATLAB.
Factored(list, <type>, <ring>) Factored(f, <type>, <ring>)
Factored is the domain of objects kept in factored form, such as prime factorization of integers, square-free factorization of polynomials, or the factorization of polynomials in irreducible factors.
The argument list must be a list of odd length and of the form [u, f1, e1, f2, e2, ..., fr, er], where the entries u and f_{i} are elements of the domain ring, or can be converted into such elements. The e_{i} must be integers. Here, i ranges from 1 to r.
See section "Operands" below for the meaning of the entries of that list.
An error message is reported, if one of the list entries is of wrong type.
An arithmetical expression f given as the first argument is the same as giving the list [ring::one, f, 1].
See section "Operands" below for the meaning of the entries of that list.
f must be an element of the domain ring, or must be convertible into such an element, otherwise an error message would be given.
The argument type indicates what is known about the factorization. Currently, the following types are known:
"unknown" – nothing is known about the factorization.
"irreducible" – the f_{i} are irreducible over the domain ring.
"squarefree" – the f_{i} are square-free over the domain ring.
If this argument is missing, then the type of the created factored object is set to "unknown".
The type of factorization is known to any element of Factored. Use the methods "getType" and "setType" (see below) to read and set the type of factorization of a given factored object.
The argument ring is the ring of factorization. It must be an integral domain, i.e., a domain of category Cat::IntegralDomain.
If this argument is missing, then the domain Dom::ExpressionField() is used.
The ring of factorization is known to any element of Factored. Use the methods "getRing" and "setRing" (see below) to read and set the ring of factorization of a given factored object.
You can use the index operator [ ] to extract the factors of an element f of the domain Factored. E.g., for f = u f_{1}^{e1} f_{2}^{e2} …, you have f [1] = u, f [2] = f_{1}^{e1}, f [3] = f_{2}^{e2} etc.
You can also use the methods "factors" and "exponents" (see below) to access the operands, i.e., the call Factored::factors(f) returns a list of the factors f_{i}, and Factored::exponents(g) returns a list of the exponents e_{i} (1 ≤ i ≤ r).
The system functions ifactor, factor and polylib::sqrfree are the main application of this domain, they return their result in form of such factored objects (see their help pages for information about the type and ring of factorization).
There may be no need to explicitly create factored objects, but to work with the results of the mentioned system functions.
Note that an element of Factored is printed like an expression and behaves like that. As an example, the result of f := factor(x^2 + 2*x + 1) is an element of Factored and printed as (x + 1)^2. The call type(f) returns "_power" as the expression type of f.
For an element f of Factored, the call Factored::convert(f, DOM_LIST) gives a list of all operands of f.
The following computes the prime factorization of the integer 20:
f := ifactor(20)
The result is an element of the domain Factored:
domtype(f)
which consists of the following five operands:
op(f)
They represent the integer 20 in the following form: 20 = 1 2^{2} 5. The factors are prime numbers and can be extracted via Factor::factors:
Factored::factors(f)
ifactor kept the information that the factorization ring is the ring of integers (represented by the domain Dom::Integer), and that the factors of f are prime (and therefore irreducible, because ℤ is an integral domain):
Factored::getRing(f), Factored::getType(f)
We can convert such an object into different forms, such as into a list of its operands:
Factored::convert_to(f, DOM_LIST)
or into an unevaluated expression, keeping the factored form:
Factored::convert_to(f, DOM_EXPR)
or back into an integer:
Factored::convert_to(f, Dom::Integer)
You may also use the system function coerce here, which has the same effect.
We compute the factorization of the integers 108 and 512:
n1 := ifactor(108); n2 := ifactor(512)
The multiplication of these two integers gives the prime factorization of 55296 = 108 512:
n1*n2
Note that the most operations on such objects lead to an un-factored form, such as adding these two integers:
n1 + n2
You may apply the function ifactor to the result, if you are interested in its prime factorization:
ifactor(%)
You an apply (almost) each function to factored objects, functions that mainly expect arithmetical expressions as their input. Note that, before the operation is applied, the factored object is converted into an arithmetical expression in un-factored form:
Re(n1)
The second system function which deals with elements of Factored, is factor, which computes all irreducible factors of a polynomial.
For example, if we define the following polynomial of ℤ_{101}:
p := poly(x^12 + x + 1, [x], Dom::IntegerMod(101)):
and compute its factorization into irreducible factors, we get:
f := factor(p)
If we multiply the factored object with an element that can be converted into an element of the ring of factorization, then we get a new factored object, which then is of the factorization type "unknown":
x*f
Factored::getType(%)
You may use the function expand which returns the factored object in expanded form as an element of the factorization ring:
expand(f)
The third system function which return elements of Factored is polylib::sqrfree, which computes the square-free factorization of polynomials. For example:
f := polylib::sqrfree(x^2 + 2*x + 1)
The factorization type, of course, is "squarefree":
Factored::getType(f)
list |
A list of odd length |
f |
An arithmetical expression |
type |
A string (default: "unknown") |
ring |
A domain of category Cat::IntegralDomain (default: Dom::ExpressionField()) |
Calling a factored object as a function yields the object itself, regardless of the arguments. The arguments are not evaluated.
You can apply (almost) every function to factored objects, functions that mainly expect arithmetical expressions as their input.
For example, one may add or multiply those objects, or apply functions such as expand and diff to them. But the result of such an operation then is usually not any longer of the domain Factored, as the factored form could be lost due to the operation (see examples below).
Call expr(f) to convert the factored object f into an arithmetical expression (as an element of a kernel domain).
The call coerce(f, DOM_LIST) returns a list of operands of the factored object f (see method "convert_to" below).
An element f of Factored consists of the r + 1 operands u, f_{1}, e_{1}, f_{2}, e_{2}, …, f_{r}, e_{r}, such that f = u f_{1}^{e1} f_{2}^{e2} … f_{r}^{er}.
The first operand u and the factors f_{i} are elements of the domain ring. The exponents e_{i} are integers.