Mathematics RU

Solver

Quadratic equation solver with the discriminant, steps and a check

Type the equation in any form: with brackets, fractions, x on both sides. The solver brings it to the form $ax^2 + bx + c = 0$, finds the discriminant and the roots, checks them by substitution and draws the parabola.

Loading the solver…

What you can type

Write the equation the way you would in an exercise book: x^2 - 5x + 6 = 0. Type the square as ^2 or with the ² sign, and you can leave out the multiplication sign between a number and a letter. You don’t have to bring the equation to standard form yourself: the solver will rewrite (x - 1)^2 = 4, x(x + 3) = 10, x^2 = 5x and 0.5x^2 - x = 4 on its own and show what it did. You can also type a single expression with no equals sign; then the right-hand side is taken to be zero, and y = x^2 - 4 is read as the question “where does the parabola cross the axis?”

The letter doesn’t have to be $x$: t^2 - t - 2 = 0 is solved for $t$. But the solver won’t take two letters at once, such as $ax^2 + bx + c = 0$ with letters for coefficients: put numbers in place of $a$, $b$ and $c$. If after simplifying the $x^2$ disappears or an $x^3$ remains, it will say so and send you to the right solver.

How to solve it: four steps

1. Move everything to the left. The quadratic formula only works for an equation of the form $ax^2 + bx + c = 0$. Expand the brackets, move the terms from the right-hand side over with the opposite sign, and collect like terms. If the coefficients are fractions, multiply both sides by a common denominator; if all the coefficients share a common factor, divide by it. The roots don’t change, and the arithmetic gets easier: $6x^2 - 12x - 18 = 0$ and $x^2 - 2x - 3 = 0$ are the same equation.

2. Write down the coefficients with their signs. In $x^2 - 5x + 6 = 0$ the leading coefficient is $a = 1$ (nothing is written in front of $x^2$), $b = -5$ (the minus is part of the coefficient) and $c = 6$.

3. Check whether the equation is incomplete. If $b = 0$ or $c = 0$, you don’t need the discriminant: there’s a shorter way.

  • $c = 0$: take $x$ out as a common factor. From $x^2 - 5x = 0$ we get $x(x - 5) = 0$, and a product is zero when one of its factors is zero: $x = 0$ or $x = 5$.
  • $b = 0$: solve for $x^2$. From $3x^2 - 12 = 0$ we get $x^2 = 4$, so $x = \pm 2$. If the right-hand side is negative, as in $x^2 = -3$, there are no real roots: a square is never negative.

4. Otherwise, the discriminant and the formula. Compute $D = b^2 - 4ac$. If $D > 0$ there are two roots, if $D = 0$ there is one, and if $D < 0$ there are no real roots. The roots themselves come from the formula in the next section. At the end it’s worth checking them: substitute them into the original equation, or compare their sum and product with the coefficients using Vieta’s formulas. The solver does both.

Why the formula works

The quadratic formula is completing the square, done once and for all in general form. Divide the equation by $a$ (we can, since $a \ne 0$) and move the constant term to the right:

$$x^2 + \frac{b}{a}x = -\frac{c}{a}.$$

The left-hand side is one term short of the square of a sum: $x^2 + 2 \cdot \frac{b}{2a} \cdot x + \left(\frac{b}{2a}\right)^2 = \left(x + \frac{b}{2a}\right)^2$. Add $\left(\frac{b}{2a}\right)^2$ to both sides and put the right-hand side over a common denominator:

$$\left(x + \frac{b}{2a}\right)^2 = \frac{b^2 - 4ac}{4a^2}.$$

On the left is a square, which is never negative. So everything depends on the sign of the numerator on the right, that very $b^2 - 4ac$. If it is negative, the equality is impossible for any real $x$. If it isn’t, take the square root with both signs and subtract $\frac{b}{2a}$.

The second coefficient with the opposite sign. With $b = -5$ this is $+5$, and this minus is where people most often slip. The discriminant. It sits under the root, so its sign tells you how many real roots the equation has: two, one or none. Twice the leading coefficient. Divide the whole numerator by it, not just the root. Example: $2x^2 + 3x - 2 = 0$, where $a = 2$, $b = 3$, $c = -2$. The discriminant is $D = 9 + 16 = 25$, so $x_{1,2} = \frac{-3 \pm 5}{4}$: $x_1 = -2$, $x_2 = \frac12$. Check: $2 \cdot 4 - 6 - 2 = 0$ and $2 \cdot \frac14 + \frac32 - 2 = 0$.

The formula has a visual meaning. The roots of $ax^2 + bx + c = 0$ are the points where the parabola $y = ax^2 + bx + c$ crosses the $x$-axis. The vertex of the parabola is at $x_0 = -\frac{b}{2a}$, exactly halfway between the roots, and the term $\pm\frac{\sqrt{D}}{2a}$ is the step from the vertex to each root, left and right. When $D = 0$ the step is zero: the vertex lies on the axis, and the parabola touches it at a single point. When $D < 0$ the vertex and the branches are on the same side of the axis, and there are no crossings. The solver shows all this on the graph.

If the second coefficient is even, $b = 2k$, the twos cancel in advance: $\frac{D}{4} = k^2 - ac$ and $x_{1,2} = \frac{-k \pm \sqrt{D/4}}{a}$. For $4x^2 - 12x + 7 = 0$ we get $k = -6$, $\frac{D}{4} = 36 - 28 = 8$ and $x_{1,2} = \frac{6 \pm 2\sqrt{2}}{4} = \frac{3 \pm \sqrt{2}}{2}$, with smaller numbers than the usual formula with $D = 32$.

Worked examples

Example 1. $x$ on both sides: $x^2 = 5x - 6$

