Quadratic Equation Solver
Enter the three coefficients to get the discriminant, exact and approximate roots, Vieta sums and the vertex.
Everyone can recite the quadratic formula, but two things still cause trouble by hand: when the number under the root does not come out cleanly, and when the discriminant goes negative and the roots stop being real. Enter a, b and c and the shape of the answer is stated first, followed by the exact roots (simplified surds where needed, complex conjugates where required) and their decimal approximations.
The discriminant Δ = b² − 4ac decides everything: greater than zero gives two distinct real roots, equal to zero a repeated root, and less than zero a pair of complex conjugates — all three are handled here. Viète’s relations (x₁ + x₂ = −b/a, x₁x₂ = c/a) are listed for checking, and the vertex (−b/2a, (4ac − b²)/4a) is given for sketching the parabola.
Did this tool solve your problem?
Submitting sends the tool name, your input and the current result to the server. Please do not include ID numbers, phone numbers or other private data.
AI assistant It answers using your current input and result
Asking again sends your current input and result to the server once more. Please do not include private data.
How to use
- Enter the coefficients a, b and c.
- Read the discriminant and the shape of the roots.
- Take the exact roots (surd or complex form) and the decimal approximations.
- Verify with Viète’s relations; the vertex helps when sketching the curve.
How it works
The discriminant decides the roots
The discriminant Δ = b² − 4ac determines the roots: Δ > 0 gives two distinct real roots, Δ = 0 gives a repeated real root, and Δ < 0 gives no real solution — a pair of conjugate complex roots. The quadratic formula x = (−b ± √Δ) / 2a is the generalized result of completing the square.
Exact form and simplified radicals
Exact form beats decimals. With integer coefficients the tool simplifies the radical: for x² − 2x − 4 = 0, Δ = 20, √20 = 2√5, and canceling the common factor yields x = 1 ± √5 (≈ 3.236068 and −1.236068). Simplification pulls perfect-square factors out of the root (20 = 4 × 5). With decimal coefficients no readable radical form exists, so the tool falls back to decimal approximations (6 significant digits).
Vieta's formulas and the parabola's vertex
Vieta's formulas link roots and coefficients directly: x₁ + x₂ = −b/a and x₁ · x₂ = c/a — you can read off the sum, product and signs of the roots without solving, handy for "one root given, find the other" or parameter problems. The parabola's vertex (−b/2a, c − b²/4a) is the extremum: x² − 3x + 2 has its vertex at (1.5, −0.25), a minimum since the parabola opens upward.
Calculation basis: the discriminant Δ = b² − 4ac with the quadratic formula x = (−b ± √Δ)/2a. For integer coefficients Δ is simplified by extracting perfect-square factors and common factors are cancelled, giving exact roots; non-integer coefficients produce approximations to 6 significant digits. Vieta's formulas give x₁ + x₂ = −b/a and x₁ · x₂ = c/a.
Code example
JavaScript Three branches on the discriminant
function solve(a, b, c) {
const d = b * b - 4 * a * c; // discriminant
if (d < 0) {
const re = -b / (2 * a), im = Math.sqrt(-d) / (2 * a);
return { type: "complex", roots: [re + "+" + im + "i", re + "-" + im + "i"] };
}
if (d === 0) return { type: "double", roots: [-b / (2 * a)] };
const r = Math.sqrt(d);
return { type: "real", roots: [(-b + r) / (2 * a), (-b - r) / (2 * a)] };
}
solve(1, -3, 2); // { type: "real", roots: [2, 1] }
Python Handling complex roots with cmath
import cmath, math
def solve(a, b, c):
d = b * b - 4 * a * c
if d >= 0:
r = math.sqrt(d)
return ((-b + r) / (2 * a), (-b - r) / (2 * a))
r = cmath.sqrt(d) # complex roots
return ((-b + r) / (2 * a), (-b - r) / (2 * a))
solve(1, -3, 2) # (2.0, 1.0)
solve(1, 0, 1) # complex roots ±i
FAQ
Why are there no real roots when the discriminant is negative?
The formula takes the square root of Δ, and negative numbers have no real square root. The two roots are then conjugate complex numbers (a ± bi), and this tool reports them in that form: x² + 2x + 5 = 0 has roots −1 ± 2i.
Why write √20 as 2√5?
Extract the perfect-square factor: 20 = 4 × 5, so √20 = √4 · √5 = 2√5. The simplified form combines easily with other radicals and estimates nicely (2√5 ≈ 4.472).
What are Vieta's formulas for?
They give x₁ + x₂ = −b/a and x₁ · x₂ = c/a — the sum and product of the roots without solving. Typical uses: finding the second root from one, checking whether the roots share a sign, and constructing an equation from two known roots.
Can the coefficient a be 0?
No. With a = 0 the equation degenerates to the linear bx + c = 0 with the single root −c/b (b also nonzero); the tool notes that this is no longer quadratic.
What does the parabola's vertex tell me?
The vertex (−b/2a, c − b²/4a) is the highest or lowest point: for a > 0 the parabola opens upward and the vertex is the minimum; for a < 0 downward and the maximum. Root ranges and optimization problems both rely on it.
Why do some results show only decimals?
When coefficients contain decimals (like 0.5x² + x + 0.5), an exact radical form reads worse than the number itself, so the tool gives decimals. Want exact form? Scale all coefficients by a power of 10 to make them integers first.
Are the coefficients I enter recorded?
No. Coefficients only take part in local arithmetic and square roots — not uploaded, not saved. History lives solely in this browser, clears anytime, and expires with an incognito window.