6.27.16 Factoring: collect
The collect command factors polynomials over their coefficient
fields or extensions of the fields.
-
collect takes one mandatory and one optional argument:
-
P, a polynomial or a list of polynomials.
- Optionally, α, a number, such as √n,
determining an extension field to the field of coefficients of
P.
- collect(P ⟨ ,α⟩) returns
the factored form of the polynomial (or list of polynomials), where
the factorization is done over the field of coefficients (such as
ℚ) or the smallest extension field containing α
(e.g. ℚ[α]). In complex mode (see Section 3.5.7),
the field is complexified.
The factor command (see 6.12.10) will also factor
polynomials over their coefficient fields (or extensions of it), but
will further factor each factor of degree 2 if Sqrt is
checked in the cas configuration.
Examples.
-
Factor x2−4 over the integers,
Input:
collect(x^2-4)
Output (in real mode):
- Factor x2+4 over the integers:
Input:
collect(x^2+4)
Output (in real mode):
Output (in complex mode):
- Factor x2−2 over the rationals:
Input:
collect(x^2-2)
Output (in real mode):
But if you input:
collect(sqrt(2)*(x^2-2))
you get:
Output:
√ | | | ⎛
⎜
⎝ | x− | √ | | ⎞
⎟
⎠ | ⎛
⎜
⎝ | x+ | √ | | ⎞
⎟
⎠ |
- Factor x3−2x2+1 and x2−x over the rationals.
Input:
collect([x^3-2*x^2+1,x^2-x])
Output:
⎡
⎣ | ⎛
⎝ | x−1 | ⎞
⎠ | ⎛
⎝ | x2−x−1 | ⎞
⎠ | ,x | ⎛
⎝ | x−1 | ⎞
⎠ | ⎤
⎦ |
but:
Input:
collect((x^3-2*x^2+1)*sqrt(5))
Output:
√ | | | ⎛
⎜
⎜
⎝ | x+ | | ⎞
⎟
⎟
⎠ | ⎛
⎝ | x−1 | ⎞
⎠ | ⎛
⎜
⎜
⎝ | x+ | | ⎞
⎟
⎟
⎠ |
or:
Input:
collect(x^3-2*x^2+1,sqrt(5))
Output:
⎛
⎜
⎜
⎝ | x+ | | ⎞
⎟
⎟
⎠ | ⎛
⎝ | x−1 | ⎞
⎠ | ⎛
⎜
⎜
⎝ | x+ | | ⎞
⎟
⎟
⎠ |