Quadratic Equation Calculator

Quadratic Equation Calculator

ax² + bx + c = 0

Calculation Results:


Understanding the Quadratic Equation

A quadratic equation is a second-order polynomial equation in a single variable. The standard form is expressed as ax² + bx + c = 0, where 'x' represents an unknown value, and 'a', 'b', and 'c' are known coefficients. The coefficient 'a' cannot be zero, as that would turn the equation into a linear one.

The Quadratic Formula

To find the values of x (the roots), we use the quadratic formula:

x = (-b ± √(b² – 4ac)) / 2a

The Role of the Discriminant

The term inside the square root, b² – 4ac, is known as the discriminant (D). It determines the nature of the roots:

  • D > 0: There are two distinct real roots.
  • D = 0: There is exactly one real root (a repeated root).
  • D < 0: There are two complex (imaginary) roots.

Real-World Example

Imagine a ball thrown into the air. Its height (h) over time (t) can be modeled by a quadratic equation. If the equation is -5t² + 20t + 0 = 0, solving for t tells you when the ball hits the ground.

  • a = -5
  • b = 20
  • c = 0

Using the calculator above, you would find that the ball is at ground level at t=0 (launch) and t=4 (landing).

function solveQuadratic() { var a = parseFloat(document.getElementById("coeffA").value); var b = parseFloat(document.getElementById("coeffB").value); var c = parseFloat(document.getElementById("coeffC").value); var outputDiv = document.getElementById("solution-output"); var stepsDiv = document.getElementById("steps"); var rootsDiv = document.getElementById("final-roots"); if (isNaN(a) || isNaN(b) || isNaN(c)) { alert("Please enter valid numerical coefficients."); return; } if (a === 0) { outputDiv.style.display = "block"; stepsDiv.innerHTML = "Since a = 0, this is a linear equation: " + b + "x + " + c + " = 0″; var linearRoot = -c / b; rootsDiv.innerHTML = "x = " + linearRoot.toFixed(4); return; } var discriminant = (b * b) – (4 * a * c); var resultHtml = "1. Find Discriminant (D): " + b + "² – 4(" + a + ")(" + c + ") = " + discriminant.toFixed(4) + ""; outputDiv.style.display = "block"; if (discriminant > 0) { var x1 = (-b + Math.sqrt(discriminant)) / (2 * a); var x2 = (-b – Math.sqrt(discriminant)) / (2 * a); resultHtml += "2. D > 0: Two distinct real roots found."; resultHtml += "3. Apply Formula: x = (-" + b + " ± √" + discriminant.toFixed(2) + ") / " + (2 * a); stepsDiv.innerHTML = resultHtml; rootsDiv.innerHTML = "x₁ = " + x1.toFixed(4) + "x₂ = " + x2.toFixed(4); } else if (discriminant === 0) { var x = -b / (2 * a); resultHtml += "2. D = 0: One repeated real root found."; resultHtml += "3. Apply Formula: x = -" + b + " / " + (2 * a); stepsDiv.innerHTML = resultHtml; rootsDiv.innerHTML = "x = " + x.toFixed(4); } else { var realPart = (-b / (2 * a)).toFixed(4); var imaginaryPart = (Math.sqrt(-discriminant) / (2 * a)).toFixed(4); resultHtml += "2. D < 0: Complex roots found."; resultHtml += "3. Apply Formula: x = (" + (-b) + " ± i√" + Math.abs(discriminant).toFixed(2) + ") / " + (2 * a); stepsDiv.innerHTML = resultHtml; rootsDiv.innerHTML = "x₁ = " + realPart + " + " + Math.abs(imaginaryPart) + "ix₂ = " + realPart + " – " + Math.abs(imaginaryPart) + "i"; } }

Leave a Comment