Skip to content

Matrix Calculator — Free Online Matrix Operations Tool

Perform all standard matrix operations including addition, subtraction, multiplication, transpose, determinant, inverse, and scalar multiplication for matrices up to 4x4.

Matrix A

Matrix B

Result

10.0000
10.0000
10.0000
10.0000
10.0000
10.0000
10.0000
10.0000
10.0000

Matrix Properties

Size: 3 x 3

Determinant of A: 0.0000

Invertible: No

How to Use the Matrix Calculator

  1. Select the operation: Choose from seven matrix operations using the dropdown: A + B (addition), A - B (subtraction), A x B (multiplication), Transpose of A, Determinant of A, Inverse of A, or Scalar x A. For unary operations (transpose, determinant, inverse), only Matrix A is used.
  2. Choose the matrix size: Select 2x2, 3x3, or 4x4 from the size dropdown. Changing the size preserves existing values where possible and fills new cells with 0. Square matrices are required for determinant and inverse operations.
  3. Enter matrix values: Click on each cell in the grid and type a number. Each cell accepts decimal values. For two-matrix operations (add, subtract, multiply), fill in both Matrix A and Matrix B. For scalar multiplication, also enter the scalar value in the additional field.
  4. Review the results: The result panel shows the computed output matrix (for matrix-returning operations) or the scalar determinant value. It also displays the determinant of Matrix A and whether it is invertible as additional properties.

The default 3x3 matrix A contains [[1,2,3],[4,5,6],[7,8,9]] and matrix B contains [[9,8,7],[6,5,4],[3,2,1]]. Try the addition operation first to see how element-wise operations work, then switch to multiplication to see the more complex row-column product. Note that this default Matrix A has determinant 0 — try changing one value to make it invertible.

Matrix Operation Formulas

Matrix Addition / Subtraction

(A ± B)_ij = A_ij ± B_ij

Matrix Multiplication

(AB)_ij = sum(A_ik * B_kj, k=1..n)

2x2 Determinant

det([[a,b],[c,d]]) = ad - bc

2x2 Inverse

A^(-1) = (1/det(A)) * [[d,-b],[-c,a]]

Transpose

(A^T)_ij = A_ji

Key Properties

  • Addition is commutative: A + B = B + A. Subtraction is not: A - B does not equal B - A (unless A = B).
  • Multiplication is NOT commutative: AB does not generally equal BA. This is one of the most important differences between matrix and scalar arithmetic.
  • Multiplication is associative: (AB)C = A(BC). You can group multiplications any way you want without changing the result.
  • Determinant of a product: det(AB) = det(A) x det(B). The determinant "distributes" over multiplication.
  • Inverse of a product: (AB)^(-1) = B^(-1) A^(-1). Note the reversed order — the same reversal that occurs with transpose of a product.

Step-by-Step Example

Multiply A = [[1, 2], [3, 4]] by B = [[5, 6], [7, 8]]:

  1. Result[0][0] = (row 0 of A) dot (col 0 of B) = 1x5 + 2x7 = 5 + 14 = 19
  2. Result[0][1] = (row 0 of A) dot (col 1 of B) = 1x6 + 2x8 = 6 + 16 = 22
  3. Result[1][0] = (row 1 of A) dot (col 0 of B) = 3x5 + 4x7 = 15 + 28 = 43
  4. Result[1][1] = (row 1 of A) dot (col 1 of B) = 3x6 + 4x8 = 18 + 32 = 50
  5. AB = [[19, 22], [43, 50]]

Verify with determinants: det(A) = 1x4 - 2x3 = -2, det(B) = 5x8 - 6x7 = -2, det(AB) = 19x50 - 22x43 = 950 - 946 = 4 = (-2)(-2). The determinant of the product equals the product of determinants.

Practical Examples

Example 1: Alex Solves a System of Equations

Alex needs to solve the system: 2x + 3y = 8 and 5x + 4y = 13. This can be written as the matrix equation Ax = b where A = [[2,3],[5,4]], x = [[x],[y]], b = [[8],[13]]:

  • det(A) = 2x4 - 3x5 = 8 - 15 = -7 (non-zero, so inverse exists)
  • A^(-1) = (1/-7) x [[4,-3],[-5,2]] = [[-4/7, 3/7], [5/7, -2/7]]
  • x = A^(-1) x b = [[-4/7 x 8 + 3/7 x 13], [5/7 x 8 + -2/7 x 13]]
  • x = [[-32/7 + 39/7], [40/7 - 26/7]] = [[7/7], [14/7]] = [[1], [2]]

The solution is x = 1, y = 2. Verification: 2(1) + 3(2) = 8, and 5(1) + 4(2) = 13. Both equations are satisfied. This method generalizes to systems of any size — for 100 equations in 100 unknowns, the same matrix inverse approach works (though numerical methods are preferred for stability).

Example 2: Maya Rotates a 2D Point

