### 5.25.13 Factorization : factor factoriser

factor takes as argument a polynomial or a list of polynomials and optionally an algebraic extension, e.g. sqrt(n).
factor factorizes the polynomial (or the polynomials in the list) on the field of its coefficients (the field is complexified in complex mode) or on the smallest extension containing the optional second argument. Unlike collect, factor will further factorize each factor of degree 2 if Sqrt is checked in the cas configuration (see also 5.12.9). You can check the current configuration in the status button under Xcas and change the configuration by hitting this status button.
Input :

factor(x`^`2+2*x+1)

Output :

(x+1)`^`2

Input :

factor(x`^`4-2*x`^`2+1)

Output :

(-x+1)`^`2*(x+1)`^`2

Input :

factor(x`^`3-2*x`^`2+1)

Output if Sqrt is not checked in the cas configuration :

(x-1)*(x`^`2-x-1)

Output if Sqrt is checked in the cas configuration :

(x-1)*(x+(sqrt(5)-1)/2)*(x+(-sqrt(5)-1)/2)

Input :

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

Output :

((2*sqrt(5)-19)*((sqrt(5)+15)*x+
7*sqrt(5)-5)*(-x+1)*((sqrt(5)+25)*x-13*sqrt(5)-15))/6820

Input :

factor(x`^`2+1)

Output in real mode :

x`^`2+1

Output in complex mode :

((-i)*x+1)*((i)*x+1)