Matrix Calculator

Add, subtract, multiply matrices and find the determinant, inverse, and transpose — for 2×2 and 3×3 matrices.

🔢 Matrix Calculator

What Is a Matrix Calculator?

A matrix calculator is a tool that performs the core operations of linear algebra on rectangular arrays of numbers called matrices. Matrices appear everywhere in mathematics, physics, computer graphics, machine learning, and engineering — they encode linear transformations, represent systems of equations, and model relationships between variables in multi-dimensional space.

This calculator supports the five most important matrix operations for 2×2 and 3×3 square matrices, plus arbitrary rectangular shapes for the transpose. Each operation has a precise mathematical meaning:

  • Addition / Subtraction: Element-wise combination of two same-size matrices.
  • Multiplication: Dot-product combination that composes linear transformations.
  • Determinant: A scalar value encoding the "volume scaling factor" and invertibility of a square matrix.
  • Inverse: The matrix A⁻¹ such that A × A⁻¹ = I (the identity), used to solve matrix equations.
  • Transpose: Reflects the matrix across its main diagonal, swapping rows and columns.

Understanding these operations is fundamental for any student or professional working with linear algebra, machine learning, computer graphics, structural engineering, or data science.

Matrix Operation Formulas

Addition: (A + B)ᵢⱼ = Aᵢⱼ + Bᵢⱼ — add corresponding elements.

Subtraction: (A − B)ᵢⱼ = Aᵢⱼ − Bᵢⱼ — subtract corresponding elements.

Multiplication: Cᵢⱼ = Σₖ Aᵢₖ · Bₖⱼ — dot product of row i of A with column j of B.

2×2 Determinant: For A = [[a,b],[c,d]], det(A) = a·d − b·c

3×3 Determinant (cofactor expansion along row 1):

det(A) = a₁₁(a₂₂a₃₃ − a₂₃a₃₂) − a₁₂(a₂₁a₃₃ − a₂₃a₃₁) + a₁₃(a₂₁a₃₂ − a₂₂a₃₁)

2×2 Inverse: A⁻¹ = (1/det) · [[d, −b],[−c, a]] — only when det ≠ 0.

Transpose: (Aᵀ)ᵢⱼ = Aⱼᵢ — swap row and column indices.

OperationRequirementResult SizeCommutative?
Addition A + BSame dimensionsSame as A, BYes
Subtraction A − BSame dimensionsSame as A, BNo
Multiplication A × Bcols(A) = rows(B)rows(A) × cols(B)No
Determinant det(A)Square matrixScalar
Inverse A⁻¹Square, det ≠ 0Same as A
Transpose AᵀAny matrixCols × Rows flipped

📖 How to Use the Matrix Calculator

Steps to Calculate

1
Choose an operation from the tabs: Add, Subtract, Multiply, Determinant, Inverse, or Transpose.
2
Select matrix size using the dropdown (2×2 or 3×3; for Transpose, choose rows and columns independently).
3
Enter matrix values into each cell of the grid. Cells default to 0.
4
Click Calculate to see the result matrix, the determinant value, or the inverse — with step-by-step working where applicable.
5
Switch modes at any time by clicking a different tab. The grids update automatically.

Example Calculations

Example 1 — 2×2 Matrix Multiplication

A = [[2, 3], [1, 4]]  ×  B = [[5, 2], [0, 6]]

1
C₁₁ = 2·5 + 3·0 = 10
2
C₁₂ = 2·2 + 3·6 = 4 + 18 = 22
3
C₂₁ = 1·5 + 4·0 = 5    C₂₂ = 1·2 + 4·6 = 26
A × B = [[10, 22], [5, 26]]
Try this example →

Example 2 — 3×3 Determinant

A = [[1,2,3],[4,5,6],[7,8,9]]

1
Expand along row 1: det = 1·(5·9−6·8) − 2·(4·9−6·7) + 3·(4·8−5·7)
2
= 1·(45−48) − 2·(36−42) + 3·(32−35) = 1·(−3) − 2·(−6) + 3·(−3)
3
= −3 + 12 − 9 = 0
det = 0 → this matrix is singular and has no inverse.
Try this example →

Example 3 — 2×2 Inverse

A = [[4, 7], [2, 6]] — find A⁻¹

1
det(A) = 4·6 − 7·2 = 24 − 14 = 10
2
A⁻¹ = (1/10) · [[6, −7],[−2, 4]]
3
A⁻¹ = [[0.6, −0.7],[−0.2, 0.4]]
Verify: A × A⁻¹ = [[4·0.6+7·(−0.2), ...]] = [[1,0],[0,1]] ✓
Try this example →

❓ Frequently Asked Questions

