Matrix Calculator with Gaussian Elimination Steps
Matrix multiply, invert, and solve linear systems with visible Gaussian-elimination pivot steps.
Five of this calculator's operations — multiplication, determinant, inverse, trace, and eigenvalues with eigenvectors — are delegated to mathjs, a well-tested numerical library. Addition, transpose, rank and linear-system solving are written by hand, and the solver in particular uses its own Gaussian elimination so every pivot choice, row swap and elimination multiplier can be shown as a worked step rather than a single opaque answer.
Matrix operations this calculator supports
- A × B and A + B, each refusing mismatched shapes with a message that names both sizes.
- Aᵀ (transpose) and rank(A) for any rectangular matrix.
- det(A), A⁻¹, tr(A) and eigenvalues with eigenvectors, which require a square matrix.
- Solving Ax = b for a square system, reported as a unique solution, infinitely many solutions or no solution, with the elimination log available underneath.
- Matrix sizes from 1×1 to 10×10 in either mode, chosen from the row and column dropdowns.
How to multiply, invert or row-reduce a matrix
- Choose Matrix operations for work on A and B, or Solve a linear system for Ax = b.
- Set the rows and columns of each matrix with the dropdowns; resizing keeps the entries that still fit.
- Type a number into each cell — decimals, negatives and scientific notation such as 1e-3 are accepted.
- Pick the operation (A × B, A + B, Aᵀ, det(A), A⁻¹, rank(A), tr(A) or Eigenvalues) and read the result, which is rounded to six decimal places for display.
- For a system, open Show elimination steps to follow each row swap and multiplier; operations-mode matrices are also kept in the page URL so the link reproduces them.
What's computed where
Every operation first checks that its inputs are rectangular — every row the same length — and dimensionally compatible before doing any arithmetic, so a mismatched multiply reports a clear reason instead of a cryptic index error. Addition and transpose are simple enough to write directly against the input arrays. Multiplication, determinant, inverse, trace and full eigendecomposition call into mathjs's own numerical routines, a deliberate choice since stable versions of those algorithms are genuinely tricky and mathjs already has extensive test coverage for them. Rank has no mathjs routine, so it is read off the same hand-written elimination the solver uses: the number of pivot columns is the rank.
Eigenvalues that come out complex are handled explicitly rather than crashing — mathjs represents them at runtime as {re, im} pairs even though its own type declarations suggest otherwise, and this tool's code checks for that shape directly so a matrix with genuinely complex eigenvalues (a rotation matrix, for instance) displays the real and imaginary part of each eigenvalue instead of throwing. The eigenvector readout is more limited: it lists only the real part of each vector component, so for a complex pair the vectors shown are incomplete.
Gaussian elimination with every pivot shown
Solving Ax = b runs forward elimination on the augmented matrix using partial pivoting — at each column, the row with the largest-magnitude entry is swapped to the pivot position before elimination proceeds, which is the standard technique for keeping the arithmetic numerically stable rather than dividing by a tiny or zero pivot. Every row swap and every elimination multiplier used to zero out entries below the pivot is recorded as a discrete step, along with the resulting echelon form and which columns ended up as pivot columns.
That step record is what makes this different from asking mathjs for a solve: you can watch the augmented matrix change one operation at a time, see exactly which row was swapped and why, and check the elimination multiplier used at each stage against your own hand calculation. Values under 1e-10 in magnitude are treated as effectively zero throughout, which is what lets the pivoting logic and the rank calculation distinguish a genuinely singular system from one that's merely close to it in floating point.
Where this stops being useful
- Every computation here runs in standard double-precision floating point, not exact rational or arbitrary-precision arithmetic — a determinant or inverse on a large, poorly conditioned matrix can accumulate visible rounding error, the same way it would in any numerical linear algebra package.
- The system solver only builds square n×n systems. A singular one is still classified — as having infinitely many solutions (with the rank shown) or none at all when a row reduces to 0 = nonzero — but there is no least-squares or pseudo-inverse fallback for overdetermined data.
- Symbolic matrices — entries with unknown variables instead of numbers — aren't supported at all; every entry has to be a concrete number before any operation runs.
Matrix examples to check against your homework
- 2×2 inverse: [[4, 7], [2, 6]] has determinant 10 and inverse [[0.6, −0.7], [−0.2, 0.4]].
- 3×3 determinant and inverse: [[1, 2, 3], [0, 1, 4], [5, 6, 0]] has determinant 1, so its inverse is all integers: [[−24, 18, 5], [20, −15, −4], [−5, 4, 1]].
- System with row swaps: x + 2y + z = 8, 3x + y + 2z = 12, 2x + 3y + 4z = 18 swaps rows twice under partial pivoting and solves to x = y = z = 2.
- The solve panel's starting system, 2x + y + z = 7, x + 3y + 2z = 13, x = 1, solves to x = 1, y = 2, z = 3.
- Complex eigenvalues: the rotation [[0, −1], [1, 0]] returns λ = 0 ± 1i.
- Rank of a rectangular matrix: [[1, 2], [2, 4], [3, 6]] has rank 1, since every row is a multiple of the first.
Questions people ask about Matrix & Linear Algebra Solver
- Why does the calculator show row swaps during Gaussian elimination when my textbook's example didn't need any?
- The elimination uses partial pivoting, meaning it always swaps the largest-magnitude available entry into the pivot position at each column, even when the original entry there was already nonzero. This is standard numerical practice because it keeps rounding error from growing during elimination, and it's how most real solvers behave, even though a hand-worked textbook example often skips it for simplicity.
- Can this calculator handle matrices with complex eigenvalues?
- Partly. A matrix like a 2D rotation has eigenvalues with nonzero imaginary parts, and the eigen readout shows each eigenvalue as a real part plus or minus an imaginary part instead of failing. Eigenvectors, however, are displayed with only the real part of each entry, so for complex eigenvalues treat the vector column as incomplete and compute those vectors elsewhere.
- What counts as a singular matrix here, given floating-point rounding?
- Any value with magnitude below one ten-billionth (1e-10) is treated as effectively zero throughout the calculator's pivoting and rank logic, rather than only exact zero. That threshold is what separates a matrix that's mathematically singular from one that merely has a very small determinant due to accumulated floating-point rounding during the computation.
- Does the calculator solve systems with more equations than unknowns?
- No — the solve panel always sets up n equations in n unknowns, with n from 1 to 10. Overdetermined or underdetermined systems cannot be entered at all, and there is no least-squares fit, so a rectangular problem needs a different method or software such as a statistics package.
- What is the largest matrix size supported?
- Ten rows by ten columns, for both the A and B matrices and for the linear-system solver. Sizes are chosen from dropdowns running from 1 to 10, and matrices close to the maximum may also be too large to encode into a shareable link.
- Can I enter fractions or get exact fractional answers?
- No. The cells are numeric fields, so a value such as 1/3 has to be typed as a decimal like 0.333333, and every result is computed in floating point and shown rounded to six decimal places rather than as an exact fraction.
- Can it handle non-square matrices?
- Yes for multiplication with compatible shapes, addition of equal shapes, transpose and rank. Determinant, inverse, trace and eigenvalues are only defined for square matrices, so for those the tool reports the actual dimensions and explains why the operation cannot run.
Related tools on BrakeTools
- Step-by-Step Symbolic Calculus Solver — See full step-by-step derivatives, integrals, and limits rendered in proper math notation.
- Universal Multi-Variable Formula Solver — Type any formula, leave one variable blank, and solve it numerically via Newton-Raphson.
- Interactive 2D/3D Graphing Calculator — Graph Cartesian, polar, parametric, and implicit curves with live sliders, roots, and tangents.
Content reviewed 2026-09-27.