Matrix Calculator
ÚjAdd, subtract, multiply matrices and compute determinant, inverse and transpose for 2×2–4×4 matrices.
Operations
Runs entirely in your browser. Nothing is uploaded.
What is a matrix calculator?
A matrix calculator is an online tool that performs linear algebra operations on rectangular arrays of numbers. Common operations include addition, subtraction, multiplication, scalar multiplication, transpose, determinant, inverse, and row reduction to reduced row echelon form (RREF). These operations are central to linear algebra, which is foundational to machine learning, computer graphics, structural engineering, economics, and most quantitative science.
This free matrix calculator supports matrices up to 4×4 and performs eight distinct operations: A+B, A−B, A×B, k·A, Aᵀ, det(A), A⁻¹, and RREF(A). For determinant and inverse calculations, step-by-step working is displayed — showing cofactor expansion for the determinant and the adjugate method for the inverse. RREF shows each row operation (swap, scale, eliminate) in sequence, making it useful for checking homework and understanding Gaussian elimination.
How to use the matrix calculator
Set the dimensions of Matrix A and Matrix B using the row and column dropdowns (1 to 4 for each dimension). Click any cell in the grid to enter a value — Tab moves to the next cell horizontally, making data entry fast on keyboard. Decimal values and negative numbers are fully supported; leave cells at 0 if not needed. For operations requiring only one matrix (transpose, determinant, inverse, RREF), only Matrix A needs values. For binary operations (A+B, A−B, A×B), both matrices must have compatible dimensions.
Click the operation button to compute and view the result grid below. To solve a system of linear equations, create an augmented matrix [A|b] by setting Matrix A to have one extra column for the constants, then run RREF(A). The solution reads directly from the rightmost column of the result.
Matrix operations, determinants, and inverses explained
Addition and subtraction are elementwise operations requiring identical dimensions. Multiplication A×B requires A's column count to equal B's row count; the result has A's row count and B's column count. The (i,j) element of the product is the dot product of row i from A and column j from B. Scalar multiplication kA multiplies every element by k. Transpose Aᵀ mirrors the matrix over its main diagonal, turning an m×n matrix into n×m.
The determinant encodes whether a matrix is invertible (det ≠ 0) and by what factor it scales areas or volumes. The inverse A⁻¹ 'undoes' A: multiplying A by A⁻¹ returns the identity matrix. For practical equation-solving, RREF applied to the augmented matrix [A|b] is numerically more stable than computing A⁻¹ and multiplying — it simultaneously reveals consistency, uniqueness, and the solution values. The rank of A (the number of non-zero rows in RREF) determines which of the three solution types (unique, infinite, none) applies.
Why step-by-step working matters
Most online matrix calculators show the answer but not how they got there. This one shows every intermediate step for the three operations students most need to understand: cofactor expansion for determinants, the adjugate method for matrix inverses, and individual row operations (scale, swap, eliminate) for RREF. That step-by-step output is what makes the tool useful for homework checking rather than just answer-grabbing.
The RREF implementation uses partial pivoting — swapping to the largest absolute-value element in each column before dividing — which improves numerical stability and avoids the floating-point division errors that appear in naive implementations. Values below 1e-10 are set to exact zero, so results stay clean even for ill-conditioned inputs where a simpler algorithm would show 0.0000000001 instead of 0.
How it compares to Wolfram Alpha, Symbolab, and Mathway
Wolfram Alpha is the most powerful alternative but caps free matrix queries and hides step-by-step working behind a $7/month Pro subscription. Symbolab and Mathway require an account sign-up and limit daily free step-by-step calculations to roughly 5–10 per day. Desmos handles graphing well but does not support matrix operations. This calculator is different: no account, no daily limit, and no paywall. Every operation — including full working for determinants, inverses, and RREF — is free on every use.
It also runs entirely in your browser. Your matrix entries never leave your device. That matters when you're working on homework problems or proprietary engineering data that shouldn't be sent to a third-party server. Close the tab and the data is gone.
Matrix multiplication explained: the dot product rule and non-commutativity
Matrix multiplication is not elementwise — you cannot simply multiply matching positions as you do with addition. The product C = A×B is defined only when A has dimensions m×n and B has dimensions n×p; the shared dimension n must match. The result C is m×p. Each entry C(i,j) is computed as the dot product of row i of A with column j of B: C(i,j) = A(i,1)·B(1,j) + A(i,2)·B(2,j) + … + A(i,n)·B(n,j). For a concrete 2×2 example with A = [[1,2],[3,4]] and B = [[5,6],[7,8]]: C(1,1) = 1·5 + 2·7 = 19, C(1,2) = 1·6 + 2·8 = 22, C(2,1) = 3·5 + 4·7 = 43, C(2,2) = 3·6 + 4·8 = 50, giving C = [[19,22],[43,50]].
A critical property of matrix multiplication is non-commutativity: AB ≠ BA in general. Even when both products are defined (i.e., A and B are both square), reversing the order almost always changes the result. Geometrically, if A and B represent linear transformations such as rotations and scalings, AB applies B first then A, while BA applies A first then B — different sequences produce different outcomes, just as rotating then scaling a shape is not the same as scaling then rotating it.
The computational cost of matrix multiplication also deserves attention. The naive algorithm requires O(n³) arithmetic operations to multiply two n×n matrices — doubling the size multiplies the work eightfold. For large matrices (n in the thousands, as encountered in deep learning and scientific computing), this is prohibitive. Strassen's algorithm reduces the complexity to approximately O(n^2.807) by cleverly reducing the number of scalar multiplications from 8 to 7 per 2×2 block. More recent algorithms push the exponent further toward O(n^2.37), and practical libraries like BLAS and LAPACK implement highly optimized blocked variants that exploit CPU cache architecture, making large matrix products feasible in neural network training.
The determinant: geometric meaning and the singular matrix
The determinant is a single scalar that encodes fundamental structural information about a square matrix. For a 2×2 matrix A = [[a,b],[c,d]], det(A) = ad − bc. For a 3×3 matrix, cofactor expansion along the first row gives det(A) = a(ei − fh) − b(di − fg) + c(dh − eg), where the letters label the nine entries in reading order. The alternating signs follow the checkerboard pattern + − + / − + − / + − + for 3×3, and the same principle extends recursively to any size.
Geometrically, the absolute value of the determinant measures how much the linear transformation represented by the matrix scales areas (in 2D) or volumes (in 3D). A 2×2 matrix with |det| = 3 stretches parallelograms by a factor of 3. The sign indicates orientation: a positive determinant preserves the handedness of coordinate axes (no reflection), while a negative determinant includes a reflection. A determinant of exactly 1 means the transformation preserves area or volume perfectly — orthogonal matrices (pure rotations and reflections) always satisfy |det| = 1.
When det(A) = 0, the matrix is called singular. Geometrically, a singular transformation collapses space: a 2D transformation with zero determinant maps the entire plane onto a line (or a point), destroying information irreversibly. Algebraically, this means the rows (or columns) of the matrix are linearly dependent — at least one row can be expressed as a combination of the others. A singular matrix has no inverse, and any system Ax = b with a singular A either has no solution or infinitely many, never a unique one. Checking det(A) before attempting inversion is therefore always the first diagnostic step.
Matrix inverse and solving linear systems
The inverse of a square matrix A, written A⁻¹, is the unique matrix satisfying A·A⁻¹ = A⁻¹·A = I (the identity). It exists if and only if det(A) ≠ 0. For a 2×2 matrix A = [[a,b],[c,d]], the closed-form inverse is A⁻¹ = (1/(ad−bc)) × [[d,−b],[−c,a]] — swap the main diagonal, negate the off-diagonal, divide by the determinant. For larger matrices, the general formula is A⁻¹ = (1/det(A)) × adj(A), where adj(A) (the adjugate) is the transpose of the cofactor matrix. Each cofactor C(i,j) = (−1)^(i+j) × det(M(i,j)), where M(i,j) is the submatrix formed by deleting row i and column j from A.
The most important application of the inverse is solving systems of linear equations. A system of n equations in n unknowns can be written as Ax = b, where A is the coefficient matrix, x is the column vector of unknowns, and b is the column vector of constants. If A is invertible, the unique solution is x = A⁻¹b — left-multiply both sides by A⁻¹. This is conceptually clean but computationally wasteful for large systems. Gaussian elimination (equivalently, RREF on the augmented matrix [A|b]) finds the same solution in roughly a third of the arithmetic operations and is numerically more stable.
Numerical stability is a serious concern for matrix inversion. An ill-conditioned matrix — one whose determinant is close to zero but not exactly zero — amplifies rounding errors enormously during inversion. The condition number of a matrix (the ratio of its largest to smallest singular value) quantifies this sensitivity: a condition number of 10⁶ means that six decimal digits of precision in the input can be completely lost in the output. Professional numerical libraries therefore avoid explicit inversion and instead prefer LU decomposition, which factors A into a lower triangular matrix L and an upper triangular matrix U (A = LU), then solves Ly = b and Ux = y with two fast triangular solves. This approach is both faster and far more numerically robust than computing A⁻¹ directly.
Eigenvalues, eigenvectors, and their applications
An eigenvector of a square matrix A is a non-zero vector v that satisfies Av = λv, where λ is the corresponding eigenvalue. In plain terms: when A acts on v as a linear transformation, it only scales v by the factor λ — it does not rotate v out of its original direction. Every direction that a matrix leaves unchanged (up to scaling) corresponds to an eigenvector, and the amount of scaling in that direction is the eigenvalue. This makes eigenvectors the 'natural axes' of a linear transformation.
To find eigenvalues, rearrange Av = λv as (A − λI)v = 0. This homogeneous system has a non-zero solution only when A − λI is singular, i.e., when det(A − λI) = 0. Expanding that determinant yields the characteristic polynomial — a degree-n polynomial in λ whose roots are the eigenvalues. For a 2×2 matrix [[a,b],[c,d]] the characteristic polynomial is λ² − (a+d)λ + (ad−bc) = 0, revealing that the sum of eigenvalues equals the trace (a+d) and their product equals the determinant (ad−bc). Once each eigenvalue is known, substituting back into (A − λI)v = 0 and solving for v gives the corresponding eigenvectors.
Eigenvalues and eigenvectors are not merely theoretical — they power some of the most impactful algorithms in computing. Google's PageRank algorithm ranks web pages by finding the dominant eigenvector of the link transition matrix: the eigenvector associated with eigenvalue 1 gives the long-run probability of landing on each page during a random walk through the web. In machine learning, Principal Component Analysis (PCA) finds the directions of maximum variance in a dataset by computing the eigenvectors of the data's covariance matrix; the eigenvalues measure how much variance each direction captures, allowing high-dimensional data to be compressed by retaining only the top eigenvectors. In structural engineering, eigenvalues of the stiffness matrix correspond to the natural vibration frequencies of a structure, which must be computed to ensure a bridge or building won't resonate catastrophically under external loading.
Frequently asked questions
What is matrix multiplication and when can I perform it?
Matrix multiplication A × B is defined only when the number of columns in A equals the number of rows in B. If A is m×n and B is n×p, the result C is m×p. Each element C(i,j) is the dot product of row i of A with column j of B: C(i,j) = Σₖ A(i,k) × B(k,j). Note that matrix multiplication is generally not commutative — A×B and B×A are different results, and B×A may not even be defined if the dimensions don't align in that order.
How is the determinant of a matrix calculated?
For a 2×2 matrix [[a,b],[c,d]], det = ad − bc. For a 3×3 or 4×4 matrix, the calculator uses cofactor expansion along the first row: det(A) = Σⱼ A(1,j) × (−1)^(1+j) × det(Mⱼ), where Mⱼ is the minor (the submatrix with row 1 and column j removed). The determinant equals zero if and only if the matrix is singular (not invertible). Step-by-step working is shown for all determinant calculations.
When does a matrix have an inverse?
An inverse exists if and only if the matrix is square (n×n) and has a non-zero determinant. The inverse A⁻¹ satisfies A × A⁻¹ = A⁻¹ × A = I (the identity matrix). If det(A) = 0, the matrix is called singular and no inverse exists — the calculator checks the determinant before attempting inversion and reports a clear error for singular matrices. Non-square matrices never have inverses.
What is RREF (Row Reduced Echelon Form)?
RREF transforms a matrix into a canonical form where: (1) the first non-zero element of each non-zero row (the pivot) is 1, (2) each pivot is strictly to the right of the pivot in the row above, (3) every element above and below a pivot is 0, and (4) all-zero rows are at the bottom. RREF is used to solve systems of linear equations, find the matrix rank, determine solution consistency, and compute null spaces. Each matrix has a unique RREF.
How do I use matrix operations to solve a linear system?
Write the system Ax = b where A is the coefficient matrix and b is the constants column. Create the augmented matrix [A | b] by appending b as an extra column to A, then compute RREF. If RREF shows a contradiction row (0…0 | nonzero), the system is inconsistent (no solution). If the last row is all zeros, infinitely many solutions exist. Otherwise, the unique solution is read directly from the right column of the RREF result.
What is the transpose of a matrix?
The transpose Aᵀ is formed by reflecting the matrix over its main diagonal — element (i,j) of A becomes element (j,i) of Aᵀ. An m×n matrix transposes to an n×m matrix. Key properties: (AB)ᵀ = BᵀAᵀ, (Aᵀ)ᵀ = A, and det(Aᵀ) = det(A). Symmetric matrices satisfy A = Aᵀ. The transpose is used in computing the adjugate matrix (which appears in the inverse formula) and in forming AᵀA, which is always square and symmetric.
What does scalar multiplication do to a matrix?
Scalar multiplication kA multiplies every element of matrix A by the scalar constant k, producing a matrix of the same dimensions. The determinant scales by kⁿ (where n is the matrix dimension): det(kA) = kⁿ det(A). Geometrically, if A represents a linear transformation, kA scales the transformation by k — expanding it if |k| > 1, shrinking it if |k| < 1, and reflecting it if k is negative.
What is the identity matrix?
The n×n identity matrix Iₙ has ones on the main diagonal and zeros everywhere else. It is the multiplicative identity for square matrices: A × I = I × A = A for any n×n matrix A. The identity has determinant 1, all eigenvalues equal to 1, and represents the 'do nothing' linear transformation. A matrix multiplied by its inverse always produces the identity: A × A⁻¹ = I. The identity is also the result of RREF applied to any full-rank square matrix.
What does the matrix rank tell me?
The rank of a matrix is the number of linearly independent rows (or columns), which equals the number of non-zero rows in its RREF. For an n×n matrix, rank = n means the matrix is full-rank (invertible, non-singular, det ≠ 0). For an m×n system Ax = b, the rank determines the solution: if rank(A) = rank([A|b]) = n there is a unique solution; if rank(A) = rank([A|b]) < n there are infinitely many solutions; if rank(A) < rank([A|b]) there is no solution.
How is the inverse of a 2×2 matrix computed?
For a 2×2 matrix A = [[a,b],[c,d]] with det = ad − bc ≠ 0, the inverse is: A⁻¹ = (1/(ad−bc)) × [[d, −b],[−c, a]]. This is the adjugate (swap the diagonal, negate the off-diagonal) divided by the determinant. For 3×3 and 4×4 matrices, the inverse is (1/det(A)) × adj(A), where adj(A) is the transpose of the cofactor matrix — a process our calculator performs with full step-by-step working shown.
What is the cofactor expansion method?
Cofactor expansion (Laplace expansion) expresses the determinant of an n×n matrix as a signed sum of n smaller (n−1)×(n−1) determinants. Expanding along row i: det(A) = Σⱼ A(i,j) × Cᵢⱼ, where the cofactor Cᵢⱼ = (−1)^(i+j) × det(Mᵢⱼ) and Mᵢⱼ is the minor (A with row i and column j deleted). The sign pattern alternates: + − + / − + − / + − + for a 3×3. Expanding along a row with zeros reduces computation significantly.
Why does matrix multiplication order matter?
Unlike scalar multiplication, matrix multiplication is not commutative: AB ≠ BA in general. Geometrically, if A and B each represent a linear transformation (rotation, scaling, shear), AB applies B first then A, while BA applies A first then B — producing different final positions. This non-commutativity is fundamental to linear algebra and explains why the order of matrix operations in equations must be handled with care, and why 'left-multiply' and 'right-multiply' are distinct operations.
What sizes of matrices does the calculator support?
The calculator supports matrices from 1×1 up to 4×4 for both Matrix A and Matrix B, adjustable via the row and column dropdowns. Each matrix cell accepts any real number including decimals and negative values. Operations requiring compatible dimensions (addition, subtraction, multiplication) display a clear error if the dimensions don't match, explaining exactly what is required. The RREF operation supports non-square matrices up to 4×4, useful for augmented matrices when solving systems of equations.
How do I solve a 3×3 system of linear equations with this calculator?
Set up your 3×3 coefficient matrix as Matrix A and set the dimensions to 3 rows × 4 columns to include the constants as a 4th column (the augmented matrix). Enter the coefficients and constants, then click RREF(A). Read the solution from the final column of the RREF result — the values in rows 1, 2, 3 of the last column are the values of x, y, z respectively. If a pivot is missing in any row, the system has infinitely many solutions or no solution.
How does this compare to Wolfram Alpha, Symbolab, or Mathway for matrix calculations?
Wolfram Alpha handles matrix operations but throttles free users to a handful of queries per day before hitting a paywall. Symbolab and Mathway both require account sign-ups to view step-by-step solutions and cap daily free calculations. This calculator has no account, no query limits, and no paywall — every operation including full step-by-step working for determinants, inverses, and RREF is free on every calculation. It also runs entirely client-side, so your matrix data is never sent to a server.
Can I use this matrix calculator on my phone?
Yes. The calculator is fully responsive and works on iPhone Safari, Android Chrome, and tablet browsers. The grid input cells resize for touch, and the Tab key on a Bluetooth keyboard or the mobile keyboard's next-field button moves between cells efficiently. All eight operations — addition, subtraction, multiplication, scalar, transpose, determinant, inverse, and RREF — are available on any screen size without installing an app.
Related tools
Összes eszköz megtekintéseJSON ⇄ CSV átalakító
Alakíts át JSON tömböt CSV-vé és CSV-t vissza JSON-ba, megfelelő idézéssel.
XML formázó
Szépítsd, tömörítsd és ellenőrizd az XML-t közvetlenül a böngésződben.
SQL formázó
Szépítsd és tömörítsd az SQL lekérdezéseket kulcsszó-kiemelésssel és záradék-törésekkel.
JSON TypeScriptté alakítás
Generálj TypeScript interfészeket egy JSON mintából, egymásba ágyazott típusokkal.
CSV néző
Nézd meg, rendezd és keresd CSV vagy TSV fájlokban az adatokat tiszta táblázatként — a böngésződben.
Statistics Calculator
Calculate mean, median, mode, standard deviation, variance and more from a data set.