Matrix Calculator
Add, subtract, multiply, transpose, invert, take the determinant, rank, trace or RREF of matrices up to 6 × 6 — or solve A · x = b. Enter your numbers or fractions and pick an operation; results are exact, with optional step-by-step working.
Add, Multiply, Transpose, Invert and Solve with Fractions
Matrix Formula
Where:
- \(a_{ij}\) — the entry of matrix \(A\) in row \(i\), column \(j\)
- \(b_{ij}\) — the entry of matrix \(B\) in row \(i\), column \(j\)
- \(k\) — a scalar (integer, decimal or fraction)
- \(n\) — the number of columns of \(A\); for the product \(A \times B\) it must equal the number of rows of \(B\)
- \(\operatorname{adj}(A)\) — the adjugate (transpose of the cofactor matrix) of \(A\)
Each entry of a sum, difference or scalar multiple is computed position by position. The matrix product is different: every entry is a dot product of a row of \(A\) with a column of \(B\). The inverse exists only when \(\det(A) \neq 0\).
Matrix – Calculation Example
Example: add the two default 3 × 3 matrices, \(A = \begin{bmatrix} 2 & 1 & 0 \\ 1 & 3 & 1 \\ 0 & 1 & 2 \end{bmatrix}\) and \(B = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}\).
\[ A + B = \begin{bmatrix} 2+1 & 1+2 & 0+3 \\ 1+4 & 3+5 & 1+6 \\ 0+7 & 1+8 & 2+9 \end{bmatrix} = \begin{bmatrix} 3 & 3 & 3 \\ 5 & 8 & 7 \\ 7 & 9 & 11 \end{bmatrix} \]
Result: each entry is the sum of the two entries in the same position, giving the 3 × 3 matrix shown above. Click Calculate with the default values to reproduce this exactly, including the decimal approximation and the copy buttons.
How to Use the Matrix Calculator
- Open the Operation dropdown and choose what you want: A + B (add), A − B (subtract), A × B (multiply), k · A (scalar multiple), Aᵀ (transpose), det(A) (determinant), A⁻¹ (inverse), rank(A), tr(A) (trace), A^n (power), RREF(A) (row reduce) or Solve A · x = b.
- Extra fields appear when needed: enter a number or fraction in Scalar (k) for a scalar multiple, an integer in Exponent (n) for a power, and tick Show steps to see the working for determinants and inverses.
- Set the size of matrix A with A rows and A cols — anything from 1 × 1 up to 6 × 6. Only the visible cells remain.
- Type the entries of A into the fields A₁₁, A₁₂, … Integers, decimals such as
1.5and fractions such as3/4are all accepted; empty cells count as 0. - For two-matrix operations, also fill in B rows, B cols and the B entries. For Solve A · x = b, the first column of B is used as the vector b.
- Click Calculate. The result appears in exact form, with a decimal approximation. Use the buttons under Export result / continue to copy it as text or LaTeX, or to load it back into matrix A for the next step.
What Is a Matrix and Why Do These Operations Matter?
A matrix is a rectangular array of numbers arranged in rows and columns. It is the standard way to compactly describe a system of linear equations, a transformation of space, a table of data or a set of network connections. Each entry \(a_{ij}\) sits at the crossing of row \(i\) and column \(j\), and the size of the matrix — rows first, then columns — determines which operations make sense.
The basic operations behave differently, and the difference matters. Addition and subtraction are entrywise: both matrices must have exactly the same size. Multiplication by a scalar stretches every entry by the same factor — our dedicated matrix scalar multiplication calculator covers just that case. Matrix multiplication is not entrywise: it combines rows with columns, which is why \(A \times B\) needs the columns of A to match the rows of B, and why \(A \times B\) is generally different from \(B \times A\).
Several operations work on a single square matrix. The determinant condenses a matrix into one number that measures how the matrix scales area or volume; a determinant of zero means the matrix has no inverse. The inverse \(A^{-1}\) undoes the action of \(A\), and is the key to solving \(A \cdot x = b\) as \(x = A^{-1} b\). The transpose flips a matrix across its diagonal — a quick job for the matrix transpose calculator — while the trace, the sum of the diagonal entries, is explained in the matrix trace calculator. The rank counts the genuinely independent rows and the RREF (reduced row echelon form) is the fully simplified version of a matrix, both useful for checking whether a system has one solution, many solutions or none.
To interpret the output: a matrix result is shown as a table in the same orientation as the operation implies; a scalar result (determinant, rank or trace) is shown as a single number; and the solver returns the vector \(x\) with each component labelled. Because all arithmetic is done with exact fractions, the exact result is always mathematically precise, while the decimal view is a rounded approximation.
Limitations and Practical Tips
- Size limit: matrices can be at most 6 × 6. Operations that only make sense for square matrices (determinant, inverse, trace, power, solving) require A rows = A cols and will show an error otherwise.
- Exact fractions: decimals such as
0.1are converted to exact fractions internally, so results like \(\tfrac{1}{3}\) appear without rounding error. Only integers, decimals and fractions are accepted — no variables, square roots or complex numbers. - Singular matrices: if det(A) = 0, the inverse and negative powers do not exist and the calculator will tell you. If a linear system is inconsistent or has infinitely many solutions, no unique solution vector can be returned.
- Exponent range: A^n accepts integer exponents from −100 to 100; negative powers require an invertible matrix.
- Chain operations: use the Use result as matrix A button to pipe an answer straight into the next calculation — for example multiply A × B, then take the determinant of the result.
- Check your work: for a computed inverse, verify that \(A \times A^{-1} = I\) by switching the operation to multiply and using Use result as matrix A.
Frequently Asked Questions
How do I multiply two matrices by hand?
For each entry of the result, take a row of the first matrix and a column of the second matrix and multiply them entry by entry, then add. Element \(c_{ij}\) of \(A \times B\) is \(c_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + \dots\). Work row by row: the 2 × 2 case is \(\begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}e&f\\g&h\end{bmatrix} = \begin{bmatrix}ae+bg & af+bh\\ce+dg & cf+dh\end{bmatrix}\). Remember the column count of A must equal the row count of B.
How do I find the determinant of a 2 × 2 or 3 × 3 matrix by hand?
For 2 × 2 use \(\det\begin{bmatrix}a&b\\c&d\end{bmatrix} = ad - bc\). For 3 × 3, expand along the first row with cofactors: \(\det(A) = a_{11}M_{11} - a_{12}M_{12} + a_{13}M_{13}\), where each \(M\) is a 2 × 2 minor. For larger matrices, reduce to upper triangular form with row operations — each row swap flips the sign — and multiply the pivots together. Tick Show steps in the calculator to see this working.
Why is A × B not always equal to B × A?
Matrix multiplication is not commutative. Each entry of \(A \times B\) combines rows of A with columns of B, so swapping the order changes which rows pair with which columns — and the sizes may not even match: if A is 2 × 3 and B is 3 × 2, then \(A \times B\) is 2 × 2 but \(B \times A\) is 3 × 3. Even for square matrices the results usually differ. Always check which order your problem requires.
How do I invert a 2 × 2 matrix by hand?
For \(A = \begin{bmatrix}a&b\\c&d\end{bmatrix}\), first compute \(\det(A) = ad - bc\). If it is zero, no inverse exists. Otherwise swap the diagonal entries, negate the off-diagonal entries, and divide everything by the determinant: \(A^{-1} = \frac{1}{ad-bc}\begin{bmatrix}d&-b\\-c&a\end{bmatrix}\). For bigger matrices, use Gauss–Jordan elimination on \([A \mid I]\) — the calculator shows each step when you tick Show steps.
What does it mean if the determinant is zero (a singular matrix)?
A zero determinant means the matrix squashes space onto a lower dimension: its rows (and columns) are linearly dependent, its rank is less than its size, and information is lost. Consequences: \(A^{-1}\) does not exist, cannot be solved uniquely — the system has either no solution or infinitely many. In practice, a singular matrix often signals duplicated or contradictory data, such as two identical rows or an equation that is a combination of the others.
How do I solve a system of linear equations with this calculator?
Write your system as \(A \cdot x = b\): put the coefficients into matrix A and the right-hand-side constants into the first column of B. Choose Solve A · x = b and the calculator returns the exact solution vector \(x\). For example, \(2x + y = 5\) and \(x - y = 1\) becomes \(A = \begin{bmatrix}2&1\\1&-1\end{bmatrix}\), \(b = \begin{bmatrix}5\\1\end{bmatrix}\). B must have exactly as many rows as A, and A must be square.
Why does the calculator show fractions like 10/3 instead of decimals like 3.33333?
All arithmetic is done with exact fractions, so answers such as \(\tfrac{10}{3}\) are mathematically precise — the decimal 3.33333 is only a rounded approximation. This avoids the rounding errors that plague plain decimal calculations, especially in long elimination chains. If you prefer decimals, check the Decimal approximation section of the result, where every exact value is also shown to 6 decimal places. You can enter inputs as integers, decimals or fractions (like 3/4) in any mix.