Factorization : collect

### 5.29.15 Factorization : collect

collect takes as argument a polynomial or a list of polynomials and optionally an algebraic extension like sqrt(n) (for √n).
collect factorizes the polynomial (or the polynomials in the list) on the field of its coefficient (for example ℚ) or on the smallest extension containing the optional second argument (e.g. ℚ[√n]). In complex mode, the field is complexified.
Examples :

- Factorize x2−4 over the integers, input :
  collect(x`^`2-4)
  Output in real mode :
  (x-2)*(x+2)
- Factorize x2+4 over the integers, input :
  collect(x`^`2+4)
  Output in real mode :
  x`^`2+4
  Output in complex mode :
  (x+2*i)*(x-2*i)
- Factorize x2−2 over the integers, input :
  collect(x`^`2-2)
  Output in real mode :
  x`^`2-2
  But if you input :
  collect(sqrt(2)*(x`^`2-2))
  Output :
  sqrt(2)*(x-sqrt(2))*(x+sqrt(2))
- Factorize over the integers :

  x3−2x2+1 and x2−x

  Input :
  collect([x`^`3-2*x`^`2+1,x`^`2-x])
  Output :
  [(x-1)*(x`^`2-x-1),x*(x-1)]
  But, input :
  collect((x`^`3-2*x`^`2+1)*sqrt(5))
  Output :
  ((19*sqrt(5)-10)*((sqrt(5)+15)*x+7*sqrt(5)-5)* ((sqrt(5)+25)*x-13*sqrt(5)-15)*(x-1))/6820
  Or, input :
  collect(x`^`3-2*x`^`2+1,sqrt(5))
  Output :
  ((2*sqrt(5)-19)*((sqrt(5)+25)*x-
  13*sqrt(5)-15)*(-x+1)*((sqrt(5)+15)*x+7*sqrt(5)-5))/6820