Maya is programming a game and needs to rotate a point (3, 4) by 90 degrees counterclockwise. The 2D rotation matrix for angle theta is [[cos(theta), -sin(theta)], [sin(theta), cos(theta)]]:

  • For 90 degrees: cos(90) = 0, sin(90) = 1
  • Rotation matrix = [[0, -1], [1, 0]]
  • New point = [[0,-1],[1,0]] x [[3],[4]] = [[0x3 + (-1)x4], [1x3 + 0x4]] = [[-4], [3]]

The point (3, 4) rotated 90 degrees counterclockwise becomes (-4, 3). Every 3D transformation in computer graphics — rotation, scaling, translation, perspective projection — is accomplished by multiplying 4x4 matrices. Game engines perform millions of such matrix multiplications per frame.

Example 3: Robert Analyzes a Network

Robert is studying a 3-node network where A = [[0,1,1],[1,0,1],[1,1,0]] represents connections (1 means connected, 0 means not). A^2 gives the number of 2-step paths between nodes:

  • A^2 = A x A = [[2,1,1],[1,2,1],[1,1,2]]
  • A^2[0][0] = 2: there are 2 paths of length 2 from node 0 back to itself (0-1-0 and 0-2-0)
  • A^2[0][1] = 1: there is 1 path of length 2 from node 0 to node 1 (0-2-1)

This adjacency matrix technique is the foundation of graph theory and network analysis. Google's PageRank algorithm works by repeatedly multiplying a web link matrix, and social network analysis uses similar matrix powers to find communities and influential nodes.

Matrix Properties Reference Table

Property Addition Multiplication Transpose Determinant
CommutativeYes (A+B=B+A)No (AB does not equal BA)N/AN/A
AssociativeYesYesN/AN/A
DistributiveA(B+C)=AB+ACOver addition(A+B)^T=A^T+B^Tdet(AB)=det(A)det(B)
IdentityZero matrixIdentity matrix I(A^T)^T = Adet(I) = 1
Inverse-A (negation)A^(-1) if det != 0(A^T)^(-1)=(A^(-1))^Tdet(A^(-1))=1/det(A)
Product ruleN/A(AB)^(-1)=B^(-1)A^(-1)(AB)^T=B^T A^Tdet(kA)=k^n det(A)

Tips and Complete Guide

Understanding Determinants Geometrically

The determinant of a 2x2 matrix represents the signed area of the parallelogram formed by its column vectors. For a 3x3 matrix, it represents the signed volume of the parallelepiped. A positive determinant means the transformation preserves orientation (handedness), while a negative determinant reverses it (a reflection is involved). A determinant of zero means the transformation collapses space by at least one dimension — a 3D object gets squashed into a plane, line, or point. This geometric interpretation makes determinants intuitive: a larger absolute determinant means more stretching, and zero means total collapse.

Eigenvalues and Eigenvectors

For a square matrix A, an eigenvector v is a non-zero vector that satisfies Av = lambda x v, where lambda is the corresponding eigenvalue. Eigenvectors point in directions that the transformation only scales (doesn't rotate). Finding eigenvalues requires solving det(A - lambda x I) = 0, which gives a polynomial equation. The sum of eigenvalues equals the trace (sum of diagonal elements), and the product of eigenvalues equals the determinant. Eigenvalues are critical in physics (vibration modes), machine learning (PCA, SVD), and Google's PageRank algorithm.

Matrices in Machine Learning

Neural networks are essentially sequences of matrix multiplications and non-linear activations. A layer with n inputs and m outputs is represented by an m x n weight matrix. Training adjusts these matrices using gradient descent, which involves computing derivatives (gradients) of matrix expressions. The backpropagation algorithm is fundamentally a series of matrix transposes and multiplications. Modern GPUs are optimized for parallel matrix operations, which is why they excel at machine learning — a single GPU can perform trillions of matrix element operations per second.

Numerical Stability Considerations

When working with matrices on computers, numerical precision matters. Matrices with determinants close to zero (ill-conditioned matrices) can produce wildly inaccurate inverses due to floating-point rounding errors. The condition number of a matrix measures this sensitivity — high condition numbers mean the matrix is nearly singular and computations with it are unreliable. In practice, LU decomposition, QR decomposition, or singular value decomposition (SVD) are preferred over direct inverse computation for solving linear systems. Our calculator uses exact formulas suitable for small matrices.

Common Mistakes to Avoid

  • Assuming matrix multiplication is commutative: AB does not equal BA in general. The order of multiplication matters enormously. In computer graphics, applying rotation then translation gives a different result than translation then rotation. Always multiply in the correct order.
  • Adding matrices of different sizes: You can only add or subtract matrices of identical dimensions. A 2x3 matrix cannot be added to a 3x2 matrix. Our calculator enforces equal sizes for addition and subtraction.
  • Misunderstanding dimension requirements for multiplication: For AB to be defined, the number of columns in A must equal the number of rows in B. A (2x3) matrix can multiply a (3x4) matrix, producing a (2x4) result. But a (2x3) cannot multiply a (2x4) because 3 does not equal 2.
  • Confusing det(kA) with k x det(A): For an n x n matrix, det(kA) = k^n x det(A), not k x det(A). Multiplying a 3x3 matrix by 2 multiplies the determinant by 2^3 = 8, not by 2. This is because scaling all three dimensions doubles each, and volume scales as the cube.
  • Trying to invert a singular matrix: A matrix with determinant 0 has no inverse. Attempting to compute one produces division by zero. Always check the determinant first. If it is zero or very close to zero, the system of equations is either inconsistent or has infinitely many solutions.

Frequently Asked Questions

A matrix is a rectangular array of numbers arranged in rows and columns. A matrix with m rows and n columns is called an m-by-n matrix. Matrices are fundamental to linear algebra and are used extensively in computer graphics, physics, engineering, statistics, and machine learning. For example, a 3x3 matrix has 3 rows and 3 columns, containing 9 numbers. Our calculator supports matrices up to 4x4 and performs all standard operations including addition, subtraction, multiplication, transpose, determinant, inverse, and scalar multiplication.

Matrix addition and subtraction are performed element by element. Both matrices must have the same dimensions. For each position (i, j), add or subtract the corresponding elements: (A + B)_ij = A_ij + B_ij. For example, if A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], then A + B = [[6, 8], [10, 12]]. Unlike multiplication, matrix addition is commutative (A + B = B + A) and straightforward. Our calculator handles this instantly for matrices up to 4x4.

