Algebra Calculator
Solve for x or simplify an expression in an algebra calculator that writes the steps out and the answer as an exact fraction, not a decimal that nearly works.
Solution
- The equation
- x + 12 = 5x - 8
- Everything to one side
- -4x + 20 = 0
- Divide by -4
- x = 5
- Check Exactly zero, computed in fractions rather than decimals, so this is a proof rather than a round-off that looks close.
- putting x = 5 into -4x + 20 gives 0
- Linear and quadratic equations are solved exactly. Higher degrees start with the rational root theorem, which finds every rational root. What is left is solved exactly where a formula applies and numerically where none does, complex roots included, and every root is checked by substitution.
- Polynomials in one variable. Trigonometry, logarithms, roots of expressions and calculus are outside what this does, and it names them rather than failing obscurely.
How the Algebra Calculator works
An equation solver finds the values of the variable that make an equation true, and for polynomials the method is always the same three moves: expand the brackets, get everything onto one side, then read off the answer according to the degree.
Take 3(x + 4) - 2x = 5x - 8. Expanding gives 3x + 12 - 2x = 5x - 8, and collecting like terms on the left gives x + 12. Subtracting the right side from both sides turns the whole thing into -4x + 20 = 0, and dividing by -4 gives x = 5. Substituting back is the check: 3(9) - 10 = 17, and 25 - 8 = 17.
That last step is worth insisting on. An answer you have verified is different in kind from an answer you have been handed, and because this calculator works in exact fractions rather than decimals, the check comes out as exactly zero rather than as 0.0000001 that you have to decide to believe.
Which is the other thing to say about exactness. 3x = 1 has the solution x = 1/3, and 1/3 has no decimal representation; 0.3333333333 is a different number. A calculator working in floating point will tell you that x/3 + 1/6 = 1/2 has the solution 0.9999999999999998, which is wrong, and nearly right in a way that is worse than being obviously wrong. Every coefficient here is a pair of integers and every answer is exact.
What the degree determines:
Degree 1, a linear equation, has exactly one solution, found by dividing: ax + b = 0 gives x = -b/a.
Degree 2 goes through the quadratic formula, and its discriminant b^2 - 4ac decides the shape of the answer before you compute it. Positive gives two real roots; a positive perfect square means both are rational and the quadratic factors over the integers. Zero gives one repeated root. Negative gives no real roots at all.
Degree 3 and above have no general formula worth using. There are cubic and quartic formulas and they are monstrous, and Abel proved in 1824 that no formula in radicals exists at all past degree four. What works instead is the rational root theorem: any rational root p/q must have p dividing the constant term and q dividing the leading coefficient. That gives a finite list of candidates, each one testable, and it is exhaustive: if none works, the equation has no rational roots. Finding one lets you divide it out and work on a smaller polynomial, which is how x^3 - 6x^2 + 11x - 6 = 0 comes apart into 1, 2 and 3.
When a factor with no rational roots is left, this calculator still solves it. A quadratic goes through the quadratic formula in exact surds. A quartic that splits into two quadratics with rational coefficients is factored, and the split is confirmed by multiplying the two back together in exact fractions. Anything else is solved numerically, complex roots included: x^3 - 2 = 0 gives x ≈ 1.25992105 and the pair -0.6299605249 ± 1.091123636i. Each numeric real root is checked by evaluating the polynomial exactly on either side of it and finding a sign change, and each complex one by substituting it back.
Two outcomes are not numbers and are worth recognizing. If the variable cancels entirely and leaves something true, like 2(x + 1) = 2x + 2, every value works. It is an identity rather than an equation. If it cancels and leaves something false, like 2(x + 1) = 2x + 3, nothing works. Both are correct answers and a calculator that reports "x = 0" for either is wrong.
A word on scope. This handles polynomials in one variable. It does not do trigonometry, logarithms, exponentials, calculus, inequalities, or expressions with the variable in a denominator or under a root. Those need a genuine computer algebra system, which is a different kind of program. Where you type one of them, this says which thing it cannot do rather than failing with something unhelpful.
Algebra Calculator FAQ
How do I solve for x?
Expand any brackets, collect like terms, move everything to one side so the equation reads something = 0, then divide by the coefficient of x. For 3(x + 4) - 2x = 5x - 8 that gives -4x + 20 = 0, so x = 5. Always substitute your answer back in to check it.
Why does this give fractions instead of decimals?
Because the fraction is the exact answer and the decimal is a rounding of it. 3x = 1 solves to exactly 1/3, and 0.3333333333 is a different number. Working in floating point makes x/3 + 1/6 = 1/2 solve to 0.9999999999999998: nearly right, which is worse than visibly wrong.
What does it mean when there is no solution?
The variable canceled out and left a false statement. 2(x + 1) = 2x + 3 simplifies to 2 = 3, which no value of x can fix. The opposite case is an identity, like 2(x + 1) = 2x + 2, where the variable cancels and leaves something true. Then every value works.
Can it solve cubic equations?
Yes. It first uses the rational root theorem: any rational root p/q has p dividing the constant term and q dividing the leading coefficient, which gives a finite list to test. Rational roots come out exactly. A factor with no rational roots is then solved numerically, complex roots included, and each root is checked by substitution.
Worked examples
Related calculators
- Fraction Calculator
- Factor Calculator
- Quadratic Formula Calculator
- System of Equations Calculator
- Log Calculator
- Distance Formula Calculator
- Slope Calculator
- Order of Operations Calculator
- Matrix Calculator
- Derivative Calculator
- Integral Calculator
- Pascal's Triangle
- Absolute Value Calculator
- Arithmetic Sequence Calculator