Factoring

### 11.1.18 Factoring

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 2.5.7), the field is complexified.

The factor command (see 9.1.10) will also factor polynomials over their coefficient fields (or extensions of it), but will further factor each factor of degree 2 if the sqrt box is checked in the CAS configuration.

#### Examples

Factor x2−4 over the integers.

collect(x^2-4)

Output (in real mode):

| ⎛ ⎝ | x−2 | ⎞ ⎠ | ⎛ ⎝ | x+2 | ⎞ ⎠

Factor x2+4 over the integers.

collect(x^2+4)

Output (in real mode):

x2+4 |  |  |  |  |  |  |  |  |  |

Output (in complex mode):

| ⎛ ⎝ | x+2i | ⎞ ⎠ | ⎛ ⎝ | x−2i | ⎞ ⎠

Factor x2−2 over the rationals.

collect(x^2-2)

Output (in real mode):

x2−2 |  |  |  |  |  |  |  |  |  |

But if you input:

collect(sqrt(2)*(x^2-2))

you get:

| √ |
2
|  | ⎛ ⎜ ⎝ | x− | √ |
2
| ⎞ ⎟ ⎠ | ⎛ ⎜ ⎝ | x+ | √ |
2
| ⎞ ⎟ ⎠

Factor x3−2x2+1 and x2−x over the rationals.

collect([x^3-2*x^2+1,x^2-x])

| ⎡ ⎣ | ⎛ ⎝ | x−1 | ⎞ ⎠ | ⎛ ⎝ | x2−x−1 | ⎞ ⎠ | ,x | ⎛ ⎝ | x−1 | ⎞ ⎠ | ⎤ ⎦

but:

collect((x^3-2*x^2+1)*sqrt(5))

| √ |
5
|  | ⎛ ⎜ ⎜ ⎝ | x+ |
− | √ |
5
| −1
2
| ⎞ ⎟ ⎟ ⎠ | ⎛ ⎝ | x−1 | ⎞ ⎠ | ⎛ ⎜ ⎜ ⎝ | x+ |
√ |
5
| −1
2
| ⎞ ⎟ ⎟ ⎠

or:

collect(x^3-2*x^2+1,sqrt(5))

| ⎛ ⎜ ⎜ ⎝ | x+ |
− | √ |
5
| −1
2
| ⎞ ⎟ ⎟ ⎠ | ⎛ ⎝ | x−1 | ⎞ ⎠ | ⎛ ⎜ ⎜ ⎝ | x+ |
√ |
5
| −1
2
| ⎞ ⎟ ⎟ ⎠