A matrix is a rectangular table of numbers, and it is the working tool of linear algebra: it encodes a system of linear equations, a geometric transformation or a network of relations in a compact form. This matrix calculator performs the operations you meet in a first course — determinant, inverse, transpose, rank, sum, difference, product and multiplication by a scalar — on matrices of up to 4 rows and 4 columns.
All arithmetic is exact. Entries may be integers, decimals or fractions, and the calculator works with fractions internally, so the inverse of an integer matrix comes out as clean fractions such as rather than 0.6000000001. A decimal version is shown next to it for convenience.
Each result comes with the method: the rule for a 2 × 2 determinant, cofactor expansion for a 3 × 3, Gaussian elimination for larger matrices, and the adjugate formula or Gauss–Jordan elimination for the inverse. Errors are explained in plain words: a singular matrix has no inverse, and a product needs matching inner dimensions.
How to use this calculator
- Choose the operation: determinant, inverse, transpose, rank, A + B, A − B, A × B or k × A.
- Type matrix A on one line. Separate the rows with a semicolon and the entries with spaces (or commas):
1 2; 3 4is the 2 × 2 matrix with rows (1, 2) and (3, 4). Brackets are optional. - Entries can be negative, decimal or fractional:
1/2 -3 0.25; 4 5 6. - For a sum, difference or product, type matrix B the same way; for k × A, type the scalar k.
- Read the result in exact form, its decimal form, and the table. The result line uses the same format as the input, so you can copy it back into A to chain operations.
The formula
For a 2 × 2 matrix, the determinant and the inverse are
For a 3 × 3 matrix, expand along the first row: .
In general the calculator uses Gaussian elimination: it reduces A to triangular form with row operations. The determinant is the product of the pivots, with a sign change for each row swap; the rank is the number of pivots; and the same elimination applied to (Gauss–Jordan) produces . A square matrix is invertible exactly when , that is when its rank equals its size.
The product is defined when A is and B is : . Sums and differences work entry by entry on matrices of the same size, and the transpose swaps rows and columns, .
Worked example
Inverse of a 2 × 2 matrix. For , , so
The top-left entry is 3/5 = 0.6. Multiplying gives the identity matrix.
Determinant of a 3 × 3 matrix. For the default matrix , cofactor expansion gives .
Order matters. With and , (columns swapped) but (rows swapped).
The determinant of a matrix: what it tells you
The determinant is a single number attached to a square matrix. Geometrically, its absolute value is the factor by which the matrix scales areas (in 2D) or volumes (in 3D), and its sign says whether the orientation is preserved. A determinant of 0 means the transformation flattens space onto a line or a plane: the matrix is singular, its rows are linearly dependent, and a linear system with that matrix has either no solution or infinitely many.
Useful properties: swapping two rows changes the sign; multiplying a row by multiplies the determinant by ; ; ; and .
Inverse of a matrix and linear systems
The inverse is the matrix that undoes A: . It exists only for square matrices with a non-zero determinant. Its main use is solving the system : when A is invertible, the unique solution is . In practice elimination is faster than computing the inverse, but for small systems and for exercises the inverse makes the structure clear.
Exact fractions matter here: the inverse of an integer matrix is times an integer matrix (the adjugate), so its entries are fractions with the determinant as common denominator, as in the fraction calculator.
Frequently asked questions
How do I enter a 3 × 3 matrix?
Type the three rows separated by semicolons, with spaces between the entries: 2 -3 1; 2 0 -1; 1 4 5. Commas between entries also work, and so do fractions like 1/3 and decimals like 0.5.
Why does my matrix have no inverse?
A matrix is invertible only if it is square and its determinant is not zero. A zero determinant means one row is a combination of the others (for example, a row that is twice another), so information is lost and cannot be recovered.
Can I multiply a 2 × 3 matrix by a 3 × 2 matrix?
Yes. The number of columns of A (3) matches the number of rows of B (3), and the result is 2 × 2. In the other order, B × A is also defined but gives a 3 × 3 matrix — another reason why A × B ≠ B × A.
What is the rank of a matrix?
The rank is the number of linearly independent rows (equivalently, columns). It equals the number of pivots after Gaussian elimination. A square n × n matrix is invertible exactly when its rank is n.
Why are some results shown as fractions?
The calculator uses exact rational arithmetic, so no rounding error builds up. An entry such as 1/3 would otherwise appear as 0.3333333333. The decimal form is shown underneath when it differs.
Sources
- Strang, G. — Introduction to Linear Algebra, 6th ed., Wellesley-Cambridge Press (2023)
- OpenStax, Precalculus 2e — §9.5 Matrices and Matrix Operations
- OpenStax, Precalculus 2e — §9.7 Solving Systems with Inverses
- Weisstein, Determinant — Wolfram MathWorld
Last updated: