Algebra

Factoring Calculator

Enter a polynomial in x. The calculator pulls out the GCD of the coefficients, then uses the rational-root theorem to peel off linear factors (qx − p) one at a time. The output combines those factors with any leftover irreducible part of the polynomial.

Factoring Calculator

Factor a polynomial over the rationals into linear and irreducible factors.

Try:
Answer(x − 2)·(x − 3)
  1. Polynomialx² − 5x + 6
  2. Factored form(x − 2)·(x − 3)

Factoring over the rationals, and stopping there

Factoring rewrites a polynomial as a product. That form answers questions the expanded form hides: roots are read off directly, a rational function can be simplified, and an inequality can be solved by signs rather than by testing points.

This calculator factors a polynomial in x over the rationals. It pulls out any common numeric factor, finds every rational root and strips the corresponding linear factor, and reports whatever remains as a single irreducible piece.

Over the rationals is a real restriction, not a hedge. x² − 2 factors over the reals as (x − √2)(x + √2) and x² + 1 factors over the complex numbers, but neither has rational roots, so both are reported unchanged here.

That boundary makes the result trustworthy. Everything the tool factors, it factors exactly, with integer coefficients throughout — no decimal approximation of a root ever appears.

How to use this calculator

  1. Type the polynomial in x Standard notation, with ^ for powers. Implicit multiplication is understood, so 5x needs no operator. The expression is expanded first, so a product of brackets is accepted as input.
  2. Keep it polynomial Division by an expression, or any trigonometric, logarithmic or exponential term, makes the input non-polynomial and is rejected with a message saying so.
  3. Read the common factor line if it appears A numeric factor shared by every coefficient is pulled out first and reported on its own line. It appears only when there is one greater than 1.
  4. Read the factored form Linear factors come first, then any irreducible remainder in brackets. A polynomial with no rational roots comes back as it went in.

How the factoring is carried out

The expression is first expanded into a coefficient list, so an input already written as a product is multiplied out. If that expansion fails — because the input is not a polynomial — the attempt stops there rather than partially factoring.

Next the greatest common divisor of all the coefficients is taken, and when it exceeds 1 it is divided out and reported as a separate factor. This step runs only when every coefficient is an integer, since a common divisor of fractions is not well defined.

The main work is the rational-root theorem. Any rational root p/q of an integer-coefficient polynomial must have p dividing the constant term and q dividing the leading coefficient, turning an infinite search into a finite one over the divisors of two numbers. Each candidate is substituted, and a value indistinguishable from zero identifies a root.

When a root is found, its linear factor is removed by synthetic division and the search restarts on the quotient, so a repeated root is found as many times as it occurs. A zero constant term is handled separately, since it means x itself is a factor. Once no rational root remains, what is left is irreducible over the rationals and printed as one bracketed factor.

What each input means

P(x) Polynomial — form field “Polynomial in x”
The expression to factor, in x. It is expanded to a coefficient list first, so brackets in the input are permitted and are multiplied out before factoring begins.
p/q Rational root candidate
A fraction whose numerator divides the constant term and whose denominator divides the leading coefficient. The theorem guarantees every rational root has this shape.
(qx − p) Linear factor
The factor for a root p/q, written with integer coefficients rather than as (x − p/q) so the factorisation stays integral.

Worked examples

Every number below is produced by the same calculation engine the tool above runs. Nothing here is typed by hand, so the walkthrough cannot drift from what you get when you enter the same values yourself.

A quadratic with integer roots

Factor x² − 5x + 6. The leading coefficient is 1, so the root candidates are just the divisors of 6 and their negatives.

Inputs Polynomial in x = x^2 - 5x + 6

  1. Polynomial x² − 5x + 6
  2. Factored form (x − 2)·(x − 3)

Result (x − 2)·(x − 3)

Both roots are found and stripped in turn, giving two linear factors. Because the leading coefficient is 1, every candidate denominator is 1 and the search runs over divisors of the constant term alone — which is why monic quadratics are easiest by hand too.

The two roots multiply to the constant term and add to the negated middle coefficient. That is the check worth running on any factored quadratic, and it needs no expansion.

A leading coefficient greater than one

Factor 2x² + 5x − 3. Now the denominators of the candidate roots matter, since q must divide 2.