First move everything to the left: $x^2 - 5x + 6 = 0$. Now $a = 1$, $b = -5$, $c = 6$. The discriminant $D = (-5)^2 - 4 \cdot 1 \cdot 6 = 25 - 24 = 1$ is positive, so there are two roots:

$$x_{1,2} = \frac{5 \pm 1}{2}, \qquad x_1 = 2, \quad x_2 = 3.$$

Check by Vieta’s formulas: $2 + 3 = 5 = -\frac{b}{a}$ and $2 \cdot 3 = 6 = \frac{c}{a}$. Along the way we also get a factorisation: $x^2 - 5x + 6 = (x - 2)(x - 3)$.

Example 2. The root doesn’t come out: $x^2 - 2x - 1 = 0$

$a = 1$, $b = -2$, $c = -1$, $D = 4 + 4 = 8$. The number $8$ isn’t a square, but a factor can be taken out from under the root: $\sqrt{8} = \sqrt{4 \cdot 2} = 2\sqrt{2}$. Then

$$x_{1,2} = \frac{2 \pm 2\sqrt{2}}{2} = 1 \pm \sqrt{2}.$$

The exact answer is $x_1 = 1 - \sqrt{2} \approx -0.414$, $x_2 = 1 + \sqrt{2} \approx 2.414$. Don’t round too early: substituting $1 + \sqrt 2$ gives exactly zero, $(1 + \sqrt2)^2 - 2(1 + \sqrt 2) - 1 = 3 + 2\sqrt2 - 2 - 2\sqrt2 - 1 = 0$, while substituting $2.414$ gives only almost zero.

Example 3. A negative discriminant: $x^2 + 2x + 5 = 0$

$D = 4 - 20 = -16 < 0$. There is no real square root of a negative number, so there are no real roots. The graph shows why: the vertex of the parabola $y = x^2 + 2x + 5$ is at $(-1, 4)$, above the axis, and the branches point upwards.

If we allow the imaginary unit $i$, with $i^2 = -1$, then $\sqrt{-16} = 4i$, and roots appear: $x_{1,2} = \frac{-2 \pm 4i}{2} = -1 \pm 2i$. This is a pair of complex conjugates; the solver shows them on the complex plane.

Example 4. Incomplete equations: $3x^2 = 12$ and $x^2 = 5x$

The first has no $x$ term: divide by $3$, $x^2 = 4$, so $x = -2$ or $x = 2$. The second, after moving everything across, $x^2 - 5x = 0$, has no constant term: $x(x - 5) = 0$, so $x = 0$ or $x = 5$. The discriminant would give the same answers, only more slowly.

Checking and factorising

The roots $x_1$ and $x_2$ are easy to check without substituting. By Vieta’s formulas, $x_1 + x_2 = -\frac{b}{a}$ and $x_1 x_2 = \frac{c}{a}$. For $2x^2 + 3x - 2 = 0$ with roots $-2$ and $\frac12$, the sum is $-\frac32$ and the product is $-1$: exactly $-\frac{3}{2}$ and $\frac{-2}{2}$. The formulas work for “ugly” roots too: $(1 - \sqrt2) + (1 + \sqrt2) = 2$, $(1 - \sqrt2)(1 + \sqrt2) = 1 - 2 = -1$.

The roots also give the factorisation of the quadratic: $ax^2 + bx + c = a(x - x_1)(x - x_2)$. For example, $2x^2 + 3x - 2 = 2(x + 2)\left(x - \frac12\right) = (x + 2)(2x - 1)$. You need this to cancel fractions like $\frac{2x^2 + 3x - 2}{x + 2}$ and to solve inequalities by the interval method.

Common mistakes

  • Using the formula before moving the terms across. In $x^2 = 5x - 6$ the coefficients are not $1$, $5$ and $-6$: first $x^2 - 5x + 6 = 0$, then $a = 1$, $b = -5$, $c = 6$.
  • Losing the sign of $b$. With $b = -5$ the numerator has $-b = 5$, and $b^2 = 25$, not $-25$.
  • Getting the sign of $4ac$ wrong. When $c < 0$ the product $4ac$ is negative, and the discriminant grows: for $x^2 - 2x - 3$ we get $D = 4 + 12 = 16$, not $4 - 12$.
  • Dividing only part of the numerator by $2a$. $\frac{-b \pm \sqrt D}{2a}$ is not $-b \pm \frac{\sqrt D}{2a}$.
  • Losing the negative root. From $x^2 = 4$ it follows that $x = \pm 2$, not just $x = 2$.
  • Dividing both sides by $x$. “Cancelling” in $x^2 = 5x$ gives $x = 5$, and the root $x = 0$ vanishes. You can’t divide by an expression that might be zero; take $x$ out as a factor instead.
  • Writing two roots when $D = 0$. $x^2 - 6x + 9 = 0$ has one root: $x = 3$. People sometimes say “a repeated root” or “two equal roots”: that is about multiplicity, not about two different numbers.
  • Confusing “no real roots” with “no roots at all”. In a school problem with $D < 0$ the answer is “no real roots”, and that is right for real numbers. But among the complex numbers a quadratic equation always has roots.

See also

The history of the formula, from a Babylonian tablet to Viète, a derivation with a picture, and a game of “find the roots from their sum and product” are in the chapter on quadratic equations; so are the discriminant as the number of crossings and the vertex of the parabola. For practice, try the trainer. If a linear equation is left after simplifying, the linear equation solver will handle it; cubic and quartic equations, biquadratics and factorising polynomials are for the higher-degree equation solver; quadratic inequalities are for the interval method. And what to do with $\sqrt{-16}$ is explained in the chapter on complex numbers.

Where this is explained

Other solvers