Desmos Math Calculator

Quadratic Equation Solver

Enter the coefficients for your quadratic equation in the form ax² + bx + c = 0 to find its roots.

function calculateQuadraticRoots() { var a = parseFloat(document.getElementById('coefficientA').value); var b = parseFloat(document.getElementById('coefficientB').value); var c = parseFloat(document.getElementById('coefficientC').value); var resultDiv = document.getElementById('quadraticResult'); var output = "; if (isNaN(a) || isNaN(b) || isNaN(c)) { resultDiv.innerHTML = 'Please enter valid numbers for all coefficients.'; return; } if (a === 0) { if (b === 0) { if (c === 0) { output = 'This is an identity (0=0). Any real number is a solution.'; } else { output = 'This is a contradiction (' + c + '=0). No solution exists.'; } } else { // Linear equation: bx + c = 0 => x = -c/b var x = -c / b; output = 'This is a linear equation (a=0).'; output += 'Root (x): ' + x.toFixed(4) + "; } resultDiv.innerHTML = output; return; } var discriminant = (b * b) – (4 * a * c); output += 'Discriminant (b² – 4ac): ' + discriminant.toFixed(4) + "; if (discriminant > 0) { var root1 = (-b + Math.sqrt(discriminant)) / (2 * a); var root2 = (-b – Math.sqrt(discriminant)) / (2 * a); output += 'Nature of Roots: Real and Distinct'; output += 'Root 1 (x₁): ' + root1.toFixed(4) + "; output += 'Root 2 (x₂): ' + root2.toFixed(4) + "; } else if (discriminant === 0) { var root = -b / (2 * a); output += 'Nature of Roots: Real and Equal'; output += 'Root (x): ' + root.toFixed(4) + "; } else { // discriminant < 0 var realPart = -b / (2 * a); var imaginaryPart = Math.sqrt(Math.abs(discriminant)) / (2 * a); output += 'Nature of Roots: Complex Conjugates'; output += 'Root 1 (x₁): ' + realPart.toFixed(4) + ' + ' + imaginaryPart.toFixed(4) + 'i'; output += 'Root 2 (x₂): ' + realPart.toFixed(4) + ' – ' + imaginaryPart.toFixed(4) + 'i'; } resultDiv.innerHTML = output; } .calculator-container { background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 8px; padding: 20px; max-width: 600px; margin: 20px auto; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; box-shadow: 0 4px 8px rgba(0,0,0,0.05); } .calculator-container h2 { color: #333; text-align: center; margin-bottom: 20px; font-size: 24px; } .calculator-content p { font-size: 15px; line-height: 1.6; color: #555; margin-bottom: 15px; } .form-group { margin-bottom: 15px; } .form-group label { display: block; margin-bottom: 5px; color: #333; font-weight: bold; } .form-group input[type="number"] { width: calc(100% – 22px); padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; box-sizing: border-box; } .calculate-button { display: block; width: 100%; padding: 12px 20px; background-color: #007bff; color: white; border: none; border-radius: 4px; font-size: 18px; cursor: pointer; transition: background-color 0.3s ease; margin-top: 20px; } .calculate-button:hover { background-color: #0056b3; } .result-area { background-color: #e9ecef; border: 1px solid #dee2e6; border-radius: 4px; padding: 15px; margin-top: 25px; font-size: 16px; color: #333; min-height: 50px; } .result-area p { margin: 5px 0; color: #333; } .result-area p strong { color: #000; } .result-area .error { color: #dc3545; font-weight: bold; }

Understanding Quadratic Equations and Their Roots

A quadratic equation is a polynomial equation of the second degree, meaning the highest power of the variable is 2. It is typically written in the standard form:

ax² + bx + c = 0

where x represents an unknown, and a, b, and c are coefficients, with a not equal to zero. If a were zero, the equation would become linear (bx + c = 0).

The Quadratic Formula

The solutions to a quadratic equation are called its roots. These are the values of x that satisfy the equation. The most common method to find these roots is using the quadratic formula:

x = [-b ± sqrt(b² - 4ac)] / 2a

This formula provides two potential roots, corresponding to the + and - signs before the square root.

The Discriminant

A crucial part of the quadratic formula is the expression under the square root: b² - 4ac. This is known as the discriminant, often denoted by the Greek letter Delta (Δ). The value of the discriminant tells us about the nature of the roots:

  • If Discriminant > 0: There are two distinct real roots. This means the parabola (the graph of a quadratic equation) intersects the x-axis at two different points.
  • If Discriminant = 0: There is exactly one real root (sometimes called a repeated or double root). The parabola touches the x-axis at exactly one point.
  • If Discriminant < 0: There are two complex conjugate roots. The parabola does not intersect the x-axis at all. These roots involve the imaginary unit i, where i = sqrt(-1).

How Desmos Visualizes Quadratic Equations

Desmos is an excellent tool for visualizing quadratic equations. When you input an equation like y = ax² + bx + c into Desmos, it instantly graphs the corresponding parabola. The roots of the equation ax² + bx + c = 0 are precisely the x-intercepts of this parabola. Desmos allows you to easily change the values of a, b, and c using sliders, letting you observe in real-time how these changes affect the shape and position of the parabola and, consequently, its roots.

For example, if you enter y = x^2 - 3x + 2 into Desmos, you'll see a parabola that crosses the x-axis at x=1 and x=2, which are the roots calculated by our solver for a=1, b=-3, c=2.

Using the Calculator

Our Quadratic Equation Solver allows you to quickly find the roots of any quadratic equation by simply entering the coefficients a, b, and c. It will also tell you the discriminant and the nature of the roots, providing a complete analysis of your equation.

Example: For the equation x² - 5x + 6 = 0, you would enter:

  • Coefficient 'a': 1
  • Coefficient 'b': -5
  • Coefficient 'c': 6

The calculator would then output: Discriminant = 1, Root 1 = 3, Root 2 = 2, indicating two distinct real roots.

Leave a Comment