Skip to main content
ilovecalcs logoilovecalcs.

Math · Live

Matrix Calculator — add, multiply, invert & more.

Perform eight matrix operations on matrices up to 5×5: addition, subtraction, multiplication, scalar multiply, transpose, determinant, inverse, and integer powers. Edit cells directly in the matrix grid . Results update instantly.

How it worksReal-time

Operation

Matrix ops

Multiply: A × B

Matrix A

Rows
Cols

Matrix B

Rows
Cols

Quick fill — A

Matrix A

3×3

3×3

Matrix B

3×3

3×3

Result

A × B

30
24
18
84
69
54
138
114
90

3×3

(3×3) × (3×3) = (3×3) result

Matrix guide

Matrix operations: the foundation of linear algebra.

A matrix is a rectangular array of numbers arranged in rows and columns. Matrices are the fundamental data structure of linear algebra; they represent linear transformations, encode systems of equations, describe rotations in 3D space, and underlie virtually every algorithm in machine learning and computer graphics.

Matrix addition and subtraction

Two matrices can be added or subtracted only if they have the same dimensions (same number of rows and columns). The operation is performed element-by-element:

(A + B)[i][j] = A[i][j] + B[i][j]

Matrix addition is commutative (A + B = B + A) and associative ((A + B) + C = A + (B + C)). These properties make matrix addition behave identically to ordinary number addition.

Matrix multiplication

Multiplying A (m×n) by B (n×p) produces a result C (m×p). The number of columns in A must equal the number of rows in B:

C[i][j] = Σₖ A[i][k] × B[k][j]

Each entry C[i][j] is the dot product of row i from A with column j from B. Matrix multiplication is not commutative in general (AB ≠ BA), but it is associative ((AB)C = A(BC)) and distributive over addition.

Scalar multiplication

Multiplying every element of a matrix by a constant k:

(kA)[i][j] = k × A[i][j]

This scales the matrix geometrically. If A represents a linear transformation, kA scales its effect by k.

Transpose

The transpose of an m×n matrix A is an n×m matrix Aᵀ obtained by swapping rows and columns:

Aᵀ[i][j] = A[j][i]

Key properties: (AB)ᵀ = BᵀAᵀ, (Aᵀ)ᵀ = A. A matrix where A = Aᵀ is called symmetric. These appear naturally in statistics (covariance matrices) and physics (stress tensors).

Determinant

The determinant is a scalar value associated with every square matrix. Geometrically, |det(A)| is the volume-scaling factor of the linear transformation represented by A:

  • 2×2: det = ad − bc for matrix [[a,b],[c,d]]
  • 3×3: Cofactor expansion along any row or column (Sarrus rule is a mnemonic shortcut)
  • n×n: LU-decomposition (Gaussian elimination) — the product of the diagonal of the U matrix.

Critical uses of the determinant:

  • If det(A) = 0, the matrix is singular — it has no inverse and the corresponding linear system has no unique solution.
  • If det(A) ≠ 0, the matrix is invertible.
  • det(AB) = det(A) × det(B)
  • det(Aᵀ) = det(A)

Matrix inverse

The inverse of a square matrix A (written A⁻¹) satisfies:

A × A⁻¹ = A⁻¹ × A = I

where I is the identity matrix. An inverse exists only when det(A) ≠ 0 (i.e., the matrix is non-singular). The inverse is unique when it exists.

Gauss-Jordan method: Augment A with the identity matrix [A | I] and apply row operations to reach [I | A⁻¹].

Applications: solving systems of linear equations (x = A⁻¹b), reversing transformations in computer graphics, and computing linear regression coefficients ((AᵀA)⁻¹Aᵀy).

Matrix powers

Aⁿ means multiplying A by itself n times. This calculator uses fast binary exponentiation (O(log n) multiplications instead of O(n)), which matters for large exponents.

  • A⁰ = I (the identity matrix — by convention)
  • A¹ = A
  • A² = A × A
  • Aⁿ requires a square matrix

Matrix powers appear in Markov chains (transition probability after n steps), graph theory (counting paths of length n), and discrete dynamical systems.

Common matrix types and their properties

Matrix typeConditionSpecial property
Identity (I)A[i][i]=1, off-diag=0AI = IA = A for any A
SymmetricA = AᵀReal eigenvalues
DiagonalNon-zero on diagonal onlyEasy to invert and exponentiate
OrthogonalAᵀA = Idet = ±1; preserves lengths
Singulardet = 0Not invertible; rank-deficient
IdempotentA² = AProjection matrices

Real-world applications

  • Computer graphics: 4×4 matrices encode translation, rotation, and scaling in 3D engines (OpenGL, DirectX).
  • Machine learning: Neural network layers are matrix multiplications (Wx + b). Backpropagation uses matrix transposes.
  • Linear systems: Solve Ax = b for x using Gaussian elimination or x = A⁻¹b.
  • Markov chains: State distributions after n steps = initial × Pⁿ.
  • Quantum mechanics: Quantum states are vectors; observables are matrices (Hermitian operators).
  • Economics: Input-output models (Leontief), covariance matrices in portfolio theory.