Quadratic Equation Solver
A quadratic equation ax² + bx + c = 0 is solved with the quadratic formula x = (−b ± √(b² − 4ac)) / (2a). For 2x² − 4x − 6 = 0 the discriminant is 64, so x = −1 or x = 3, with the vertex at (1, −8) and the factored form 2(x + 1)(x − 3). When the discriminant is not a perfect square the roots stay exact as surds: 2x² + 3x − 4 = 0 gives x = (−3 ± √41)/4 (x₁ ≈ −2.350781059, x₂ ≈ 0.8507810594). A negative discriminant gives complex roots: x² + 2x + 5 = 0 gives x = −1 ± 2i. Type the coefficients or an equation like 2x^2 - 4x = 6 and the solver shows the discriminant, exact and decimal roots, vertex, axis of symmetry, y-intercept, completing the square and Vieta’s sums, with a graph.
Updated By ponderloop editorial · How we checkRuns in your browser: nothing you enter is uploadedHow this tool worksEmbed this tool
2x² − 4x − 6 = 0
x = −1 or x = 3
D = 64 > 0: two distinct real roots, rational.
- Discriminant D = b² − 4ac
- 64
- Type of roots
- Two distinct real roots
- Exact roots
- −1 or 3
- Roots as decimals
- x₁ ≈ −1, x₂ ≈ 3
- Vertex
- (1, −8)
- Axis of symmetry
- x = 1
- y-intercept
- (0, −6)
- Opens
- Upward (a > 0)
- Minimum value
- −8 at x = 1
- Sum of roots (−b/a)
- 2
- Product of roots (c/a)
- −3
- Factored form
- 2(x + 1)(x − 3)
- Vertex form
- y = 2(x − 1)² − 8
Graph
Show the graph as a table of points
| x | y = f(x) | Point |
|---|---|---|
| −2 | 10 | |
| −1 | 0 | Root x₁ |
| 0 | −6 | y-intercept |
| 1 | −8 | Vertex |
| 2 | −6 | |
| 3 | 0 | Root x₂ |
| 4 | 10 |
The working, step by step
- Standard form. Write the equation as ax² + bx + c = 0. Here a = 2, b = −4, c = −6, so 2x² − 4x − 6 = 0.
- Discriminant. D = b² − 4ac = (−4)² − 4 × 2 × (−6) = 16 + 48 = 64.
- What D tells you. D > 0, so there are two distinct real roots, and the parabola crosses the x-axis twice. D is the square of a rational number, so the roots are rational and the quadratic factors.
- Quadratic formula. x = (−b ± √D) / (2a) = (4 ± √64) / 4.
- Exact roots. √64 = 8, so x = (4 + 8) / 4 = 3 and x = (4 − 8) / 4 = −1. The roots are −1 and 3.
- Decimal roots. Use the numerically stable form: √D ≈ 8, q = −½(b + sgn(b)√D) ≈ 6, and the roots are q/a and c/q: x ≈ −1 and x ≈ 3. The textbook formula subtracts two nearly equal numbers for one of the roots when b² is much larger than |4ac|, which throws away digits; this form never does (Press et al., Numerical Recipes, section 5.6; Higham, Accuracy and Stability of Numerical Algorithms, section 1.8). D itself is computed exactly first.
- Vertex and axis. The vertex is at x = −b / (2a) = −(−4) / (2 × 2) = 1. Its height is y = −D / (4a) = −8, so the vertex is (1, −8). The axis of symmetry is the vertical line x = 1. The parabola opens upward because a > 0, so −8 is the minimum value. The y-intercept is where x = 0: y = c = −6, the point (0, −6).
- Completing the square. Divide by a: x² − 2x − 3 = 0. Move the constant: x² − 2x = 3. Add (b / 2a)² = 1 to both sides: (x − 1)² = 4. Take the square root of both sides: x − 1 = ±2, so x = 1 ± 2. In vertex form the equation is y = 2(x − 1)² − 8.
- Factored form. With rational roots r₁ = −1 and r₂ = 3, ax² + bx + c = a(x − r₁)(x − r₂) = 2(x + 1)(x − 3). Each factor is zero at one root.
- Sum and product of roots. Vieta’s formulas: the roots add up to −b/a = 2 and multiply to c/a = −3. Check: −1 + 3 = 2 and −1 × 3 = −3.
Worked examples
| Equation | Discriminant | Roots (exact) | Roots (decimal) |
|---|---|---|---|
| x² − 5x + 6 = 0 | 1 | 2 or 3 | x₁ ≈ 2, x₂ ≈ 3 |
| 2x² − 4x − 6 = 0 | 64 | −1 or 3 | x₁ ≈ −1, x₂ ≈ 3 |
| 4x² − 12x + 9 = 0 | 0 | 3/2 (twice) | x ≈ 1.5 |
| (1/2)x² − (3/2)x + 1 = 0 | 1/4 | 1 or 2 | x₁ ≈ 1, x₂ ≈ 2 |
| 2x² + 3x − 4 = 0 | 41 | (−3 ± √41)/4 | x₁ ≈ −2.350781059, x₂ ≈ 0.8507810594 |
| 16x² + 24x − 11 = 0 | 1280 | (−3 ± 2√5)/4 | x₁ ≈ −1.868033989, x₂ ≈ 0.3680339887 |
| x² − 7 = 0 | 28 | ±√7 | x₁ ≈ −2.645751311, x₂ ≈ 2.645751311 |
| x² + 2x + 5 = 0 | −16 | −1 ± 2i | −1 ± 2i |
| x² + 4 = 0 | −16 | ±2i | ±2i |
What the discriminant tells you
| Discriminant | Roots | The parabola | Example |
|---|---|---|---|
| D > 0 and a perfect square | Two different rational roots | Crosses the x-axis twice, at fractions or whole numbers | 2x² − 4x − 6 = 0: x = −1 or x = 3 |
| D > 0, not a perfect square | Two different irrational roots (surds) | Crosses the x-axis twice | 2x² + 3x − 4 = 0: x = (−3 ± √41)/4 |
| D = 0 | One repeated real root | Touches the x-axis at its vertex | 4x² − 12x + 9 = 0: x = 3/2 (repeated root) |
| D < 0 | Two complex conjugate roots | Never meets the x-axis | x² + 2x + 5 = 0: x = −1 ± 2i |
Textbook formula against the stable formula
| Method | Smaller root | Relative error |
|---|---|---|
| Textbook: (−b − √D) / 2a, in double precision | 7.45058×10⁻⁹ | 0.25 |
| Stable: q = −½(b + sgn(b)√D), then c / q | 1×10⁻⁸ | 0 |
| Reference (40-digit arithmetic) | 1×10⁻⁸ | 0 |
Worked problems
| Problem | Steps | Answer |
|---|---|---|
| A rectangle is 3 longer than it is wide and has area 40. Find the width. | With width x: x(x + 3) = 40, which is x² + 3x − 40 = 0. D = 169, so x = −8 or 5. A width cannot be negative. | Width 5, length 8 (5 × 8 = 40; the root −8 is rejected) |
| Two consecutive whole numbers multiply to 56. Find them. | n(n + 1) = 56, which is x² + x − 56 = 0. D = 225, so n = −8 or 7. | 7 and 8, or −8 and −7 if negatives are allowed |
| A ball is thrown so its height in feet after t seconds is −16t² + 48t + 4. When does it land? | Set the height to 0: −16x² + 48x + 4 = 0. The roots are t = (3 ± √10)/2, in decimals x₁ ≈ −0.08113883008, x₂ ≈ 3.08113883 (the solver calls the unknown x). The negative root is before the throw. | About 3.08113883 seconds. The highest point is (t, height) = (1.5, 40) |
| For which k does x² + kx + 9 = 0 have one repeated root? | D = k² − 36 must be 0, so k = 6 or k = −6. Check: k = 6 gives D = 0 and x = −3 (repeated root); k = −6 gives D = 0 and x = 3 (repeated root). | k = 6 or k = −6 |
| Write a quadratic with roots 2 and −7. | (x − 2)(x + 7) = x² + 5x − 14. The roots add to −5 and multiply to −14 (Vieta), and the solver confirms x² + 5x − 14 = 0 has x = −7 or x = 2. | x² + 5x − 14 = 0 |
| Solve x² = 49. | No x term: x² − 49 = 0, so x = ±√49. | x = −7 or x = 7 |
| Solve x² − 4x = 0. | No constant: factor out x, giving x(x − 4) = 0, so each factor can be 0. The solver shows the factored form x(x − 4). | x = 0 or x = 4 |
| Solve x² − x − 1 = 0 (the golden ratio equation). | D = 5 is not a perfect square, so the roots stay as surds: x = (1 ± √5)/2. | x₁ ≈ −0.6180339887, x₂ ≈ 1.618033989 |
| What is the largest value of −x² + 4x + 5? | a < 0, so the parabola opens downward and the vertex is the maximum: x = −b / 2a = 2. | 9 at x = 2; roots −1 or 5 |
How to solve a quadratic equation
- Write it as ax² + bx + c = 0. Move every term to one side so the other side is 0: 2x^2 - 4x = 6 becomes 2x² − 4x − 6 = 0, so a = 2, b = −4 and c = −6.
- Find the discriminant. Compute D = b² − 4ac. For a = 2, b = −4, c = −6: D = b² − 4ac = (−4)² − 4 × 2 × (−6) = 16 + 48 = 64.
- Read the sign of D. If D > 0 there are two real roots, if D = 0 one repeated root, and if D < 0 two complex roots. Here D = 64, which is a perfect square, so the roots are rational.
- Apply the quadratic formula. x = (−b ± √D) / (2a) = (4 ± √64) / 4 = (4 ± 8) / 4, so x = −1 or 3. Simplify any radical and cancel: (−6 ± √20) / 4 = (−6 ± 2√5) / 4 = (−3 ± √5) / 2.
- Check with Vieta’s formulas. The roots add up to −b/a = 2 and multiply to c/a = −3. For x = −1 or 3: −1 + 3 = 2 and −1 × 3 = −3.
- Find the vertex and graph it. The vertex is at x = −b / (2a) = 1, and its height is f(x) there, giving (1, −8). Plot the vertex, the roots and the y-intercept (0, −6).
Frequently asked questions
- How do you solve a quadratic equation?
- Write it as ax² + bx + c = 0, find the discriminant D = b² − 4ac, and use x = (−b ± √D) / (2a). For 2x² − 4x − 6 = 0, D = 64, so x = (4 ± 8) / 4, which is −1 or 3. If the quadratic factors you can also factor it, here as 2(x + 1)(x − 3), and set each factor to 0.
- What is the discriminant, and what does it tell you?
- The discriminant is D = b² − 4ac, the part under the square root in the quadratic formula. D > 0 gives two real roots (rational when D is a perfect square, like 64 for 2x² − 4x − 6 = 0), D = 0 gives one repeated root (4x² − 12x + 9 = 0 has x = 3/2), and D < 0 gives two complex conjugate roots (x² + 2x + 5 = 0 has D = −16).
- How do you find complex roots?
- When D is negative, √D is an imaginary number: √(−16) = 4i. The roots are then −b/(2a) ± (√(−D)/(2a))·i. For x² + 2x + 5 = 0, x = (−2 ± √(−16)) / 2 = (−2 ± 4i) / 2 = −1 ± 2i. The two roots are complex conjugates, and x² + 4 = 0 gives the pure imaginary pair ±2i.
- How do I get an exact answer like (−3 ± 2√5)/4?
- The tool keeps the discriminant as an exact whole number, pulls out square factors from the radical (√1280 = 16√5), and divides the top and bottom by their common factor. 16x² + 24x − 11 = 0 has D = 1280 and x = (−3 ± 2√5)/4 (x₁ ≈ −1.868033989, x₂ ≈ 0.3680339887). Fractions and decimals in a, b and c are fine: they are cleared with a common multiplier first, so (1/2)x² − (3/2)x + 1 = 0 gives x = 1 or x = 2 and nothing is rounded.
- What if a is 0?
- Then there is no x² term and the equation is linear, so the quadratic formula (which divides by 2a) does not apply. The solver switches to bx + c = 0 and gives x = −c/b: 2x − 3 = 0 gives x = 3/2. If a and b are both 0 the equation is either 0 = 0, true for every x, or a false statement such as 5 = 0, which has no solution.
- How do I find the vertex and the axis of symmetry?
- The vertex is at x = −b / (2a), halfway between the roots, and its height is the value of the quadratic there. For 2x² − 4x − 6 = 0 that is (1, −8). The axis of symmetry is the vertical line through it, x = 1. The vertex is the minimum when a > 0 (the parabola opens upward) and the maximum when a < 0. In vertex form the equation is y = 2(x − 1)² − 8.
- How does completing the square work?
- Divide by a, move the constant to the right, and add (b/2a)² to both sides so the left side is a perfect square: 2x² − 4x − 6 = 0 becomes (x − 1)² = 4, so x − 1 = ±2 and x = 1 ± 2 = −1 or 3. Doing this with letters instead of numbers gives the quadratic formula. The tool writes out the steps for your own coefficients.
- What are Vieta’s formulas?
- For the roots x₁ and x₂ of ax² + bx + c = 0, x₁ + x₂ = −b/a and x₁ × x₂ = c/a. For 2x² − 4x − 6 = 0 the sum is 2 and the product is −3, matching −1 + 3 and −1 × 3. They let you check roots, or build a quadratic from two numbers: the sum 5 and product 6 give x² − 5x + 6 = 0, with roots 2 and 3.
- Why do the decimals use a different formula from the one in the textbook?
- When b² is much larger than |4ac|, one of (−b ± √D) is a subtraction of nearly equal numbers, and a computer loses most of its digits (catastrophic cancellation). For x² − 100,000,000x + 1 = 0 the textbook formula in double precision gives 7.45058×10⁻⁹ for the smaller root, off by a relative 0.25, while the stable form q = −½(b + sgn(b)√D), x₁ = q/a, x₂ = c/q gives 1×10⁻⁸. The tool computes the discriminant exactly first and uses the stable form for decimals (Press et al., Numerical Recipes, section 5.6; Higham, Accuracy and Stability of Numerical Algorithms, section 1.8).
- How do I type an equation instead of coefficients?
- Choose “An equation” and type it as you would write it, such as 2x^2 - 4x = 6 (the tool moves it to 2x² − 4x − 6 = 0). Terms may be on both sides: 3x^2 + 2x = x^2 - 5 becomes 2x² + 2x + 5 = 0. Use ^ or ² for the square, and parentheses around a fraction in front of x, like (3/4)x. Powers above 2 are refused because the equation would not be a quadratic.
- Can every quadratic be factored?
- Over the rational numbers only when the discriminant is a perfect square (the roots are then rational). 2x² − 4x − 6 = 0 factors as 2(x + 1)(x − 3); 2x² + 3x − 4 = 0 does not factor with rational numbers because its roots involve √41. 4x² − 12x + 9 = 0 is a perfect square: 4(x − 3/2)².
- How do I solve x² = 49 or x² − 4x = 0 without the full formula?
- If there is no x term, isolate x² and take both square roots: x² − 49 = 0 gives x = −7 or x = 7. If there is no constant term, factor out x: x² − 4x = x(x − 4) = 0 gives x = 0 or x = 4. Both cases work in the solver as well (a = 1, b = 0, c = −49 and a = 1, b = −4, c = 0).
- How do I solve a quadratic word problem, such as when a ball lands?
- Write the quantity as a quadratic in one unknown, set it equal to 0 (or to the target value and move everything to one side), solve, and discard any root that does not make sense, such as a negative time or length. For a height of −16t² + 48t + 4 feet, the roots are x₁ ≈ −0.08113883008, x₂ ≈ 3.08113883, so the ball lands after about 3.08113883 seconds, and the vertex (t, height) = (1.5, 40) gives its highest point. The −16 is half of gravity, about 32 feet per second squared (Wikipedia, projectile motion).
- How do I write a quadratic from its roots?
- Multiply (x − r₁)(x − r₂), or use Vieta: x² − (sum)x + (product). For roots 2 and −7 the sum is −5 and the product is −14, so x² + 5x − 14 = 0. Check it in the solver: x² + 5x − 14 = 0 gives x = −7 or x = 2. Multiply the whole equation by any non-zero number for another quadratic with the same roots.
- For what value of k does a quadratic have exactly one root?
- Set the discriminant to 0 and solve for k. For x² + kx + 9 = 0, D = k² − 36 = 0, so k = 6 or k = −6. Each gives a perfect square: x² + 6x + 9 = 0 is (x + 3)² and x² − 6x + 9 = 0 is (x − 3)².
- Are the answers exact, or rounded?
- The discriminant, the exact roots, the vertex, the factored form and Vieta’s sums are exact: every coefficient is kept as a fraction of two whole numbers (up to 30 digits each). Only the lines marked ≈ are decimals, shown to 10 significant digits. A radical so large that its square factors cannot all be found is left as it stands, which is still correct but may not be fully simplified.
How it works
The coefficients are read as exact fractions (a mixed number, a fraction, a decimal; an equation typed as text is moved to one side and collected into a, b and c). If any is a fraction, the equation is multiplied by the least common multiple of the denominators so a, b and c are whole numbers; this does not change the roots. The discriminant D = b² − 4ac is then a whole number. If it is a perfect square the roots are the fractions (−b ± √D) / 2a. Otherwise √|D| is written as k√m with m free of square factors (trial division by primes, then a perfect-square check on what is left), and the roots (−b ± k√m) / 2a, or (−b ± k·i√m) / 2a when D is negative, are divided by the common factor of −b, k and 2a. The vertex is (−b/2a, −D/4a), the y-intercept is c, the roots add up to −b/a and multiply to c/a (Vieta), and the factored form a(x − r₁)(x − r₂) is shown when the roots are rational. For decimals, the discriminant is first computed exactly and then converted to a double; the roots are q/a and c/q with q = −½(b + sgn(b)√D), which avoids subtracting nearly equal numbers (Press et al., Numerical Recipes, section 5.6; Higham, Accuracy and Stability of Numerical Algorithms, section 1.8). When a = 0 the equation is linear, x = −c/b. The graph is a parabola drawn from the same numbers, with the x-axis range chosen to include the roots, the vertex and the y-intercept. Everything runs in your browser and nothing you type is sent anywhere.
Sources
- Quadratic equation, Encyclopaedia Britannica
- Quadratic formula, Wikipedia
- Press, Teukolsky, Vetterling and Flannery, Numerical Recipes, section 5.6 “Quadratic and Cubic Equations”
- Higham, Accuracy and Stability of Numerical Algorithms (2nd ed., SIAM), section 1.8 “Solving a Quadratic Equation”
- Projectile motion, Wikipedia
- Vieta’s formulas, Wikipedia
More free tools
- Fraction CalculatorAdd, subtract, multiply and divide fractions and mixed numbers like 2 3/8 + 1 5/16, simplify, and convert to decimals, with every step shown.
- Polynomial CalculatorAdd, subtract, multiply and divide polynomials, find roots, factor and differentiate, with exact fractions and step-by-step working.
- Decimal to Fraction ConverterTurn a decimal like 0.375 or 0.1(6) into an exact fraction, or round inches to the nearest 1/16 or 1/32 on a tape measure, with the working shown.
- Complex Number CalculatorAdd, subtract, multiply and divide complex numbers exactly, then find the modulus, argument, polar form, powers, square roots and roots of unity.
- Triangle CalculatorSolve a triangle from SSS, SAS, ASA, AAS or SSA (both ambiguous solutions) or a right triangle: sides, angles, area, heights and type, with the working.
- Square Root CalculatorSquare roots, cube roots and nth roots with the simplified radical (√72 = 6√2), perfect-power check, 30-digit decimals, negative inputs and fractions.
More: Algebra and number theoryAll math & numbersAll toolsHome & DIY calculators