The Equation Solver, Explained
After reading this you will know how to find every root of a polynomial from its coefficients, how to solve a linear system A\mathbf{x} = \mathbf{b}, and how to read the results when a system has no exact solution.
What this solver does
The Equation Solver works in two modes. In polynomial mode it takes a list of coefficients and returns all roots, both real and complex. In system mode it takes a matrix A and a vector \mathbf{b} and returns the vector \mathbf{x} that satisfies A\mathbf{x} = \mathbf{b}.
Here is the hook. Type the coefficients 1, -6, 11, -6. These describe the cubic x^3 - 6x^2 + 11x - 6. The solver returns 1, 2, 3. You can check this by hand: the product of the roots is 1 \cdot 2 \cdot 3 = 6, which matches the constant term rule for a monic cubic, and their sum is 1 + 2 + 3 = 6, which matches the negated x^2 coefficient.
When to use it, and when not to
Reach for polynomial mode when you have a single-variable equation written as a sum of powers, and you want numeric roots. A degree-n polynomial has exactly n roots in the complex numbers, counted with multiplicity, so the solver always returns n values.
Reach for system mode when you have several linear equations in several unknowns. Three equations in three unknowns become a 3-by-3 matrix A and a length-3 vector \mathbf{b}.
Do not use this tool when you want exact symbolic answers. If you want factored form or a discriminant for a quadratic, the Quadratic solver gives exact roots. If you want to factor, expand or divide polynomials, use the Polynomial toolkit. For inequalities rather than equations, use the Inequality solver.
The solver returns floating-point numbers. A root that should be exactly 2 may appear as 1.9999999998, and a real root may carry a tiny imaginary part like 3 + 2e-16i. Treat values below about 1e-9 as zero.
How polynomial roots are found
Write a polynomial with its highest power first:
Here a_n is the leading coefficient, a_0 is the constant term, and n is the degree. The list 1, -6, 11, -6 means a_3 = 1, a_2 = -6, a_1 = 11, a_0 = -6.
The solver does not guess and factor. It builds the companion matrix of the polynomial, a square matrix whose characteristic polynomial equals p(x), then computes that matrix's eigenvalues. The eigenvalues are exactly the roots. This method is stable and works for any degree, unlike the quadratic formula which only covers degree 2.
Two facts help you sanity-check any result. The roots sum to -a_{n-1}/a_n, and they multiply to (-1)^n a_0/a_n. These are Vieta's formulas.
A worked polynomial example
Solving x^3 - 6x^2 + 11x - 6 = 0
This is the demo. Enter 1, -6, 11, -6 and press Calculate.
- Test small integers. At x = 1: 1 - 6 + 11 - 6 = 0. So
1is a root. - Divide out (x-1) to get x^2 - 5x + 6.
- Factor the quadratic: x^2 - 5x + 6 = (x-2)(x-3).
- Read the roots:
1, 2, 3.
Check with Vieta. Sum: 1 + 2 + 3 = 6 = -(-6)/1. Product: 1 \cdot 2 \cdot 3 = 6 = (-1)^3 \cdot (-6)/1. Both match.
How linear systems are solved
A linear system stacks equations into matrix form:
When A is square and invertible, there is exactly one solution, \mathbf{x} = A^{-1}\mathbf{b}. The solver does not literally invert the matrix, which is slow and inaccurate. It uses LU factorization, the same idea as Gaussian elimination.
When A is not square, or is square but singular, no single exact solution exists. The solver then returns the least squares solution: the vector \mathbf{x} that makes the residual \lVert A\mathbf{x} - \mathbf{b} \rVert as small as possible.
Here \lVert \cdot \rVert is the ordinary length of a vector. If the residual comes out near zero, the least squares answer is also an exact solution. If it is large, no combination of the columns of A reaches \mathbf{b}, and the answer is the closest possible fit.
To inspect why a system misbehaves, the Matrix calculator reports the rank and determinant, and the Matrix decompositions tool shows the LU, QR and SVD factorizations behind these methods.
A 2-by-2 system with one exact answer
Solve 2x + y = 5 and x - y = 1. Enter A = \begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix} and \mathbf{b} = \begin{bmatrix} 5 \\ 1 \end{bmatrix}.
- Add the two equations: 3x = 6, so x = 2.
- Back-substitute into x - y = 1: 2 - y = 1, so y = 1.
- Solution: \mathbf{x} = (2, 1). Residual is zero.
Reading and interpreting the output
In polynomial mode, each root prints as a real number or as a + bi. Complex roots of a real polynomial always come in conjugate pairs. For example x^2 + 1 returns 0 + 1i and 0 - 1i. A repeated root appears more than once: x^2 - 2x + 1 returns 1 and 1, because the double factor (x-1)^2 contributes a root of multiplicity 2.
In system mode, read the solution vector in variable order, so the first entry is your first unknown. When the system is over-determined, also look at the residual. A residual of 0.03 means the best fit misses the equations by that combined amount.
| Polynomial | Degree | Real roots | Complex roots |
|---|---|---|---|
| x - 4 | 1 | 1 | 0 |
| x^2 - 5x + 6 | 2 | 2 | 0 |
| x^2 + 1 | 2 | 0 | 2 |
| x^3 - 6x^2 + 11x - 6 | 3 | 3 | 0 |
| x^4 - 1 | 4 | 2 | 2 |
Explore how a coefficient moves the roots
Common mistakes
Omitting zero coefficients. The polynomial x^3 + 1 has coefficients 1, 0, 0, 1, not 1, 1. Every power from the highest down to the constant needs an entry, even when it is zero.
Reversing the coefficient order. Highest power comes first. Entering -6, 11, -6, 1 instead of 1, -6, 11, -6 describes a different polynomial and gives different roots.
Expecting exact fractions. A root like 1/3 shows as 0.3333333333. For an exact radical form such as \sqrt{2}, use the Radical simplifier, and for exact complex arithmetic use the Complex number calculator.
Mismatched dimensions in a system. If A has 3 rows, then \mathbf{b} must have 3 entries. A mismatch is not an error you can fix by padding with zeros; it changes the problem.
Related tools
Once you have roots, you may want to split a rational function using the Partial fraction decomposition tool. If the coefficients themselves come from a pattern, the Sequence calculator handles arithmetic and geometric terms. For equations built from exponentials or logarithms rather than powers, use the Exponent and logarithm calculator, and for geometry-flavored linear algebra the Vector calculator covers dot and cross products.
Frequently asked questions
Why did my real polynomial return complex roots?
Not every polynomial with real coefficients has real roots. x^2 + 1 has none: it never touches the x-axis. Its roots \pm i are genuinely complex, not a numerical error.
How many roots should I expect?
Exactly the degree, counted with multiplicity. A degree-4 polynomial always returns 4 values. If one looks missing, you probably have a repeated root printed twice or a coefficient entered wrong.
What does least squares mean when the system has no solution?
It returns the \mathbf{x} that comes closest to satisfying every equation at once, minimizing the total squared miss. When an exact solution exists, least squares finds it and the residual is zero.
Can I solve a system with more equations than unknowns?
Yes. With 5 equations and 2 unknowns the system is over-determined. The solver gives the least squares best fit and you should check the residual to judge how well it fits.
Does the order of my answers matter?
Polynomial roots are returned in no guaranteed order, so sort them yourself if you need to. System solutions follow the variable order of your columns in A.