Equation solver
Enter the coefficients and the equation is solved, with the discriminant and vertex thrown in.
ax² + bx + c = 0
Solutions
x1 = 1 x2 = 2
Factorised: (x − 1)(x − 2)
- Discriminantb² − 4ac decides the number of real roots.1
- VertexThe lowest or highest point of the parabola.(1.5, -0.25)
- Axis of symmetryx = 1.5
The working
x = (−(-3) ± √1) / (2 · 1)
How it works
A linear equation always has exactly one solution, as long as the coefficient in front of x is not zero. If it is zero there is either no solution at all or infinitely many.
The quadratic is solved with the quadratic formula, in the numerically stable form described below. Mathematically it gives the same roots as the formula taught at school. The discriminant b² − 4ac decides how many real roots there are.
A positive discriminant gives two roots, zero gives one double root, and a negative one gives no real roots but two complex ones that mirror each other.
The vertex is the lowest or highest point of the parabola. It always sits halfway between the roots, at x = −b / 2a, which is also the axis of symmetry.
The tool uses a numerically stable form of the formula. The textbook version subtracts two nearly equal numbers when b² is much larger than 4ac, and loses the smaller root entirely.
How the roots are found
The tool first works out q = −½(b + sign of b × √D), where D = b² − 4ac. One root is q / a and the other c / q. When b is zero the sign is taken as plus. It matches David Goldberg’s rearrangement of the formula: the root for which the formula would subtract two nearly equal numbers is worked out instead as c / q, since the product of the roots is always c / a.
The roots are listed in ascending order to at most ten significant figures. When the discriminant is negative, the answer is written as −b / 2a ± √(−D) / |2a| times i.
A discriminant that differs from zero only by rounding error counts as zero, since b² and 4ac are rounded separately. With a = 1, b = 0.2 and c = 0.01, b² − 4ac comes out as 6.9 × 10⁻¹⁸, but the tool gives the double root −0.1, not two roots close together.
Example: a very small root
Take x² + 100,000,000x + 1 = 0, so a = 1, b = 100,000,000 and c = 1. The textbook formula gives the small root as (−b + √D) / 2, which at the computer’s precision comes out as about −0.00000000745. That is wrong by roughly a quarter, and with b = 1,000,000,000 the textbook formula even gives 0.
The tool gets q = −100,000,000, and the roots become q / a = −100,000,000 and c / q = −0.00000001, which is shown as a power of ten.
Putting the equation in the right form
The tool only solves equations with zero on one side. If you have x² = 3x − 2, move everything to the left: x² − 3x + 2 = 0 gives a = 1, b = −3 and c = 2, and the roots 1 and 2. The working below the answer shows x = (−(−3) ± √1) / (2 · 1) and the factorised form (x − 1)(x − 2). A missing term has the coefficient zero, and a minus sign goes into the coefficient.
The linear equation 2x + 3 = 7 likewise becomes 2x − 4 = 0, so a = 2, b = −4 and x = 2. If you choose quadratic with a = 0, the tool asks you to switch to linear rather than divide by zero.