Quadratic Equation Calculator
Solve for x in equations of the form ax² + bx + c = 0
Understanding the Quadratic Equation
A quadratic equation is a second-degree polynomial equation, meaning it contains at least one term that is squared. The standard form of a quadratic equation is:
ax² + bx + c = 0
where:
a,b, andcare coefficients (constants).xis the variable for which we are solving.acannot be zero. Ifa = 0, the equation becomes a linear equation (bx + c = 0).
The Discriminant
The nature of the solutions (roots) of a quadratic equation depends on a value called the discriminant, which is calculated as:
Δ = b² - 4ac
- If
Δ > 0: There are two distinct real solutions. - If
Δ = 0: There is exactly one real solution (a repeated root). - If
Δ < 0: There are two complex conjugate solutions.
The Quadratic Formula
The solutions for x are found using the quadratic formula:
x = [-b ± √(b² - 4ac)] / 2a
This formula directly uses the coefficients a, b, and c to find the values of x that satisfy the equation.
How This Calculator Works
This calculator takes the coefficients a, b, and c that you input and:
- Checks if
ais zero. If it is, it informs you it's not a quadratic equation and solves it as a linear equation if possible. - Calculates the discriminant (
Δ = b² - 4ac) to determine the type of roots. - Applies the quadratic formula to find the real or complex roots.
- Displays the calculated roots and shows the step-by-step process, including the discriminant calculation.
Use Cases
Quadratic equations and their solutions have numerous applications in various fields:
- Physics: Calculating projectile motion (e.g., the path of a ball thrown in the air), determining the time it takes for an object to fall under gravity.
- Engineering: Designing structures, analyzing electrical circuits.
- Economics: Modeling cost and revenue functions, finding optimal production levels.
- Geometry: Finding areas, calculating dimensions of shapes.
- Mathematics: Understanding parabolas and their properties, solving algebraic problems.
By understanding and solving quadratic equations, we can model and predict phenomena in the real world more effectively.
Calculation Steps
"; stepsHTML += "Given equation:ax² + bx + c = 0";
stepsHTML += "Coefficients: a = " + a + ", b = " + b + ", c = " + c + "";
// Case: a = 0 (Linear Equation)
if (a === 0) {
stepsHTML += "Since a = 0, this is a linear equation: bx + c = 0";
if (b !== 0) {
var x_linear = -c / b;
stepsHTML += "Solving for x: x = -c / b";
stepsHTML += "Result: x = " + x_linear.toFixed(4) + "";
resultDiv.innerHTML = "Linear Equation Solution
x = " + x_linear.toFixed(4) + ""; } else { // a = 0 and b = 0 stepsHTML += "Since a = 0 and b = 0:"; if (c === 0) { stepsHTML += "The equation is0 = 0, which is true for all values of x (infinite solutions).";
resultDiv.innerHTML = "Linear Equation Result
Infinite solutions (0 = 0).";
} else {
stepsHTML += "The equation is " + c + " = 0, which is false (no solution).";
resultDiv.innerHTML = "Linear Equation Result
No solution (" + c + " = 0 is false).";
}
}
stepsDiv.innerHTML = stepsHTML;
return;
}
// Quadratic Equation Calculations
stepsHTML += "Calculate the discriminant (Δ): Δ = b² - 4ac";
var discriminant = (b * b) – (4 * a * c);
stepsHTML += "Δ = (" + b + ")² – 4 * (" + a + ") * (" + c + ")";
stepsHTML += "Δ = " + (b * b) + " – " + (4 * a * c) + "";
stepsHTML += "Δ = " + discriminant.toFixed(4) + "";
var solutions = [];
var resultHTML = "Quadratic Equation Solutions
"; if (discriminant > 0) { stepsHTML += "Since Δ > 0, there are two distinct real solutions."; var x1 = (-b + Math.sqrt(discriminant)) / (2 * a); var x2 = (-b – Math.sqrt(discriminant)) / (2 * a); solutions.push(x1, x2); stepsHTML += "Using the quadratic formula:x = [-b ± √Δ] / 2a";
stepsHTML += "First solution (using +): x₁ = (-" + b + " + √" + discriminant.toFixed(4) + ") / (2 * " + a + ")";
stepsHTML += "x₁ = (" + (-b) + " + " + Math.sqrt(discriminant).toFixed(4) + ") / " + (2 * a) + "";
stepsHTML += "x₁ = " + ((-b) + Math.sqrt(discriminant)).toFixed(4) + " / " + (2 * a) + "";
stepsHTML += "x₁ = " + x1.toFixed(4) + "";
stepsHTML += "Second solution (using -): x₂ = (-" + b + " - √" + discriminant.toFixed(4) + ") / (2 * " + a + ")";
stepsHTML += "x₂ = (" + (-b) + " - " + Math.sqrt(discriminant).toFixed(4) + ") / " + (2 * a) + "";
stepsHTML += "x₂ = " + ((-b) - Math.sqrt(discriminant)).toFixed(4) + " / " + (2 * a) + "";
stepsHTML += "x₂ = " + x2.toFixed(4) + "";
resultHTML += "x₁ = " + x1.toFixed(4) + "";
resultHTML += "x₂ = " + x2.toFixed(4) + "";
} else if (discriminant === 0) {
stepsHTML += "Since Δ = 0, there is exactly one real solution (a repeated root).";
var x = -b / (2 * a);
solutions.push(x);
stepsHTML += "Using the quadratic formula: x = -b / 2a";
stepsHTML += "x = -(" + b + ") / (2 * " + a + ")";
stepsHTML += "x = " + (-b) + " / " + (2 * a) + "";
stepsHTML += "x = " + x.toFixed(4) + "";
resultHTML += "x = " + x.toFixed(4) + " (repeated root)";
} else { // discriminant < 0
stepsHTML += "Since Δ < 0, there are two complex conjugate solutions.";
var realPart = -b / (2 * a);
var imaginaryPart = Math.sqrt(-discriminant) / (2 * a);
solutions.push(realPart + " + " + imaginaryPart + "i", realPart + " – " + imaginaryPart + "i");
stepsHTML += "Using the quadratic formula: x = [-b ± i√(-Δ)] / 2a";
stepsHTML += "Real part: -b / 2a";
stepsHTML += "Real part = -" + b + " / (2 * " + a + ") = " + realPart.toFixed(4) + "";
stepsHTML += "Imaginary part: √(-Δ) / 2a";
stepsHTML += "Imaginary part = √(" + (-discriminant).toFixed(4) + ") / " + (2 * a) + " = " + Math.sqrt(-discriminant).toFixed(4) + " / " + (2 * a) + " = " + imaginaryPart.toFixed(4) + "";
stepsHTML += "First complex solution: x₁ = " + realPart.toFixed(4) + " + " + imaginaryPart.toFixed(4) + "i";
stepsHTML += "Second complex solution: x₂ = " + realPart.toFixed(4) + " – " + imaginaryPart.toFixed(4) + "i";
resultHTML += "x₁ = " + realPart.toFixed(4) + " + " + imaginaryPart.toFixed(4) + "i";
resultHTML += "x₂ = " + realPart.toFixed(4) + " – " + imaginaryPart.toFixed(4) + "i";
}
resultDiv.innerHTML = resultHTML;
stepsDiv.innerHTML = stepsHTML;
}