What is a matrix?+
A matrix is a rectangular array of numbers arranged in rows and columns. A 2×2 matrix has 2 rows and 2 columns (4 elements); a 3×3 matrix has 9 elements. Matrices are used in linear algebra to represent linear transformations, solve systems of equations, model transformations in 3D graphics, and much more. Each element is identified by its row and column index.
How do you add or subtract matrices?+
To add or subtract matrices, they must have the same dimensions (same number of rows and columns). You simply add or subtract corresponding elements: (A + B)ᵢⱼ = Aᵢⱼ + Bᵢⱼ. For example: [[1,2],[3,4]] + [[5,6],[7,8]] = [[6,8],[10,12]]. Matrix addition is commutative (A + B = B + A) and associative. Subtraction is not commutative: A − B ≠ B − A.
How does matrix multiplication work?+
Matrix multiplication (A × B) requires the columns in A to equal the rows in B. Element Cᵢⱼ = Σₖ Aᵢₖ × Bₖⱼ. For 2×2: [[1,2],[3,4]] × [[5,6],[7,8]] = [[1·5+2·7, 1·6+2·8],[3·5+4·7, 3·6+4·8]] = [[19,22],[43,50]]. Multiplication is NOT commutative: A × B ≠ B × A in general. It is associative: (AB)C = A(BC).
What is a matrix determinant?+
The determinant is a scalar computed from a square matrix. For 2×2 [[a,b],[c,d]], det = ad − bc. For 3×3, use cofactor expansion. Key properties: det = 0 means the matrix is singular (non-invertible, maps space to a lower-dimensional subspace); det(AB) = det(A)·det(B); |det| is the volume scaling factor. For example, a 2×2 matrix with det = 3 scales areas by a factor of 3.
When does a matrix have an inverse?+
A square matrix A has an inverse A⁻¹ if and only if det(A) ≠ 0. Such a matrix is called invertible or non-singular. The inverse satisfies A × A⁻¹ = A⁻¹ × A = I. For a 2×2 matrix [[a,b],[c,d]], the inverse is (1/(ad−bc)) × [[d,−b],[−c,a]]. If det = 0, the matrix is singular, maps multiple inputs to the same output, and cannot be inverted.
What is a matrix transpose?+
The transpose Aᵀ swaps rows and columns: element at (i,j) in A moves to (j,i) in Aᵀ. A 2×3 matrix becomes 3×2 after transposing. Properties: (Aᵀ)ᵀ = A; (A+B)ᵀ = Aᵀ+Bᵀ; (AB)ᵀ = BᵀAᵀ. A symmetric matrix satisfies A = Aᵀ. Transpose appears in inner products, covariance matrices, and neural network weight updates during backpropagation.
What is the identity matrix?+
The identity matrix I has 1s on the main diagonal and 0s elsewhere: I₂ = [[1,0],[0,1]], I₃ = [[1,0,0],[0,1,0],[0,0,1]]. Multiplying any matrix by the identity leaves it unchanged: A × I = I × A = A. The identity is the multiplicative identity for matrix multiplication, analogous to 1 for scalar multiplication. A⁻¹ is defined by A × A⁻¹ = I.
What are eigenvalues and eigenvectors?+
For a square matrix A, a non-zero vector v is an eigenvector if Av = λv for some scalar λ (the eigenvalue). Eigenvectors point in directions scaled (but not rotated) by A. Eigenvalues satisfy det(A − λI) = 0. Applications: PCA in machine learning (eigenvectors of the covariance matrix are principal components), quantum mechanics (eigenvalues are observable quantities), and Google's PageRank (dominant eigenvector of the web graph).
What is a singular matrix?+
A singular matrix is a square matrix with det = 0. It has no inverse, its rows (or columns) are linearly dependent, and the corresponding linear system Ax = b either has no solution or infinitely many solutions. Geometrically, a singular matrix collapses space: a 2×2 singular matrix maps the entire 2D plane onto a line. Numerical computations with near-singular matrices can be numerically unstable.
How are matrices used in real life?+
Matrices are ubiquitous: (1) Computer graphics — 4×4 transformation matrices perform rotation, scaling, and translation in 3D rendering. (2) Machine learning — neural network weights are matrices; operations like forward pass are matrix multiplications. (3) Economics — input-output models (Leontief matrices) analyse supply chains. (4) Physics — quantum mechanics uses matrices (operators) to represent observables. (5) Engineering — stiffness matrices in finite element analysis model structural behaviour. (6) Statistics — covariance matrices encode variable relationships.
Is matrix multiplication commutative?+
No. In general, A × B ≠ B × A. For example: [[1,2],[3,4]] × [[0,1],[1,0]] = [[2,1],[4,3]], but [[0,1],[1,0]] × [[1,2],[3,4]] = [[3,4],[1,2]]. Matrix multiplication is associative ((AB)C = A(BC)) and distributive (A(B+C) = AB+AC), but not commutative. There are special cases where AB = BA (diagonal matrices always commute; a matrix commutes with its own inverse), but these are exceptions not the rule.

What is a matrix?

A matrix is a rectangular array of numbers arranged in rows and columns. A 2×2 matrix has 2 rows and 2 columns (4 elements); a 3×3 matrix has 9 elements. Matrices are used in linear algebra to represent linear transformations, solve systems of equations, model transformations in 3D graphics, and much more. Each element is identified by its row and column index.

How do you add or subtract matrices?

