F = factor(x) returns all irreducible factors of x in vector F. If x is an integer, factor returns the prime factorization of x. If x is a symbolic expression, factor returns the subexpressions that are factors of x.
F = factor(823429252)
F = 2 2 59 283 12329
To factor integers greater than flintmax, convert the integer to a symbolic object using sym. Then place the number in quotation marks to represent it accurately.
F = factor(sym('82342925225632328'))
F = [ 2, 2, 2, 251, 401, 18311, 5584781]
To factor a negative integer, convert it to a symbolic object using sym.
F = factor(sym(-92465))
F = [ -1, 5, 18493]
Perform prime factorization for 41758540882408627201. Since the integer is greater than flintmax, convert it to a symbolic object using sym, and place the number in quotation marks to represent it accurately.
n = sym('41758540882408627201'); factor(n)
ans = [ 479001599, 87178291199]
Factor the fraction 112/81 by converting it into a symbolic object using sym.
F = factor(sym(112/81))
F = [ 2, 2, 2, 2, 7, 1/3, 1/3, 1/3, 1/3]
Factor the polynomial x^6-1.
syms x F = factor(x^6-1)
F = [ x - 1, x + 1, x^2 + x + 1, x^2 - x + 1]
Factor the polynomial y^6-x^6.
syms y F = factor(y^6-x^6)
F = [ -1, x - y, x + y, x^2 + x*y + y^2, x^2 - x*y + y^2]
Factor y^2*x^2 for factors containing x.
syms x y F = factor(y^2*x^2,x)
F = [ y^2, x, x]
factor combines all factors without x into the first element. The remaining elements of F contain irreducible factors that contain x.
Factor the polynomial y for factors containing symbolic variables b and c.
syms a b c d y = -a*b^5*c*d*(a^2 - 1)*(a*d - b*c); F = factor(y,[b c])
F = [ -a*d*(a - 1)*(a + 1), b, b, b, b, b, c, a*d - b*c]
factor combines all factors without b or c into the first element of F. The remaining elements of F contain irreducible factors of y that contain either b or c.
Input to factor, specified as a number, or a symbolic number, expression, or function.