Skip to main content
ponderloop

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

Enter the equation as

For ax² + bx + c = 0. Whole numbers, decimals and fractions like 3/4 all work.

Need the slope of a line instead? Try the slope calculator.

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

Graph of y = 2x² − 4x − 6A parabola opening upward with its vertex at (1, −8). It crosses the x-axis at x = −1 and x = 3, and crosses the y-axis at y = −6. Circles mark the roots, a diamond the vertex and a triangle the y-intercept.−2−101234−10−50510xyx₁x₂Vy-int
Circle: a root (where the curve meets the x-axis). Diamond: the vertex. Triangle: the y-intercept.
Show the graph as a table of points
Points on the graph, in order of x
xy = f(x)Point
−210
−10Root x₁
0−6y-intercept
1−8Vertex
2−6
30Root x₂
410

The working, step by step

  1. Standard form. Write the equation as ax² + bx + c = 0. Here a = 2, b = −4, c = −6, so 2x² − 4x − 6 = 0.
  2. Discriminant. D = b² − 4ac = (−4)² − 4 × 2 × (−6) = 16 + 48 = 64.
  3. 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.
  4. Quadratic formula. x = (−b ± √D) / (2a) = (4 ± √64) / 4.
  5. Exact roots. √64 = 8, so x = (4 + 8) / 4 = 3 and x = (4 − 8) / 4 = −1. The roots are −1 and 3.
  6. 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.
  7. 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).
  8. 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.
  9. 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.
  10. 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

Each row is solved by the tool above; the roots are exact, with decimals next to them.
EquationDiscriminantRoots (exact)Roots (decimal)
x² − 5x + 6 = 012 or 3x₁ ≈ 2, x₂ ≈ 3
2x² − 4x − 6 = 064−1 or 3x₁ ≈ −1, x₂ ≈ 3
4x² − 12x + 9 = 003/2 (twice)x ≈ 1.5
(1/2)x² − (3/2)x + 1 = 01/41 or 2x₁ ≈ 1, x₂ ≈ 2
2x² + 3x − 4 = 041(−3 ± √41)/4x₁ ≈ −2.350781059, x₂ ≈ 0.8507810594
16x² + 24x − 11 = 01280(−3 ± 2√5)/4x₁ ≈ −1.868033989, x₂ ≈ 0.3680339887
x² − 7 = 028±√7x₁ ≈ −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

The sign of D = b² − 4ac decides the kind of roots, and whether the parabola crosses the x-axis.
DiscriminantRootsThe parabolaExample
D > 0 and a perfect squareTwo different rational rootsCrosses the x-axis twice, at fractions or whole numbers2x² − 4x − 6 = 0: x = −1 or x = 3
D > 0, not a perfect squareTwo different irrational roots (surds)Crosses the x-axis twice2x² + 3x − 4 = 0: x = (−3 ± √41)/4
D = 0One repeated real rootTouches the x-axis at its vertex4x² − 12x + 9 = 0: x = 3/2 (repeated root)
D < 0Two complex conjugate rootsNever meets the x-axisx² + 2x + 5 = 0: x = −1 ± 2i

Textbook formula against the stable formula

For x² − 100,000,000x + 1 = 0 the smaller root is about 1×10⁻⁸. The textbook formula subtracts two numbers near 10⁸ and keeps few correct digits; the stable form does not. The reference value is computed with 40-digit integer arithmetic.
MethodSmaller rootRelative error
Textbook: (−b − √D) / 2a, in double precision7.45058×10⁻⁹0.25
Stable: q = −½(b + sgn(b)√D), then c / q1×10⁻⁸0
Reference (40-digit arithmetic)1×10⁻⁸0

Worked problems

Typical homework questions, with the steps. Every root, vertex and discriminant is the solver’s own result.
ProblemStepsAnswer
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

  1. 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.
  2. Find the discriminant. Compute D = b² − 4ac. For a = 2, b = −4, c = −6: D = b² − 4ac = (−4)² − 4 × 2 × (−6) = 16 + 48 = 64.
  3. 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.
  4. 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.
  5. 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.
  6. 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

More: Algebra and number theoryAll math & numbersAll toolsHome & DIY calculators