Linear Algebra

Matrix
Calculator

Add, subtract, and multiply matrices. Find determinant, inverse, transpose, scalar multiples, and matrix properties. Supports up to 5×5 with step-by-step solutions.

Operation
Result Size
Matrix A
Single Matrix Operations
Matrix A
Matrix B
Two Matrix Operations
Result

Understanding Matrix Operations

A matrix is a rectangular array of numbers arranged in rows and columns. Matrix operations are fundamental to linear algebra, which underpins computer graphics, machine learning, physics simulations, and network analysis.

Key Matrix Formulas

Addition (A+B): Same size only. Add element by element. Subtraction (A−B): Same size only. Subtract element by element. Multiply (AB): A is m×n, B is n×p → result is m×p. C[i][j] = Σ A[i][k] × B[k][j] Transpose (Aᵀ): Rows become columns. m×n → n×m. Determinant 2×2: det = ad − bc Determinant 3×3: Cofactor expansion along first row. Inverse A⁻¹: Exists only if det(A) ≠ 0. A⁻¹ = adjugate(A) / det(A) Trace: Sum of diagonal elements. Hadamard (A⊙B): Same size. Multiply element by element.
Why is matrix multiplication not commutative?
In general, AB ≠ BA because each element of the result depends on a specific row of A and column of B. When you reverse the order, different rows and columns combine. Beyond that, AB might not even be defined when BA is (e.g., A is 2×3 and B is 3×4 — AB is 2×4 but BA is undefined). Even when both are defined and square, they typically give different results.
What does the determinant tell you?
The determinant of a square matrix encodes the scaling factor of the linear transformation the matrix represents. Geometrically: |det(A)| is the factor by which areas (2D) or volumes (3D) are scaled. If det(A) = 0, the transformation is degenerate — it collapses space into a lower dimension. A non-zero determinant means the matrix is invertible.
What is an identity matrix?
The identity matrix I has 1s on the main diagonal and 0s everywhere else. Multiplying any matrix A by I (of compatible size) gives back A: AI = IA = A. It's the matrix equivalent of multiplying by 1. The identity matrix is always square. A 3×3 identity has 1s at (1,1), (2,2), (3,3) and 0s everywhere else.
When does a matrix NOT have an inverse?
A matrix has no inverse (is "singular") when: it is not square, OR its determinant is zero. A zero determinant means the rows (or columns) are linearly dependent — one row is a combination of others. For example, if row 2 = 2 × row 1, the matrix is singular. Singular matrices cannot "undo" transformations because they've lost information (collapsed dimensions).