Solve linear and quadratic equations instantly with detailed breakdowns of every mathematical step.
1. Linear Equation Solver
Solves equations in the form: ax + b = c
2. Quadratic Equation Solver
Solves equations in the form: ax² + bx + c = 0
Understanding Algebraic Equations
Algebra is the branch of mathematics that uses letters (variables) to represent numbers in equations. The primary goal is usually to isolate the variable to find its value. Our algebra calculator with steps simplifies this process by showing you exactly how the transformation occurs.
How to Solve Linear Equations (ax + b = c)
Linear equations are the foundation of algebra. To solve for x, you must reverse the operations applied to it:
Step 1: Subtraction/Addition. Move the constant b to the other side by changing its sign.
Step 2: Division/Multiplication. Divide both sides by the coefficient a.
Example: Solve 2x + 10 = 20. Subtract 10: 2x = 10. Divide by 2: x = 5.
Solving Quadratic Equations (ax² + bx + c = 0)
Quadratic equations are identifiable by the squared term (x²). The most reliable way to solve these is using the Quadratic Formula:
x = [-b ± sqrt(b² – 4ac)] / 2a
The term b² – 4ac is called the Discriminant (D). It tells us the nature of the roots:
If D > 0: Two distinct real roots.
If D = 0: One real root (repeated).
If D < 0: Two complex (imaginary) roots.
Why Use an Algebra Solver with Steps?
Learning algebra is not just about getting the final answer; it is about understanding the logic of the steps. By using a step-by-step calculator, students can verify their manual work and identify exactly where they might have made a calculation error. This is particularly helpful for complex quadratic equations where signs (+ or -) can easily be misplaced during the application of the quadratic formula.
function solveLinear() {
var a = parseFloat(document.getElementById('linearA').value);
var b = parseFloat(document.getElementById('linearB').value);
var c = parseFloat(document.getElementById('linearC').value);
var resDiv = document.getElementById('linearResult');
var solText = document.getElementById('linearSolutionText');
var stepsDiv = document.getElementById('linearSteps');
if (isNaN(a) || isNaN(b) || isNaN(c)) {
alert("Please enter valid numbers for a, b, and c.");
return;
}
resDiv.style.display = "block";
if (a === 0) {
if (b === c) {
solText.innerHTML = "Result: Infinite Solutions";
stepsDiv.innerHTML = "Since a=0 and b=c, any value of x works.";
} else {
solText.innerHTML = "Result: No Solution";
stepsDiv.innerHTML = "Since a=0 and b≠c, the equation is mathematically impossible.";
}
return;
}
var x = (c – b) / a;
solText.innerHTML = "Result: x = " + x.toFixed(4).replace(/\.?0+$/, "") + "";
var steps = "Equation: " + a + "x + " + b + " = " + c + "";
steps += "Step 1: Subtract " + b + " from both sides:";
steps += a + "x = " + c + " – (" + b + ")";
steps += a + "x = " + (c – b) + "";
steps += "Step 2: Divide by " + a + ":";
steps += "x = " + (c – b) + " / " + a + "";
steps += "x = " + x.toFixed(4).replace(/\.?0+$/, "") + "";
stepsDiv.innerHTML = steps;
}
function solveQuadratic() {
var a = parseFloat(document.getElementById('quadA').value);
var b = parseFloat(document.getElementById('quadB').value);
var c = parseFloat(document.getElementById('quadC').value);
var resDiv = document.getElementById('quadResult');
var solText = document.getElementById('quadSolutionText');
var stepsDiv = document.getElementById('quadSteps');
if (isNaN(a) || isNaN(b) || isNaN(c)) {
alert("Please enter valid numbers for a, b, and c.");
return;
}
resDiv.style.display = "block";
if (a === 0) {
solText.innerHTML = "Note: This is a linear equation because a = 0.";
var xLin = -c / b;
stepsDiv.innerHTML = "Solving " + b + "x + " + c + " = 0x = " + xLin.toFixed(4);
return;
}
var disc = (b * b) – (4 * a * c);
var steps = "Equation: " + a + "x² + (" + b + ")x + (" + c + ") = 0";
steps += "Formula: x = [-b ± √(b² – 4ac)] / 2a";
steps += "Step 1: Calculate Discriminant (D)";
steps += "D = (" + b + ")² – 4 * (" + a + ") * (" + c + ")";
steps += "D = " + (b*b) + " – (" + (4*a*c) + ")";
steps += "D = " + disc + "";
if (disc > 0) {
var x1 = (-b + Math.sqrt(disc)) / (2 * a);
var x2 = (-b – Math.sqrt(disc)) / (2 * a);
solText.innerHTML = "Result: Two Real Rootsx₁ = " + x1.toFixed(4).replace(/\.?0+$/, "") + ", x₂ = " + x2.toFixed(4).replace(/\.?0+$/, "") + "";
steps += "Step 2: Since D > 0, calculate two roots:";
steps += "x = [" + (-b) + " ± √" + disc + "] / " + (2 * a) + "";
steps += "x₁ = (" + (-b) + " + " + Math.sqrt(disc).toFixed(4) + ") / " + (2 * a) + " = " + x1.toFixed(4) + "";
steps += "x₂ = (" + (-b) + " – " + Math.sqrt(disc).toFixed(4) + ") / " + (2 * a) + " = " + x2.toFixed(4);
} else if (disc === 0) {
var x = -b / (2 * a);
solText.innerHTML = "Result: One Real Rootx = " + x.toFixed(4).replace(/\.?0+$/, "") + "";
steps += "Step 2: Since D = 0, there is one repeated root:";
steps += "x = -b / 2a = " + (-b) + " / " + (2 * a) + "";
steps += "x = " + x.toFixed(4) + "";
} else {
var realPart = (-b / (2 * a)).toFixed(4);
var imagPart = (Math.sqrt(-disc) / (2 * a)).toFixed(4);
solText.innerHTML = "Result: Two Complex Rootsx = " + realPart + " ± " + imagPart + "i";
steps += "Step 2: Since D < 0, roots are complex (imaginary):";
steps += "x = [" + (-b) + " ± i√" + (-disc) + "] / " + (2 * a) + "";
steps += "x = " + realPart + " ± " + imagPart + "i";
}
stepsDiv.innerHTML = steps;
}