Quadratic Equation Calculator (Step-by-Step)
Results
Understanding the Quadratic Equation
A quadratic equation is a second-degree polynomial equation, meaning it contains at least one term that is squared. The general form of a quadratic equation is:
ax² + bx + c = 0
where:
a,b, andcare coefficients (numbers), andacannot be zero (ifa=0, it becomes a linear equation).
The goal is to find the value(s) of x that satisfy this equation. These values are called the roots or solutions of the equation. A quadratic equation can have:
- Two distinct real roots
- One real root (a repeated root)
- Two complex roots (involving imaginary numbers)
The Quadratic Formula
The most common and reliable method for solving quadratic equations is the quadratic formula, derived using a technique called completing the square:
x = [-b ± √(b² – 4ac)] / 2a
The Discriminant (Δ)
A crucial part of the quadratic formula is the expression under the square root sign: b² - 4ac. This is called the discriminant (often denoted by the Greek letter delta, Δ).
The discriminant tells us about the nature of the roots:
- If Δ > 0: There are two distinct real roots.
- If Δ = 0: There is exactly one real root (a repeated root).
- If Δ < 0: There are two complex conjugate roots.
Step-by-Step Calculation Process
- Identify Coefficients: Determine the values of
a,b, andcfrom your equation (ensure it's in the standard form ax² + bx + c = 0). - Calculate the Discriminant: Compute Δ =
b² - 4ac. - Analyze the Discriminant:
- If Δ ≥ 0, proceed to calculate real roots.
- If Δ < 0, calculate complex roots.
- Apply the Quadratic Formula: Substitute the values of
a,b,c, and the discriminant into the formula to find the value(s) ofx.
Use Cases for Quadratic Equations
Quadratic equations appear in various fields:
- Physics: Modeling projectile motion (e.g., the path of a ball thrown into the air).
- Engineering: Designing structures, calculating areas, and optimizing performance.
- Economics: Analyzing cost functions, revenue, and profit maximization.
- Geometry: Calculating areas and solving problems involving shapes like parabolas.
- Finance: Modeling growth patterns or investment returns.
bx + c = 0. The solution is x = -c / b (if b is not zero).';
return;
}
// Step 1: Display Input Coefficients
stepDiv.innerHTML += 'Step 1: Identified Coefficients';
stepDiv.innerHTML += 'Equation: ' + a + 'x² + ' + b + 'x + ' + c + ' = 0';
stepDiv.innerHTML += 'a = ' + a + ', b = ' + b + ', c = ' + c + ";
// Step 2: Calculate the Discriminant
var discriminant = b * b – 4 * a * c;
stepDiv.innerHTML += 'Step 2: Calculate the Discriminant (Δ)';
stepDiv.innerHTML += 'Formula: Δ = b² – 4ac';
stepDiv.innerHTML += 'Calculation: Δ = (' + b + ')² – 4 * (' + a + ') * (' + c + ') = ' + discriminant + ";
var x1, x2;
// Step 3: Analyze Discriminant and Calculate Roots
stepDiv.innerHTML += 'Step 3: Analyze Discriminant and Find Roots';
if (discriminant > 0) {
// Two distinct real roots
x1 = (-b + Math.sqrt(discriminant)) / (2 * a);
x2 = (-b – Math.sqrt(discriminant)) / (2 * a);
stepDiv.innerHTML += 'Since Δ (' + discriminant + ') > 0, there are two distinct real roots.';
stepDiv.innerHTML += 'Step 4: Apply the Quadratic Formula';
stepDiv.innerHTML += 'x₁ = [-b + √(Δ)] / 2a = [-(' + b + ') + √(' + discriminant + ')] / (2 * ' + a + ') = ' + x1.toFixed(4) + ";
stepDiv.innerHTML += 'x₂ = [-b – √(Δ)] / 2a = [-(' + b + ') – √(' + discriminant + ')] / (2 * ' + a + ') = ' + x2.toFixed(4) + ";
resultsDiv.innerText = 'Solutions: x₁ = ' + x1.toFixed(4) + ', x₂ = ' + x2.toFixed(4);
resultsDiv.style.color = '#28a745'; // Success Green
} else if (discriminant === 0) {
// One real root (repeated)
x1 = -b / (2 * a);
stepDiv.innerHTML += 'Since Δ (' + discriminant + ') = 0, there is exactly one real root (a repeated root).';
stepDiv.innerHTML += 'Step 4: Apply the Quadratic Formula';
stepDiv.innerHTML += 'x = -b / 2a = -(' + b + ') / (2 * ' + a + ') = ' + x1.toFixed(4) + ";
resultsDiv.innerText = 'Solution: x = ' + x1.toFixed(4) + ' (repeated root)';
resultsDiv.style.color = '#28a745'; // Success Green
} else {
// Two complex roots
var realPart = -b / (2 * a);
var imaginaryPart = Math.sqrt(-discriminant) / (2 * a);
stepDiv.innerHTML += 'Since Δ (' + discriminant + ') < 0, there are two complex conjugate roots.';
stepDiv.innerHTML += 'Step 4: Apply the Quadratic Formula for Complex Roots';
stepDiv.innerHTML += 'Real Part = -b / 2a = -(' + b + ') / (2 * ' + a + ') = ' + realPart.toFixed(4) + ";
stepDiv.innerHTML += 'Imaginary Part = √(-Δ) / 2a = √(' + (-discriminant) + ') / (2 * ' + a + ') = ' + imaginaryPart.toFixed(4) + ";
stepDiv.innerHTML += 'x₁ = ' + realPart.toFixed(4) + ' + i' + imaginaryPart.toFixed(4) + ";
stepDiv.innerHTML += 'x₂ = ' + realPart.toFixed(4) + ' – i' + imaginaryPart.toFixed(4) + ";
resultsDiv.innerText = 'Complex Solutions: x₁ = ' + realPart.toFixed(4) + ' + i' + imaginaryPart.toFixed(4) + ', x₂ = ' + realPart.toFixed(4) + ' – i' + imaginaryPart.toFixed(4);
resultsDiv.style.color = '#dc3545'; // Error/Warning Color
}
}