Matrix multiplication is more complex than addition. For A (m x n) multiplied by B (n x p), the result is an m x p matrix. Each element (i, j) of the result is the dot product of row i of A and column j of B. The number of columns in A must equal the number of rows in B. For example, [[1,2],[3,4]] x [[5,6],[7,8]] = [[1x5+2x7, 1x6+2x8],[3x5+4x7, 3x6+4x8]] = [[19,22],[43,50]]. Matrix multiplication is NOT commutative: A x B usually does not equal B x A.

The determinant is a scalar value computed from a square matrix that encodes important properties. For a 2x2 matrix [[a,b],[c,d]], the determinant is ad - bc. For larger matrices, the determinant is computed using cofactor expansion. A non-zero determinant means the matrix is invertible and represents a non-degenerate linear transformation. A zero determinant means the matrix is singular — it collapses space into a lower dimension and has no inverse. The absolute value of the determinant gives the scaling factor for areas (2D) or volumes (3D).

The inverse of a square matrix A, denoted A^(-1), is the matrix such that A x A^(-1) = A^(-1) x A = I (the identity matrix). An inverse exists if and only if the determinant is non-zero. For a 2x2 matrix [[a,b],[c,d]] with determinant D = ad-bc, the inverse is (1/D)[[d,-b],[-c,a]]. Matrix inversion is used to solve systems of linear equations: if Ax = b, then x = A^(-1)b. Our calculator computes inverses for matrices up to 4x4 and reports when a matrix is singular.

The transpose of a matrix A, written A^T, is formed by converting rows into columns and columns into rows. If A is m x n, then A^T is n x m. Element (i, j) of A becomes element (j, i) of A^T. For example, the transpose of [[1,2,3],[4,5,6]] is [[1,4],[2,5],[3,6]]. Key properties: (A^T)^T = A, (A + B)^T = A^T + B^T, (AB)^T = B^T A^T (note the reversed order). Symmetric matrices equal their transpose (A = A^T) and arise frequently in physics and statistics.

Scalar multiplication multiplies every element of a matrix by a single number (the scalar). If k is a scalar and A is a matrix, then (kA)_ij = k x A_ij. For example, 3 x [[1,2],[3,4]] = [[3,6],[9,12]]. Scalar multiplication distributes over matrix addition: k(A + B) = kA + kB. The determinant of kA for an n x n matrix is k^n times det(A), not k times det(A) — a common misconception. This operation is equivalent to scaling all directions uniformly in the geometric interpretation.

Matrices are used everywhere in modern computing and science. Computer graphics use 4x4 transformation matrices for rotation, scaling, and translation of 3D objects. Machine learning relies on matrix operations for neural network computations. Google's PageRank algorithm uses enormous matrices to rank web pages. Quantum mechanics describes quantum states as vectors and operations as matrices. Structural engineering uses stiffness matrices to analyze forces in buildings and bridges. Image processing treats images as matrices of pixel values. Essentially, any system involving multiple interrelated linear equations uses matrices.

The identity matrix I is a square matrix with 1s on the main diagonal and 0s everywhere else. For a 3x3 identity: [[1,0,0],[0,1,0],[0,0,1]]. It is the multiplicative identity: AI = IA = A for any compatible matrix A. The identity matrix represents the 'do nothing' transformation — it maps every vector to itself. Its determinant is 1. Any invertible matrix A satisfies AA^(-1) = A^(-1)A = I. The identity matrix plays the same role for matrices that the number 1 plays for scalar multiplication.

Related Calculators

Disclaimer: This calculator is for informational and educational purposes only. Results are estimates and may not reflect exact values.

Last updated: February 23, 2026

Sources