Algebra & Equations

Factoring Calculator

This factoring calculator factors any polynomial in x step by step, starting with the GCF, and names the method at each step.

Try

Degree 1 to 10 in x. Use ^ for powers. A fraction of polynomials such as (x^2 - 9)/(x + 3) is simplified. Enter a whole number such as 36 for all its factors.

Result

Factored form: 3(x + 3)(x + 2)(x − 2)

Factored form

3(x+3)(x+2)(x−2)3\left(x + 3\right)\left(x + 2\right)\left(x - 2\right)

Standard form
3x3+9x2−12x−363x^{3} + 9x^{2} - 12x - 36
Methods used
Greatest common factor, Grouping, Difference of squares
Irreducible factorsDistinct factors that cannot be split further over the integers.
3
Rational roots (from linear factors)Set each linear factor equal to 0.
x = −3, x = −2, x = 2
Check
Expands back to the original exactly

3x³ + 9x² − 12x − 36 factors into 3 irreducible factors times the constant 3 using greatest common factor, grouping and difference of squares. Setting the linear factors to zero gives x = −3, x = −2, x = 2.

Graph of y = 3x³ + 9x² − 12x − 36
−50050−4−3−2−1012xyyRational roots
Factors of the polynomial
FactorMultiplicityDegreeRoot(s)
x + 311−3
x + 211−2
x − 2112
Step-by-step working (5 steps)
  1. Write the polynomial in standard form

    Expand any products and powers, then collect like terms with the highest power first.

    3x3+9x2−12x−363x^{3} + 9x^{2} - 12x - 36
  2. Greatest common factor: factor out 3

    Every coefficient is a multiple of 3. What is left has whole-number coefficients with no common factor and a positive leading coefficient.

    3x3+9x2−12x−36=3(x3+3x2−4x−12)3x^{3} + 9x^{2} - 12x - 36 = 3\left(x^{3} + 3x^{2} - 4x - 12\right)
  3. Grouping: x³ + 3x² − 4x − 12

    Group the first two terms and the last two. Factoring x² out of the first pair and −4 out of the second leaves the same binomial, x + 3, in both.

    x3+3x2−4x−12=(x3+3x2)+(−4x−12)=x2(x+3)−4(x+3)=(x2−4)(x+3)x^{3} + 3x^{2} - 4x - 12 = \left(x^{3} + 3x^{2}\right) + \left(-4x - 12\right) = x^{2}\left(x + 3\right) - 4\left(x + 3\right) = \left(x^{2} - 4\right)\left(x + 3\right)
  4. Difference of squares: x² − 4

    x² − 4 is x² − 2², a difference of two squares, and A² − B² = (A − B)(A + B) with A = x and B = 2.

    x2−4=x2−22=(x−2)(x+2)x^{2} - 4 = x^{2} - 2^{2} = \left(x - 2\right)\left(x + 2\right)
  5. Check by expanding

    Multiplying the factors back together gives the original polynomial exactly, so the factorization is correct.

    3(x+3)(x+2)(x−2)=3x3+9x2−12x−363\left(x + 3\right)\left(x + 2\right)\left(x - 2\right) = 3x^{3} + 9x^{2} - 12x - 36

A final check expands the answer: x2−5x+6=(x−2)(x−3)x^2 - 5x + 6 = (x - 2)(x - 3). Whole numbers get every factor and factor pair.

By Hira Noor, mathematicianLast reviewed Free, no sign-up, runs in your browserReport a problem

How to use this calculator

  1. Type the polynomial using x, for example 6x^2 + 11x - 10. Use ^ for powers. Write products as 3x or 2(x+1).
  2. Fractions, decimals and partly factored input work too. x^2/4 - 1 and (x+1)^2 - 9 are expanded first.
  3. To simplify a fraction of polynomials, type the top over the bottom, such as (x^2 - 9)/(x^2 + 5x + 6). Common factors cancel.
  4. Type a whole number such as 36 to list all its factors and factor pairs.
  5. Read the answer at the top, then the steps. Each step names its method and shows the numbers. The last step checks the answer.
  6. The calculator works with one variable, x, up to degree 10.

Formulas

Difference of squares, sum and difference of cubes

a2−b2=(a−b)(a+b),a3±b3=(a±b)(a2∓ab+b2)a^2 - b^2 = (a - b)(a + b), \quad a^3 \pm b^3 = (a \pm b)\left(a^2 \mp ab + b^2\right)

