About the Matrix Calculator
Linear algebra homework, computer graphics and engineering problems involve matrices that are tedious to work through by hand. This matrix calculator adds, subtracts and multiplies matrices up to six by six and finds the determinant, inverse, transpose, rank, trace, powers and reduced row echelon form, all in exact fractions, so the inverse of the matrix with rows (2, 1) and (5, 3) has whole-number entries, because its determinant is 1.
All arithmetic is exact. Entries can be whole numbers, decimals such as 0.25 or fractions such as 2/3, and the calculator works in fractions throughout, so the inverse of a matrix comes out as clean values like 3/2 instead of 1.4999999. Switch the result to decimals with one click when you need them, rounded to six places. Cells that cannot be read as numbers are outlined in red so you can fix them.
Matrix multiplication needs the number of columns of the first matrix to equal the number of rows of the second, and the result has the rows of the first and the columns of the second. The determinant, inverse, trace and powers need a square matrix, and only matrices with a non-zero determinant have an inverse. When an operation is not possible, the calculator says why instead of showing an error code. Send any result back into A or B to chain several steps together.
For the systems of equations that matrices often represent, try the system of equations solver. To check a single fraction by hand, use the fraction calculator, and for powers, roots and logarithms, the scientific calculator.
How to use the Matrix Calculator
- Set the sizesChoose the number of rows and columns for matrices A and B.
- Enter the valuesType whole numbers, decimals or fractions such as 2/3 in the cells.
- Pick an operationCombine A and B, or choose A or B for a single-matrix operation.
- Read and reuseSwitch between fractions and decimals, copy the result or send it to A or B.
Matrix Calculator features
- A + B, A − B, A × B and B × A
- Determinant, inverse, transpose and trace
- Rank and reduced row echelon form
- Whole-number powers, including negative
- Scalar multiplication
- Exact fractions, or decimals to 6 places
- Matrices up to 6×6
- Results can be sent back to A or B
Common uses
- Checking linear algebra homework
- Inverting a matrix to solve a system of equations
- Multiplying transformation matrices
- Finding the rank of a set of vectors
- Computing Markov chain steps with matrix powers
Matrices in practice: graphics, systems, Markov chains and search engines
A matrix is a rectangular grid of numbers, and matrix operations are the language of computer graphics, data science, engineering and economics. Multiplying, inverting and finding determinants of matrices solves systems of equations, rotates images, predicts long-run behaviour and even ranks web pages. This guide explains those applications with small worked examples and the rules that most often trip up learners.
Dimensions and multiplication
Two matrices can be multiplied only when the number of columns in the first equals the number of rows in the second: a 2 × 3 matrix times a 3 × 4 matrix gives a 2 × 4 result. Each entry of the result combines a row of the first matrix with a column of the second. Matrix multiplication is generally not commutative: AB and BA can be different, or one may not even exist.
Rotating points in graphics
Computer graphics move, rotate and scale shapes with matrices. A rotation by 90 degrees anticlockwise uses the matrix with rows (0, −1) and (1, 0). Multiplying it by the point (1, 0) gives (0, 1): the point on the x-axis has moved to the y-axis. Games and design software combine rotation, scaling and translation matrices to transform thousands of points every frame.
Solving systems of equations
A system of linear equations can be written as a matrix equation, Ax = b, where A holds the coefficients. If A has an inverse, the solution is x = A⁻¹b. If its determinant is zero, there is no unique solution: the equations are either contradictory or dependent. Engineers solve systems with thousands of unknowns this way, using efficient computer methods based on the same algebra.
A worked example: weather as a Markov chain
Suppose that in a city, a sunny day is followed by another sunny day 80% of the time and by a rainy day 20% of the time, while a rainy day is followed by sun 40% of the time and rain 60% of the time. These probabilities form a transition matrix. Multiplying it by itself gives the probabilities two days ahead, and repeated multiplication shows the long-run pattern.
In the long run, the city is sunny two thirds of the time and rainy one third, whatever the starting weather. This kind of model, a Markov chain, is used for weather, customer behaviour, inventory and text prediction.
Ranking web pages
Early versions of Google's search ranking, PageRank, treated the web as a huge matrix of links. A page's importance depended on the importance of the pages linking to it, and the ranking came from a special vector of that matrix, found by repeated multiplication. The idea showed how matrix mathematics could organise information at enormous scale.
Images as matrices
A greyscale digital image is a matrix of brightness values, and a colour image is three matrices, one for each colour channel. Blurring, sharpening and edge detection apply small matrices, called kernels, across the image. Photo filters and many image recognition systems are built on these operations.
Economics and encryption
Economists use input-output matrices to model how industries depend on one another, an approach developed by Wassily Leontief, who received the Nobel Prize in Economics in 1973. In cryptography, the classic Hill cipher encrypts groups of letters by multiplying them by a matrix, and decrypts them with its inverse. Modern encryption is far more complex, but matrices remain central to many algorithms.
Determinants as scale factors
The determinant of a 2 × 2 matrix tells you how the matrix scales areas: a determinant of 3 triples every area, and a negative determinant also flips orientation. A determinant of zero squashes shapes flat, which is exactly why such matrices have no inverse.
Common mistakes
- Multiplying matrices with incompatible dimensions.
- Assuming AB equals BA.
- Trying to invert a matrix with a zero determinant.
- Multiplying entries position by position instead of rows by columns.
Related tools
For systems of equations, use System of Equations Solver. For probabilities, try Probability Calculator, and for vectors and points, Distance Formula Calculator.
Undoing a transformation
The inverse of a matrix undoes what the matrix does. If a matrix rotates shapes by 30 degrees, its inverse rotates them back by 30 degrees; if it scales by 2, its inverse scales by a half. Graphics programs use inverses to convert a mouse click on screen back into coordinates in a scene, which is how you can select an object even after the view has been rotated and zoomed.
Matrices and artificial intelligence
Modern machine learning systems are built on enormous numbers of matrix multiplications. A neural network stores its learned knowledge as matrices of weights and processes data by multiplying it through those matrices layer by layer. Graphics processors are designed to perform matrix multiplication extremely quickly, which is why they are used to train and run such systems.
Limits
Calculations are exact with fractions up to the supported matrix size; very large or ill-conditioned matrices may show rounding in decimal mode.
Frequently asked questions
How do I multiply two matrices?
Enter A and B and press A × B. Each entry of the result is the sum of the products of a row of A with a column of B, so the number of columns of A must equal the number of rows of B. Matrix multiplication is not commutative, which is why B × A has its own button.
Why does my matrix have no inverse?
A matrix has an inverse only if it is square and its determinant is not zero. A zero determinant means the rows are linearly dependent, for example one row is a multiple of another, so the matrix squashes space into fewer dimensions and cannot be undone.
Can I enter fractions?
Yes. Type fractions such as 3/4 or -5/2, decimals such as 0.125, or whole numbers. The calculator converts everything to exact fractions, so results have no rounding errors, and you can switch the display to decimals rounded to six places.
What is RREF?
The reduced row echelon form is what you get after Gauss-Jordan elimination: every leading entry is 1, it is the only non-zero number in its column, and rows of zeros sit at the bottom. It shows the rank of the matrix and the solutions of the linear system it describes.
How is the determinant calculated?
By Gaussian elimination in exact fractions: the matrix is reduced to triangular form, and the determinant is the product of the pivots, with the sign changed once for every row swap. This is much faster than cofactor expansion and gives the exact value.
What does a negative power mean?
A to the power −n is the inverse of A raised to the power n. It exists only if A is invertible. A to the power 0 is the identity matrix, and positive powers are calculated by repeated squaring, which stays fast even for powers up to 50.
Are my matrices saved or sent anywhere?
No. All calculations happen in your browser and nothing is uploaded. Copy a result as tab-separated text to paste it into a spreadsheet, or send it back into A or B to continue working with it.