Enter coefficients 'a', 'b', and 'c' to see the steps.
Solutions (Roots)
Results will appear here.
Understanding the Quadratic Formula
A quadratic equation is a polynomial equation of the second degree, 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', and 'c' are coefficients (constants), and 'x' is the variable we want to solve for. The coefficient 'a' cannot be zero, otherwise, it would be a linear equation, not a quadratic one.
The Discriminant (Δ)
Before finding the roots, it's crucial to calculate the discriminant, denoted by the Greek letter delta (Δ). The discriminant tells us about the nature of the roots:
Δ = b² – 4ac
If Δ > 0: There are two distinct real roots.
If Δ = 0: There is exactly one real root (a repeated root).
If Δ < 0: There are two distinct complex roots (involving the imaginary unit 'i').
The Quadratic Formula
The quadratic formula is used to find the solutions (also called roots or zeros) of a quadratic equation. It is derived by applying algebraic methods (like completing the square) to the standard form of the quadratic equation. The formula is:
x = [-b ± √(b² – 4ac)] / 2a
This single formula elegantly provides all possible solutions for 'x'. The '±' symbol indicates that there are two potential solutions: one using the plus sign and one using the minus sign.
How to Use the Calculator
To use this calculator, simply input the numerical values for the coefficients 'a', 'b', and 'c' from your quadratic equation (ax² + bx + c = 0) into the respective fields. The calculator will then compute and display:
The value of the discriminant (Δ).
The nature of the roots based on the discriminant.
The step-by-step calculation process.
The final real or complex roots of the equation.
Examples of Use Cases
The quadratic formula and equations are fundamental in many areas of mathematics, science, and engineering:
Physics: Calculating projectile motion (e.g., the trajectory of a ball thrown in the air), where the height often follows a parabolic path described by a quadratic equation.
Engineering: Designing structures, optimizing processes, and analyzing circuits.
Economics: Modeling cost functions, revenue, and profit maximization.
Geometry: Finding intersections between curves and lines.
General Problem Solving: Many real-world optimization problems can be framed and solved using quadratic equations.
Understanding and applying the quadratic formula is a key skill for anyone studying algebra or working in fields that involve mathematical modeling.
function calculateQuadratic() {
var a = parseFloat(document.getElementById("coeffA").value);
var b = parseFloat(document.getElementById("coeffB").value);
var c = parseFloat(document.getElementById("coeffC").value);
var stepOutput = document.getElementById("step-output");
var resultOutput = document.getElementById("result-output");
// Clear previous results
stepOutput.innerHTML = "";
resultOutput.innerHTML = "";
// Input validation
if (isNaN(a) || isNaN(b) || isNaN(c)) {
stepOutput.innerHTML = "Please enter valid numerical values for all coefficients.";
resultOutput.innerHTML = "Error in input.";
return;
}
if (a === 0) {
stepOutput.innerHTML = "Coefficient 'a' cannot be zero for a quadratic equation. This is a linear equation.";
resultOutput.innerHTML = "Not a quadratic equation.";
return;
}
// Step 1: Calculate the Discriminant
var discriminant = b * b – 4 * a * c;
stepOutput.innerHTML += "Step 1: Calculate the Discriminant (Δ)";
stepOutput.innerHTML += "Δ = b² – 4ac";
stepOutput.innerHTML += `Δ = (${b})² – 4 * (${a}) * (${c})`;
stepOutput.innerHTML += `Δ = ${b * b} – ${4 * a * c}`;
stepOutput.innerHTML += `Δ = ${discriminant}`;
var roots = [];
var root1, root2;
// Step 2: Determine the nature of the roots and calculate them
if (discriminant > 0) {
stepOutput.innerHTML += "Step 2: Calculate the Roots (since Δ > 0, there are two distinct real roots)";
root1 = (-b + Math.sqrt(discriminant)) / (2 * a);
root2 = (-b – Math.sqrt(discriminant)) / (2 * a);
stepOutput.innerHTML += "Using the formula: x = [-b ± √(Δ)] / 2a";
stepOutput.innerHTML += `Root 1 (using +):`;
stepOutput.innerHTML += `x₁ = [ -(${b}) + √(${discriminant}) ] / (2 * ${a})`;
stepOutput.innerHTML += `x₁ = [ ${-b} + ${Math.sqrt(discriminant)} ] / ${2 * a}`;
stepOutput.innerHTML += `x₁ = ${-b + Math.sqrt(discriminant)} / ${2 * a}`;
stepOutput.innerHTML += `x₁ ≈ ${root1.toFixed(4)}`;
stepOutput.innerHTML += `Root 2 (using -):`;
stepOutput.innerHTML += `x₂ = [ -(${b}) – √(${discriminant}) ] / (2 * ${a})`;
stepOutput.innerHTML += `x₂ = [ ${-b} – ${Math.sqrt(discriminant)} ] / ${2 * a}`;
stepOutput.innerHTML += `x₂ = ${-b – Math.sqrt(discriminant)} / ${2 * a}`;
stepOutput.innerHTML += `x₂ ≈ ${root2.toFixed(4)}`;
resultOutput.innerHTML = `x₁ ≈ ${root1.toFixed(4)}, x₂ ≈ ${root2.toFixed(4)}`;
} else if (discriminant === 0) {
stepOutput.innerHTML += "Step 2: Calculate the Root (since Δ = 0, there is one real root)";
root1 = -b / (2 * a);
stepOutput.innerHTML += "Using the formula: x = -b / 2a";
stepOutput.innerHTML += `x = -(${b}) / (2 * ${a})`;
stepOutput.innerHTML += `x = ${-b} / ${2 * a}`;
stepOutput.innerHTML += `x = ${root1.toFixed(4)}`;
resultOutput.innerHTML = `x = ${root1.toFixed(4)} (repeated root)`;
} else { // discriminant < 0
stepOutput.innerHTML += "Step 2: Calculate the Complex Roots (since Δ < 0, there are two complex roots)";
var realPart = -b / (2 * a);
var imaginaryPart = Math.sqrt(-discriminant) / (2 * a);
stepOutput.innerHTML += "Using the formula: x = [-b ± i√(-Δ)] / 2a";
stepOutput.innerHTML += `Root 1 (using +):`;
stepOutput.innerHTML += `x₁ = [ -(${b}) + i√(${-discriminant}) ] / (2 * ${a})`;
stepOutput.innerHTML += `x₁ = ${-b} / ${2 * a} + i * √(${-discriminant}) / ${2 * a}`;
stepOutput.innerHTML += `x₁ = ${realPart.toFixed(4)} + i * ${imaginaryPart.toFixed(4)}`;
stepOutput.innerHTML += `x₁ = ${realPart.toFixed(4)} + ${imaginaryPart.toFixed(4)}i`;
stepOutput.innerHTML += `Root 2 (using -):`;
stepOutput.innerHTML += `x₂ = [ -(${b}) – i√(${-discriminant}) ] / (2 * ${a})`;
stepOutput.innerHTML += `x₂ = ${-b} / ${2 * a} – i * √(${-discriminant}) / ${2 * a}`;
stepOutput.innerHTML += `x₂ = ${realPart.toFixed(4)} – i * ${imaginaryPart.toFixed(4)}`;
stepOutput.innerHTML += `x₂ = ${realPart.toFixed(4)} – ${imaginaryPart.toFixed(4)}i`;
resultOutput.innerHTML = `x₁ = ${realPart.toFixed(4)} + ${imaginaryPart.toFixed(4)}i, x₂ = ${realPart.toFixed(4)} – ${imaginaryPart.toFixed(4)}i`;
}
}