Plain-text formula: a^2 − b^2 = (a − b)(a + b), a^3 ± b^3 = (a ± b)(a^2 ∓ ab + b^2)

A binomial whose two terms are perfect squares with a minus sign between them, or perfect cubes with either sign, factors by these identities. A sum of two squares such as x² + 4 does not factor over the real numbers.

Perfect square trinomial

a2±2ab+b2=(a±b)2a^2 \pm 2ab + b^2 = (a \pm b)^2

Plain-text formula: a^2 ± 2ab + b^2 = (a ± b)^2

When the first and last terms are squares and the middle term is twice the product of their roots, the trinomial is a square, for example x² + 6x + 9 = (x + 3)².

AC method (splitting the middle term)

ax2+bx+c=ax2+mx+nx+c,mn=ac,m+n=bax^2 + bx + c = ax^2 + mx + nx + c, \quad mn = ac, \; m + n = b

Plain-text formula: ax^2 + bx + c = ax^2 + mx + nx + c, mn = ac, m + n = b

a,b,ca, b, c
the coefficients of x², x and the constant term
m,nm, n
the two numbers used to split the middle term

Find two integers whose product is ac and whose sum is b. Split bx into mx + nx, then factor the two pairs. The X method finds the same two numbers. They exist exactly when the discriminant b² − 4ac is a perfect square.

Rational root test

P(pq)=0,p∣a0,q∣an⇒(qx−p) is a factor of P(x)P\left(\tfrac{p}{q}\right) = 0, \; p \mid a_0, \; q \mid a_n \;\Rightarrow\; (qx - p) \text{ is a factor of } P(x)

Plain-text formula: P(p/q) = 0, p∣a_0, q∣a_n ⇒ (qx − p) is a factor of P(x)

For integer coefficients, every rational root p/q in lowest terms has p dividing the constant term and q dividing the leading coefficient. Each root found gives a linear factor, and division leaves a polynomial of lower degree to factor next.

Reading the result

The factored form is written over the integers. Each factor has whole-number coefficients and a positive first term. Any common factor, minus sign or fraction goes in front. A factor that cannot be split further is irreducible, also called prime.

Set each linear factor equal to zero to get a root: 2x + 5 = 0 gives x = −5/2. Prime factors have irrational or complex roots. The table lists them, and the results show the polynomial as linear factors over the real or complex numbers.

Factors can come in a different order, or with signs moved, and still be the same product: (x − 2)(x − 3) equals (2 − x)(3 − x). To compare two answers, expand them, as the last step does.

Which factoring method to try first

Always take out the greatest common factor first. That is the largest number dividing every coefficient, times the lowest power of x in every term. Then count the terms.

Two terms: try a difference of squares or a sum or difference of cubes. Three terms: try a perfect square trinomial or the AC method, also taught as the X method. Four terms: try grouping.

If no pattern fits, use the rational root test. Each root it finds divides out a linear factor. Repeat on every factor until none splits further. The calculator works in this same order, so its steps match the way the methods are taught.

When a polynomial cannot be factored

A quadratic ax2+bx+cax^2 + bx + c with integer coefficients factors exactly when b2−4acb^2 - 4ac is a perfect square. A cubic factors exactly when it has a rational root, because one of its factors must be linear.

From degree 4 on, a polynomial with no rational roots can still split into larger pieces: x4+4=(x2−2x+2)(x2+2x+2)x^4 + 4 = (x^2 - 2x + 2)(x^2 + 2x + 2). Neither piece has a real root. The calculator finds such splits by grouping the complex roots, then confirms each one by exact division.

Over the complex numbers, every polynomial splits into linear factors. This is the fundamental theorem of algebra, and the results show that form whenever a prime factor remains.

Worked example

Factor 3x³ + 9x² − 12x − 36

Factor P(x) = 3x³ + 9x² − 12x − 36 completely.

  1. Greatest common factor: every coefficient is a multiple of 3, so P(x)=3(x3+3x2−4x−12)P(x) = 3(x^3 + 3x^2 - 4x - 12).
  2. Grouping: (x3+3x2)+(−4x−12)=x2(x+3)−4(x+3)=(x2−4)(x+3)(x^3 + 3x^2) + (-4x - 12) = x^2(x + 3) - 4(x + 3) = (x^2 - 4)(x + 3).
  3. Difference of squares: x2−4=x2−22=(x−2)(x+2)x^2 - 4 = x^2 - 2^2 = (x - 2)(x + 2).
  4. Check: 3(x+3)(x+2)(x−2)=3(x+3)(x2−4)=3x3+9x2−12x−363(x + 3)(x + 2)(x - 2) = 3(x + 3)(x^2 - 4) = 3x^3 + 9x^2 - 12x - 36.

Answer: P(x) = 3(x + 3)(x + 2)(x − 2). Setting each factor to zero gives the roots x = −3, x = −2 and x = 2.

Frequently asked questions

How do you factor a sum or difference of cubes?

Use a3+b3=(a+b)(a2−ab+b2)a^3 + b^3 = (a + b)(a^2 - ab + b^2) and a3−b3=(a−b)(a2+ab+b2)a^3 - b^3 = (a - b)(a^2 + ab + b^2). For example, 8x3+27=(2x)3+33=(2x+3)(4x2−6x+9)8x^3 + 27 = (2x)^3 + 3^3 = (2x + 3)(4x^2 - 6x + 9). When a and b are linear, as here, the quadratic factor has no real roots and is prime.

How do I find the greatest common factor of a polynomial?

Take the greatest common divisor of the coefficients and the lowest power of x that appears in every term. For 12x3−18x212x^3 - 18x^2 that is 6x26x^2, so 12x3−18x2=6x2(2x−3)12x^3 - 18x^2 = 6x^2(2x - 3). For the GCF of plain numbers, use the GCD and LCM calculator.

What does it mean when a polynomial is prime?

It cannot be written as a product of polynomials of lower degree with integer coefficients. For example x2+x+1x^2 + x + 1 is prime because its discriminant, 1−4=−31 - 4 = -3, is not a perfect square. A prime polynomial still has roots; they are irrational or complex.

Can it factor with imaginary numbers?

Yes. When a prime factor remains, the results also write the whole polynomial as linear factors over the complex numbers, such as x2+4=(x+2i)(x−2i)x^2 + 4 = (x + 2i)(x - 2i). Roots with no exact form are shown as decimals. For more detail on each root, use the polynomial root finder.

What are the most common factoring mistakes?

Forgetting the greatest common factor first, stopping too early (in x4−16=(x2−4)(x2+4)x^4 - 16 = (x^2 - 4)(x^2 + 4) the first factor still splits), trying to factor a sum of squares such as x2+9x^2 + 9, and sign errors when grouping: −4x−12=−4(x+3)-4x - 12 = -4(x + 3), not −4(x−3)-4(x - 3).

Can it simplify a fraction of polynomials?

Yes. Type the top over the bottom, such as (x^2 - 9)/(x^2 + 5x + 6). Both are factored, and the common factor x+3x + 3 cancels to leave x−3x+2\frac{x - 3}{x + 2}. The values that made the original denominator zero, x = −3 and x = −2, stay excluded. The calculator works with one variable, x.

How does factoring help solve an equation?

If a product is zero, one of its factors is zero. So once x2−5x+6=(x−2)(x−3)x^2 - 5x + 6 = (x - 2)(x - 3), the equation x2−5x+6=0x^2 - 5x + 6 = 0 has the solutions x = 2 and x = 3. For quadratics that do not factor, the quadratic equation calculator gives exact roots.

Polynomial Root Finder

All real and complex roots of a polynomial up to degree 10, with multiplicities, exact forms and steps.

Algebra & Equations

Quadratic Formula Calculator

Solve ax² + bx + c = 0 with the quadratic formula: exact roots, discriminant, vertex, graph and steps.

Algebra & Equations

LCM and GCF Calculator

LCM and GCF of up to 10 numbers with steps: multiples, prime factors, Euclid’s algorithm and a coprime check.

Number Theory & Bases

Step-by-Step Math Solver

Free worked solutions for equations, systems, inequalities, factoring, derivatives, integrals, limits and matrices.

Tools

Cubic Equation Solver

Exact and complex roots of ax³ + bx² + cx + d = 0 with the discriminant, steps and a root check.

Algebra & Equations

Sources and further reading

  1. Factoring (Chapter 6, Intermediate Algebra 2e) (opens in a new tab), OpenStax, Rice University
  2. Zeros of Polynomial Functions (Section 5.5, Algebra and Trigonometry 2e) (opens in a new tab), OpenStax, Rice University
  3. Algebra, 2nd edition (M. Artin), Gauss’s lemma and factoring integer polynomials, Pearson

Results are calculated in your browser with methods checked by automated tests, and are intended for learning and general use. For engineering, medical, financial, legal or safety-critical decisions, verify important values independently and follow the rounding rules your work requires. How accurate are these results?