Quadratic Equation Solver (Step-by-Step)
Enter the coefficients a, b, and c for a quadratic equation in the form ax² + bx + c = 0 to find its roots and see the step-by-step solution.
Results:
Step-by-Step Solution:
Given Quadratic Equation:
'); steps.push('The general form of a quadratic equation isax² + bx + c = 0.');
steps.push('Your equation is: ' + a + 'x² + ' + b + 'x + ' + c + ' = 0');
steps.push('Step 1: Identify Coefficients
'); steps.push('From the equation, we have:'); steps.push('- ');
steps.push('
a = ' + a + '');
steps.push('b = ' + b + '');
steps.push('c = ' + c + '');
steps.push('
Step 2: Calculate the Discriminant (Δ)
'); steps.push('The discriminant is calculated using the formula:Δ = b² - 4ac');
var discriminant = (b * b) – (4 * a * c);
steps.push('Substitute the values:');
steps.push('Δ = (' + b + ')² - 4 * (' + a + ') * (' + c + ')');
steps.push('Δ = ' + (b * b) + ' - ' + (4 * a * c) + '');
steps.push('Δ = ' + discriminant + '');
steps.push('Step 3: Determine the Nature of the Roots
'); if (discriminant > 0) { steps.push('SinceΔ > 0, there are two distinct real roots.');
steps.push('Step 4: Calculate the Roots
'); steps.push('The roots are found using the quadratic formula:x = (-b ± √Δ) / 2a');
steps.push('Substitute the values:');
steps.push('x = (-(' + b + ') ± √(' + discriminant + ')) / (2 * ' + a + ')');
steps.push('x = (' + (-b) + ' ± ' + Math.sqrt(discriminant).toFixed(4) + ') / ' + (2 * a) + '');
var x1 = (-b + Math.sqrt(discriminant)) / (2 * a);
var x2 = (-b – Math.sqrt(discriminant)) / (2 * a);
steps.push('For x1 (using +): x1 = (' + (-b) + ' + ' + Math.sqrt(discriminant).toFixed(4) + ') / ' + (2 * a) + ' = ' + x1.toFixed(4) + '');
steps.push('For x2 (using -): x2 = (' + (-b) + ' - ' + Math.sqrt(discriminant).toFixed(4) + ') / ' + (2 * a) + ' = ' + x2.toFixed(4) + '');
resultOutput.innerHTML = 'The roots are: x1 = ' + x1.toFixed(4) + ' and x2 = ' + x2.toFixed(4) + '';
} else if (discriminant === 0) {
steps.push('Since Δ = 0, there is exactly one real root (a repeated root).');
steps.push('Step 4: Calculate the Root
'); steps.push('The root is found using the simplified quadratic formula:x = -b / 2a');
steps.push('Substitute the values:');
steps.push('x = (-(' + b + ')) / (2 * ' + a + ')');
steps.push('x = ' + (-b) + ' / ' + (2 * a) + '');
var x = -b / (2 * a);
steps.push('x = ' + x.toFixed(4) + '');
resultOutput.innerHTML = 'The single real root is: x = ' + x.toFixed(4) + '';
} else { // discriminant < 0
steps.push('Since Δ < 0, there are two distinct complex (non-real) roots.');
steps.push('Step 4: Calculate the Complex Roots
'); steps.push('The roots are found using the quadratic formula:x = (-b ± i√|Δ|) / 2a');
steps.push('Substitute the values:');
steps.push('x = (-(' + b + ') ± i√(' + Math.abs(discriminant) + ')) / (2 * ' + a + ')');
steps.push('x = (' + (-b) + ' ± i * ' + Math.sqrt(Math.abs(discriminant)).toFixed(4) + ') / ' + (2 * a) + '');
var realPart = (-b / (2 * a)).toFixed(4);
var imaginaryPart = (Math.sqrt(Math.abs(discriminant)) / (2 * a)).toFixed(4);
steps.push('For x1: x1 = ' + realPart + ' + ' + imaginaryPart + 'i');
steps.push('For x2: x2 = ' + realPart + ' - ' + imaginaryPart + 'i');
resultOutput.innerHTML = 'The complex roots are: x1 = ' + realPart + ' + ' + imaginaryPart + 'i and x2 = ' + realPart + ' - ' + imaginaryPart + 'i';
}
stepsOutput.innerHTML = steps.join(");
}
.calculator-container {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
padding: 25px;
max-width: 700px;
margin: 20px auto;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.calculator-container h2 {
color: #333;
text-align: center;
margin-bottom: 20px;
font-size: 1.8em;
}
.calculator-container h3 {
color: #555;
margin-top: 25px;
margin-bottom: 10px;
font-size: 1.3em;
border-bottom: 1px solid #eee;
padding-bottom: 5px;
}
.calculator-container p {
color: #666;
line-height: 1.6;
margin-bottom: 10px;
}
.calculator-inputs label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: bold;
}
.calculator-inputs input[type="number"] {
width: calc(100% – 22px);
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1em;
box-sizing: border-box;
}
.calculator-inputs input[type="number"]:focus {
border-color: #007bff;
outline: none;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}
.calculator-container button {
background-color: #007bff;
color: white;
padding: 12px 25px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1.1em;
display: block;
width: 100%;
margin-top: 20px;
transition: background-color 0.3s ease;
}
.calculator-container button:hover {
background-color: #0056b3;
}
.calculator-results {
background-color: #e9f7ff;
border: 1px solid #cce5ff;
border-radius: 8px;
padding: 20px;
margin-top: 30px;
}
.calculator-results p {
margin-bottom: 8px;
color: #333;
}
.calculator-results ul {
list-style-type: disc;
margin-left: 20px;
margin-bottom: 10px;
color: #444;
}
.calculator-results ul li {
margin-bottom: 5px;
}
.calculator-results code {
background-color: #f0f0f0;
padding: 2px 5px;
border-radius: 3px;
font-family: 'Courier New', Courier, monospace;
color: #c7254e;
}
#resultOutput p {
font-size: 1.1em;
font-weight: bold;
color: #0056b3;
}
#stepsOutput h4 {
color: #007bff;
margin-top: 15px;
margin-bottom: 8px;
font-size: 1.15em;
}
Understanding the Quadratic Equation and Its Solutions
A quadratic equation is a polynomial equation of the second degree, meaning it contains at least one term in which the unknown variable is raised to the power of two. The standard form of a quadratic equation is written as:
ax² + bx + c = 0
Where:
xrepresents the unknown variable.a,b, andcare coefficients, withanot equal to zero. Ifawere zero, the equation would become linear (bx + c = 0).
Quadratic equations are fundamental in mathematics and appear in various fields, including physics, engineering, economics, and computer science, to model phenomena like projectile motion, areas, and optimization problems.
The Quadratic Formula
While some quadratic equations can be solved by factoring or completing the square, the most universal method is using the quadratic formula. This formula provides the values of x (also known as the roots or solutions) that satisfy the equation. The quadratic formula is:
x = (-b ± √(b² - 4ac)) / 2a
This formula allows you to find the roots regardless of whether they are real or complex numbers.
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 without actually calculating them:
- If
Δ > 0(positive): The equation has two distinct real roots. This means the parabola (the graph of a quadratic equation) intersects the x-axis at two different points. - If
Δ = 0(zero): The equation has exactly one real root (a repeated root). In this case, the parabola touches the x-axis at exactly one point. - If
Δ < 0(negative): The equation has two distinct complex (non-real) roots. The parabola does not intersect the x-axis at all. These roots involve the imaginary uniti, wherei = √-1.
How to Use the Quadratic Equation Solver
Our step-by-step calculator simplifies the process of solving quadratic equations:
- Identify Coefficients: Look at your quadratic equation (e.g.,
2x² + 5x - 3 = 0). Identify the values fora,b, andc. In this example,a=2,b=5, andc=-3. - Input Values: Enter these values into the respective input fields for "Coefficient 'a'", "Coefficient 'b'", and "Coefficient 'c'".
- Calculate: Click the "Calculate Roots" button.
- Review Results and Steps: The calculator will instantly display the roots of the equation and a detailed breakdown of each step, including the calculation of the discriminant and the application of the quadratic formula.
Examples of Quadratic Equations
Let's look at a few examples to illustrate the different types of roots:
Example 1: Two Distinct Real Roots
Equation: x² - 3x + 2 = 0
a = 1b = -3c = 2
Discriminant: Δ = (-3)² - 4(1)(2) = 9 - 8 = 1
Since Δ > 0, there are two real roots.
Roots: x = (3 ± √1) / 2(1)
x1 = (3 + 1) / 2 = 2
x2 = (3 - 1) / 2 = 1
Example 2: One Real (Repeated) Root
Equation: x² - 4x + 4 = 0
a = 1b = -4c = 4
Discriminant: Δ = (-4)² - 4(1)(4) = 16 - 16 = 0
Since Δ = 0, there is one real root.
Root: x = (4 ± √0) / 2(1) = 4 / 2 = 2
Example 3: Two Complex Roots
Equation: x² + 2x + 5 = 0
a = 1b = 2c = 5
Discriminant: Δ = (2)² - 4(1)(5) = 4 - 20 = -16
Since Δ < 0, there are two complex roots.
Roots: x = (-2 ± √-16) / 2(1) = (-2 ± 4i) / 2
x1 = -1 + 2i
x2 = -1 - 2i
This calculator is a valuable tool for students, educators, and professionals who need to quickly and accurately solve quadratic equations and understand the underlying mathematical steps.