To add or subtract matrices, they must have the same dimensions (same number of rows and columns). You simply add or subtract corresponding elements: (A + B)ᵢⱼ = Aᵢⱼ + Bᵢⱼ. For example, adding two 2×2 matrices: [[1,2],[3,4]] + [[5,6],[7,8]] = [[6,8],[10,12]]. Matrix addition is commutative (A + B = B + A) and associative.

How does matrix multiplication work?

Matrix multiplication (A × B) is defined only when the number of columns in A equals the number of rows in B. The element at row i, column j of the result is the dot product of row i of A and column j of B: Cᵢⱼ = Σₖ Aᵢₖ × Bₖⱼ. For a 2×2 example: [[1,2],[3,4]] × [[5,6],[7,8]] = [[1·5+2·7, 1·6+2·8],[3·5+4·7, 3·6+4·8]] = [[19,22],[43,50]]. Multiplication is NOT commutative.

What is a determinant?

The determinant is a scalar value computed from a square matrix that encodes important properties. For a 2×2 matrix [[a,b],[c,d]], det = ad − bc. For a 3×3 matrix, it uses cofactor expansion. Key properties: det(A) = 0 means the matrix is singular (non-invertible); det(AB) = det(A) × det(B); det(Aᵀ) = det(A). Geometrically, |det(A)| is the area/volume scaling factor of the linear transformation A.

How do you find the inverse of a matrix?

A matrix A is invertible if det(A) ≠ 0. For a 2×2 matrix [[a,b],[c,d]], the inverse is (1/det) × [[d,−b],[−c,a]]. For 3×3, the inverse is the adjugate matrix (transposed cofactor matrix) divided by the determinant. The inverse satisfies A × A⁻¹ = A⁻¹ × A = I (identity matrix). If det(A) = 0, the matrix is singular and has no inverse.

What is matrix transpose?

The transpose Aᵀ of a matrix A is obtained by swapping rows and columns: element at position (i,j) in A moves to position (j,i) in Aᵀ. A 2×3 matrix becomes a 3×2 matrix after transposing. Properties: (Aᵀ)ᵀ = A; (A + B)ᵀ = Aᵀ + Bᵀ; (AB)ᵀ = BᵀAᵀ. Symmetric matrices satisfy A = Aᵀ. Transpose is used heavily in statistics, physics, and machine learning.

What is the identity matrix?

The identity matrix I is the square matrix with 1s on the main diagonal and 0s everywhere else. For 2×2: I = [[1,0],[0,1]]; for 3×3: I = [[1,0,0],[0,1,0],[0,0,1]]. Any matrix multiplied by the identity gives itself: A × I = I × A = A. The identity matrix is the multiplicative identity for matrix multiplication, analogous to the number 1 for scalar multiplication.

What is the difference between a singular and non-singular matrix?

A square matrix is non-singular (invertible) if its determinant is non-zero. It has a unique inverse and the system Ax = b has a unique solution for any b. A singular matrix has det = 0, no inverse, and the corresponding linear system either has no solution or infinitely many solutions. Singular matrices represent degenerate linear transformations that collapse the space (e.g., mapping a 2D plane onto a line).

How do matrices relate to solving linear equations?

A system of linear equations can be written as Ax = b, where A is the coefficient matrix, x is the vector of unknowns, and b is the constants vector. If A is invertible, the unique solution is x = A⁻¹ × b. For 2 equations in 2 unknowns: [a₁x + b₁y = c₁, a₂x + b₂y = c₂] → matrix A = [[a₁,b₁],[a₂,b₂]]. This is why determinants and inverses are central to linear algebra.

What is the cofactor expansion method for the determinant?

Cofactor expansion (Laplace expansion) computes the determinant by breaking a 3×3 matrix into three 2×2 determinants. Expanding along the first row: det = a₁₁(a₂₂a₃₃ − a₂₃a₃₂) − a₁₂(a₂₁a₃₃ − a₂₃a₃₁) + a₁₃(a₂₁a₃₂ − a₂₂a₃₁). The signs alternate: +, −, +, −, ... The cofactor Cᵢⱼ = (−1)^(i+j) × det(minor Mᵢⱼ). This method generalizes to any square matrix by expanding along any row or column.

What are eigenvalues and eigenvectors?

For a square matrix A, an eigenvector v is a non-zero vector satisfying Av = λv, where λ is the corresponding eigenvalue (a scalar). Eigenvectors point in directions that are only scaled (not rotated) by the transformation A. Eigenvalues are found by solving det(A − λI) = 0 (the characteristic equation). Eigenvalues/eigenvectors are fundamental in physics, machine learning (PCA), differential equations, and Google's PageRank algorithm.

What does it mean for two matrices to be equal?

Two matrices A and B are equal if and only if they have the same dimensions and every corresponding element is equal: Aᵢⱼ = Bᵢⱼ for all i and j. So [[1,2],[3,4]] = [[1,2],[3,4]] but [[1,2],[3,4]] ≠ [[1,2],[3,5]]. Matrix equality is an element-wise comparison, not an overall 'value' comparison like with scalars.