Inputs Polynomial in x = 2x^2 + 5x - 3

  1. Polynomial 2x² + 5x − 3
  2. Factored form (x + 3)·(2x − 1)

Result (x + 3)·(2x − 1)

One root is a fraction with denominator 2, and its factor is written with integer coefficients rather than as a bracket containing a fraction. That is why the quotient is rescaled after each division: it keeps every coefficient whole.

By hand this case needs trial and error or the AC method. The rational-root search does the same work systematically, testing each candidate rather than guessing a split of the middle term.

A cubic with a factor of x

Factor x³ − x. The constant term is zero, which triggers the shortcut that handles x as a factor before any root search.

Inputs Polynomial in x = x^3 - x

  1. Polynomial x³ − x
  2. Factored form x·(x − 1)·(x + 1)

Result x·(x − 1)·(x + 1)

A zero constant term means zero is a root, so x divides the polynomial. That case is detected directly rather than through the candidate search, since a constant term of zero has no useful divisors.

What remains after removing x is a difference of squares, which factors into two more linear pieces. Three linear factors in total, which is the maximum for a cubic and confirms all three roots are rational.

Reading the result

Reading a bracketed remainder

A final factor printed in brackets and not further split is irreducible over the rationals: it has no rational roots. It may still have irrational or complex ones, which the quadratic solver will find if it is of degree two.

The factored form gives the roots

Each factor (qx − p) vanishes at x = p/q, so reading the roots off needs no further work. A polynomial that factors completely into linear pieces has all its roots rational.

When you would use this

Solving a polynomial equation

Setting a polynomial to zero and factoring turns one hard equation into several trivial ones, since a product is zero exactly when a factor is. It is the standard route beyond a quadratic.

Simplifying a rational expression

Factoring numerator and denominator separately exposes any common factor, the only way to cancel legitimately. It also locates the holes and vertical asymptotes.

Assumptions and limitations

What this calculator assumes

  • The input is a genuine polynomial in x: no division by an expression, and no trigonometric, logarithmic or exponential terms.
  • Coefficients are integers, or become integers after expansion; the common-factor step is skipped otherwise.
  • Factoring is over the rationals only, so irrational and complex roots are not extracted.
  • A root is accepted when substituting the candidate gives a value indistinguishable from zero.

Where it stops being the right tool

  • No irrational or complex factorisation: x² − 2 and x² + 1 are both returned unchanged.
  • The rational-root search enumerates divisors of the constant and leading coefficients, so large coefficients make it slow.

Common mistakes

Expecting a factorisation of an irreducible polynomial

Why it happens. A quadratic that crosses the axis twice looks factorable, and returning it unchanged reads as a failure. If its roots are irrational there is no rational factorisation.

How to avoid it. Use the quadratic solver on the remainder. It will report the irrational roots that this tool deliberately declines to approximate.

Forgetting the numeric common factor

Why it happens. Working by hand, attention goes to the variable part, and a shared coefficient such as 3 in 3x² − 12 is easy to leave inside.

How to avoid it. Compare against the common-factor line. Its absence in your own answer means the factorisation is correct but incomplete.

Writing linear factors with fractional roots inside them

Why it happens. A root of 1/2 suggests (x − 1/2), which is correct but leaves fractions in an otherwise integer factorisation.

How to avoid it. Clear the denominator into the factor itself and account for it in the leading coefficient. That is the form the tool prints, and it keeps every coefficient whole.

Frequently asked questions

Which polynomials can it factor?

Polynomials in x with integer coefficients, or ones that become integral after expansion. Linear factors are found through the rational-root theorem, and any quadratic or higher remainder with no rational roots is left as a single factor.

Does it work for high-degree polynomials?

In principle yes: roots are stripped one at a time and the search restarts on the quotient. The cost is driven by the constant and leading coefficients, since the candidate list is built from their divisors.

What happens when there are no rational roots?

The polynomial is irreducible over the rationals and is returned unchanged, with a line saying so. That is a mathematical fact about the polynomial rather than a limit on the search.

Why is a factor written as (2x − 1) rather than (x − 0.5)?

So that every coefficient stays an integer. A root of p/q gives the factor (qx − p), and the quotient is rescaled after each division to keep the remaining polynomial integral too.