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

  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]]

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.

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]] ✓

❓ 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.