Factorisation : factor

### 2.12.9 Factorisation : `factor`

`factor` takes as argument an expression.
`factor` factorizes this expression on the field of it’s coefficients, with the addition of i in complex mode. If `sqrt` is enabled in the Cas configuration, polynomials of order 2 are factorized in complex mode or in real mode if the discriminant is positive.
Examples

1. Factorize x4−1 over ℚ.
   Input :
   `factor(x```^```4-1)`
   Output :
   `(x```^```2+1)*(x+1)*(x-1)`
   The coefficients are rationals, hence the factors are polynomials with rationals coefficients.
2. Factorize x4−1 over ℚ[i]
   To have a complex factorisation, check `complex` in the `cas` configuration (red button displaying the status line).
   Input :
   `factor(x```^```4-1)`
   Output :
   `-i*(-x+-i)*(i*x+1)*(-x+1)*(x+1)`
3. Factorize x4+1 over ℚ
   Input :
   `factor(x```^```4+1)`
   Output :
   `x```^```4+1`
   Indeed x4+1 has no factor with rational coefficients.
4. Factorize x4+1 over ℚ[i]
   Check `complex` in the `cas` configuration (red button rouge displaying the status line).
   Input :
   `factor(x```^```4-1)`
   Output :
   `(x```^```2+i)*(x```^```2+-i)`
5. Factorize x4+1 over ℝ.
   You have to provide the square root required for extending the rationals. In order to do that with the help of `Xcas`, first check `complex` in the `cas` configuration and input :
   `solve(x```^```4+1,x)`
   Output :
   `[sqrt(2)/2+(i)*sqrt(2)/2,sqrt(2)/2+(i)*(-(sqrt(2)/2)), -sqrt(2)/2+(i)*sqrt(2)/2,-sqrt(2)/2+(i)*(-(sqrt(2)/2))]`
   The roots depends on √2. Uncheck complex mode in the Cas configuration and input :
   `factor(x```^```4+1,sqrt(2))`
   Output :
   `(x```^```2+sqrt(2)*x+1)*(x```^```2+(-(sqrt(2)))*x+1)`
   To factorize over ℂ, check `complex` in the `cas` configuration and input `cFactor(x```^```4+1,sqrt(2))` (cf `cFactor`).