Matrix Calculator
Add, subtract, multiply matrices and calculate determinant and transpose.
Matrix A (rows × cols)
Matrix B
What Is a Matrix?
A matrix is a rectangular array of numbers arranged in rows and columns. A 3×2 matrix has 3 rows and 2 columns. Matrices are the core data structure of linear algebra and appear throughout computer graphics, machine learning, physics, economics, and engineering. Most operations that feel complex with equations become systematic and computable when expressed in matrix form — which is why virtually all scientific computing software works extensively with matrices.
Key Matrix Operations
Addition and subtraction require matrices of the same dimensions — just add or subtract corresponding elements. Multiplication is more complex: to multiply matrix A (m×n) by matrix B (p×q), the inner dimensions must match (n = p), and the result is an m×q matrix. Each element of the result is a dot product of a row from A and a column from B. The transpose flips a matrix across its main diagonal — rows become columns and vice versa. The determinant is a single scalar value that encodes key properties of a square matrix — a zero determinant means the matrix has no inverse.
Why Matrices Matter
In computer graphics, every rotation, scaling, and translation of a 3D object is represented as matrix multiplication. In machine learning, a neural network's weights are stored as matrices and forward propagation is matrix multiplication. In Google's original PageRank algorithm, the entire web was modeled as a massive matrix and page importance was found by solving a matrix equation. Even spreadsheet operations like pivot tables and regression analysis are fundamentally matrix computations under the hood.
Frequently Asked Questions
When can you multiply two matrices?
Matrix A (m×n) can multiply matrix B (p×q) only when n = p — the number of columns in A must equal the number of rows in B. The result has dimensions m×q. Matrix multiplication is not commutative: A×B and B×A are generally different (and one may not even be defined if the other is).
What is the identity matrix?
The identity matrix (I) is a square matrix with 1s on the main diagonal and 0s everywhere else. Multiplying any matrix by a conformable identity matrix returns the original matrix unchanged — it is the matrix equivalent of multiplying by 1. The identity matrix is used in solving systems of equations, finding matrix inverses, and defining matrix division.
What is a matrix inverse?
The inverse of a square matrix A (written A⁻¹) is the matrix that, when multiplied by A, gives the identity matrix. Not all matrices have inverses — a matrix with a zero determinant is called singular and has no inverse. Matrix inverses are used to solve systems of linear equations: if Ax = b, then x = A⁻¹b.
What does the determinant tell you?
The determinant of a square matrix encodes several important properties. If det = 0, the matrix is singular (no inverse, system of equations has no unique solution). The absolute value of the determinant gives the scaling factor of the transformation — a 2×2 matrix with determinant 3 scales areas by a factor of 3. The sign indicates whether the transformation preserves or reverses orientation.
What are matrices used for in real life?
Computer graphics (3D transformations, camera projections), machine learning (neural network layers, principal component analysis), economics (input-output models), physics (quantum mechanics, relativity), engineering (finite element analysis), cryptography, statistics (regression, covariance), and network analysis. Any application involving systems of equations or multidimensional data is likely using matrix operations under the hood.