Solve quadratic equations of the form ax² + bx + c = 0 instantly.
Step-by-Step Solution:
function calculateQuadratic() {
var a = parseFloat(document.getElementById('coeffA').value);
var b = parseFloat(document.getElementById('coeffB').value);
var c = parseFloat(document.getElementById('coeffC').value);
var resultDiv = document.getElementById('solutionResult');
var stepsDiv = document.getElementById('calcSteps');
if (isNaN(a) || isNaN(b) || isNaN(c)) {
alert("Please enter valid numbers for coefficients a, b, and c.");
return;
}
if (a === 0) {
alert("Coefficient 'a' cannot be zero for a quadratic equation.");
return;
}
resultDiv.style.display = "block";
var discriminant = (b * b) – (4 * a * c);
var steps = "1. Identify coefficients: a = " + a + ", b = " + b + ", c = " + c + "";
steps += "2. Calculate Discriminant (D): D = b² – 4ac";
steps += "D = (" + b + ")² – 4(" + a + ")(" + c + ") = " + discriminant + "";
if (discriminant > 0) {
var x1 = (-b + Math.sqrt(discriminant)) / (2 * a);
var x2 = (-b – Math.sqrt(discriminant)) / (2 * a);
steps += "3. Real Roots found: Since D > 0, there are two distinct real roots.";
steps += "x = (-b ± √D) / 2a";
steps += "x₁ = (" + (-b) + " + " + Math.sqrt(discriminant).toFixed(4) + ") / " + (2 * a) + " = " + x1.toFixed(4) + "";
steps += "x₂ = (" + (-b) + " – " + Math.sqrt(discriminant).toFixed(4) + ") / " + (2 * a) + " = " + x2.toFixed(4) + "";
} else if (discriminant === 0) {
var x = -b / (2 * a);
steps += "3. One Real Root found: Since D = 0, there is one repeated real root.";
steps += "x = -b / 2a = " + (-b) + " / " + (2 * a) + " = " + x.toFixed(4) + "";
} else {
var realPart = (-b / (2 * a)).toFixed(4);
var imagPart = (Math.sqrt(-discriminant) / (2 * a)).toFixed(4);
steps += "3. Complex Roots found: Since D < 0, roots are imaginary.";
steps += "x = " + realPart + " ± " + imagPart + "i";
}
stepsDiv.innerHTML = steps;
}
Understanding the Symbolab Quadratic Solver
The quadratic equation is a fundamental pillar of algebra, appearing in everything from physics trajectories to financial modeling. A quadratic equation is any equation that can be rearranged in standard form as ax² + bx + c = 0, where x represents an unknown, and a, b, and c represent known numbers.
The Quadratic Formula
This calculator utilizes the quadratic formula to find the roots of the equation:
x = [-b ± sqrt(b² – 4ac)] / 2a
How to Use This Calculator
Input A: The coefficient of the x² term. This cannot be zero.
Input B: The coefficient of the x term.
Input C: The constant term.
Click Solve Equation to see the discriminant and the final roots.