Quadratic Equation Solver

Solve any quadratic equation \(ax^2 + bx + c = 0\). Compute discriminant, real or complex roots, vertex coordinates, and visualize the parabola with interactive graph.

? Two real roots: x² - 5x + 6 = 0
? One real root (double): x² - 4x + 4 = 0
? Complex roots: x² + 2x + 5 = 0
✨ Simple: x² - 1 = 0
⬇️ Negative a: -x² + 3x - 2 = 0
Privacy first: All calculations are performed locally. No data leaves your device.

The Quadratic Formula: A Universal Solver

The quadratic formula provides the roots of any quadratic equation \(ax^2 + bx + c = 0\) (with \(a \neq 0\)):

\[ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \]

The expression under the square root, \(\Delta = b^2 - 4ac\), is called the discriminant. It determines the nature of the roots:

  • If \(\Delta > 0\): two distinct real roots.
  • If \(\Delta = 0\): one real double root (tangent vertex on x-axis).
  • If \(\Delta < 0\): two complex conjugate roots (no real x-intercepts).

The vertex of the parabola is at \(\left(-\frac{b}{2a}, f\left(-\frac{b}{2a}\right)\right)\), and the axis of symmetry is the vertical line \(x = -\frac{b}{2a}\).

How This Solver Works

Our tool reads coefficients a, b, c as floating-point numbers. It first validates that a ≠ 0. Then it computes the discriminant using high-precision JavaScript numbers. If Δ ≥ 0, real roots are computed directly; if Δ < 0, the complex roots are expressed as \(p \pm qi\) where \(p = -\frac{b}{2a}\) and \(q = \frac{\sqrt{|\Delta|}}{2a}\). The vertex and axis of symmetry are derived from the standard form.

The interactive graph draws the parabola over a suitable x-range (automatically adjusted to show vertex and roots). The canvas uses a coordinate transformation that maps mathematical coordinates to pixel space. For complex-root cases, the graph still shows the parabola (which does not intersect the x-axis), and the vertex is highlighted.

Real-World Applications

  • Physics: Projectile motion (height vs. time) forms a quadratic trajectory.
  • Engineering: Beam deflection, optimization of parabolic reflectors.
  • Economics: Profit maximization (quadratic revenue/cost models).
  • Computer Graphics: Bézier curves and parabolic paths.

Derivation & Historical Context

The quadratic formula has been known for millennia. Babylonian mathematicians (c. 2000 BCE) solved quadratic equations geometrically. The modern algebraic form was developed by Persian mathematician Muhammad ibn Musa al-Khwarizmi (c. 780–850 CE) in his book "The Compendious Book on Calculation by Completion and Balancing" — the source of the word "algebra". The symbol \(\pm\) was introduced by Albert Girard in 1631, and the familiar formula using a, b, c became standard in the 17th century.

Discriminant (Δ) Nature of Roots Example Graph Intersection
Δ > 0 Two distinct real roots x² - 5x + 6 = 0 → roots 2, 3 Crosses x-axis at two points
Δ = 0 One real double root x² - 4x + 4 = 0 → root 2 (double) Tangent to x-axis at vertex
Δ < 0 Two complex conjugate roots x² + 2x + 5 = 0 → -1 ± 2i No x-axis intersection
Case Study: Projectile Motion

A ball is thrown upward from height 1.5 m with initial velocity 15 m/s. Its height \(h(t) = -4.9t^2 + 15t + 1.5\). Using the quadratic formula, we find when it hits the ground (\(h=0\)): \(t \approx 3.21\) seconds (positive root). This real-time solver helps physics students verify kinematic problems instantly. The vertex gives the maximum height at \(t = -b/(2a) \approx 1.53\) seconds, height ≈ 13.0 m.

Step-by-Step Usage

  1. Enter coefficients a, b, c (a cannot be zero).
  2. Click Solve Equation to compute discriminant, roots, vertex, and axis of symmetry.
  3. The parabola graph automatically updates to show the function and relevant points.
  4. Use example buttons to quickly test different cases (real distinct, double root, complex).

Frequently Asked Questions

If a = 0, the equation becomes linear (bx + c = 0). Our tool shows a warning and does not proceed. Use our separate Linear Equation Solver for that case.

JavaScript uses 64-bit double-precision floats (about 15–16 significant digits). For most practical equations, accuracy is excellent. For extreme coefficients (very large or small), consider using symbolic calculators.

Yes, the parabola is still drawn, but since there are no real x-intercepts, the graph shows the curve either entirely above or below the x-axis (depending on a). The vertex and axis are still displayed.

Currently, we provide the final roots and discriminant. A full step-by-step derivation (completing the square) is planned for a future update. However, the quadratic formula itself is shown above.

The graph window is auto-scaled to show the parabola and roots. In some extreme cases (e.g., very narrow parabola), the vertex may be clipped. Adjusting coefficients or zoom is not yet implemented, but for typical educational examples it works well.
References: MathWorld: Quadratic Equation; Boyer, C. B. "A History of Mathematics"; Wikipedia: Quadratic Formula.