MathMarch 28, 2026

Matrix Calculator Guide: Addition, Multiplication & Determinants (2026)

By The hakaru Team·Last updated March 2026

Quick Answer

  • *A matrix is a rectangular array of numbers arranged in rows and columns — written as m×n where m is rows and n is columns.
  • *You can only add or subtract matrices with the same dimensions — just add the corresponding entries.
  • *Matrix multiplication requires the inner dimensions to match: A(m×n) × B(n×p) = C(m×p). It’s not commutative — A×B ≠ B×A in general.
  • *The determinant of a 2×2 matrix [[a,b],[c,d]] is simply ad − bc.

What Is a Matrix?

A matrix is a rectangular grid of numbers, symbols, or expressions arranged in rows and columns. Mathematicians write it using bracket notation, with the size described as m×n, where m is the number of rows and n is the number of columns.

For example, this is a 2×3 matrix (2 rows, 3 columns):

472
159

A square matrixhas the same number of rows and columns (2×2, 3×3, etc.). Square matrices are especially important because only square matrices can have determinants and inverses.

Matrix algebra was formalized by the mathematician Arthur Cayley in 1858 in his landmark paper “A Memoir on the Theory of Matrices” (source: MacTutor History of Mathematics, University of St Andrews). Before Cayley’s work, mathematicians had been solving systems of linear equations for centuries without a compact notation. Cayley’s insight — treating the entire array as a single mathematical object — transformed the field.

Matrix Addition and Subtraction

Adding two matrices is the simplest operation. The rule: both matrices must have identical dimensions. You add (or subtract) each pair of corresponding entries.

Worked Example: 2×2 Addition

Let A = [[2, 3], [5, 1]] and B = [[1, 4], [2, 6]].

Matrix AMatrix BA + B
2   31   43   7
5   12   67   7

Position by position: (2+1)=3, (3+4)=7, (5+2)=7, (1+6)=7. Result: [[3, 7], [7, 7]].

Subtraction works identically — just subtract each entry. A 2×3 matrix cannot be added to a 3×2 matrix, even though both contain 6 entries. The shape must match exactly.

Matrix Multiplication

Matrix multiplication is more involved. The key rule: to multiply A(m×n) by B(n×p), the number of columns in A must equal the number of rows in B. The result is a matrix C of size m×p.

Each entry C[i][j] is the dot product of row i from A and column j from B: multiply corresponding entries and sum them all.

Worked Example: 2×2 Multiplication

Using the same A = [[2, 3], [5, 1]] and B = [[1, 4], [2, 6]]:

EntryCalculationResult
C[1][1]2×1 + 3×28
C[1][2]2×4 + 3×626
C[2][1]5×1 + 1×27
C[2][2]5×4 + 1×626

So A×B = [[8, 26], [7, 26]].

The Dimension Rule in Action

Consider multiplying a 2×3 matrix A by a 3×2 matrix B. The inner dimensions are both 3, so multiplication is valid. The result is 2×2.

A (2×3)B (3×2)C = A×B (2×2)
1   2   37   8Computed below
4   5   69   10
11   12

C[1][1] = 1×7 + 2×9 + 3×11 = 7 + 18 + 33 = 58. You get the pattern — each output entry requires summing three products.

One critical point: matrix multiplication is not commutative. A×B usually does not equal B×A. In some cases B×A isn’t even defined. This is a common source of errors — order matters.

The Determinant

The determinant is a single number derived from a square matrix. It encodes important properties: whether the matrix is invertible, how it scales areas or volumes, and more.

Determinant of a 2×2 Matrix

For A = [[a, b], [c, d]], the determinant is:

det(A) = ad − bc

Worked example: A = [[3, 2], [1, 4]].

det(A) = 3×4 − 2×1 = 12 − 2 = 10

If det(A) = 0, the matrix is called singular— it has no inverse, and the system of equations it represents has either no solution or infinitely many.

Determinant of a 3×3 Matrix (Cofactor Expansion)

For a 3×3 matrix, you expand along the first row using cofactors:

det([[a, b, c], [d, e, f], [g, h, i]]) = a(ei − fh) − b(di − fg) + c(dh − eg)

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

det(A) = 1(5×9 − 6×8) − 2(4×9 − 6×7) + 3(4×8 − 5×7)
= 1(45 − 48) − 2(36 − 42) + 3(32 − 35)
= 1(−3) − 2(−6) + 3(−3)
= −3 + 12 − 9 = 0

A determinant of zero means this particular matrix is singular — the rows are linearly dependent (row 3 = row 1 + 2×row 2 here, which is why).

The Inverse of a 2×2 Matrix

The inverse of matrix A is written A¹ and satisfies A×A¹ = I (the identity matrix). It only exists when det(A) ≠ 0.

For A = [[a, b], [c, d]]:

A¹ = (1/det(A)) × [[d, −b], [−c, a]]

Using our earlier example, A = [[3, 2], [1, 4]] with det(A) = 10:

A¹ = (1/10) × [[4, −2], [−1, 3]] = [[0.4, −0.2], [−0.1, 0.3]]

You can verify: multiply A by A¹ and you should get [[1, 0], [0, 1]].

The Identity Matrix

The identity matrix I is the matrix equivalent of the number 1. It’s square, with 1s on the main diagonal and 0s everywhere else. For any compatible matrix A:

A × I = I × A = A

The 3×3 identity matrix looks like this:

100
010
001

Real-World Applications of Matrices

Artificial Intelligence and Machine Learning

Modern AI runs on matrices. Every neural network layer is a matrix multiplication followed by a non-linear activation. According to technical papers from DeepMind and OpenAI, a GPT-style language model with billions of parameters performs trillions of matrix multiplications per training step. The weights connecting one layer to the next are stored as matrices, and the forward pass — computing the model’s output — is fundamentally a chain of matrix products.

LAPACK (Linear Algebra PACKage), the standard software library for numerical matrix computations, underpins NumPy, MATLAB, and R. When you call numpy.matmul()in Python, you’re invoking highly optimized LAPACK and BLAS routines written in Fortran and C (source: LAPACK documentation, University of Tennessee).

Search Engines

Google’s original PageRank algorithm — which ranked web pages by the structure of links between them — is fundamentally a matrix eigenvector problem. The entire web is represented as a massive matrix, and the rank of each page is the corresponding entry in the principal eigenvector of that matrix (source: Page, Brin, Motwani, Winograd, 1998, Stanford University technical report “The PageRank Citation Ranking: Bringing Order to the Web”). Without matrix algebra, modern search wouldn’t exist.

Computer Graphics and Game Engines

Every rotation, translation, scaling, and perspective projection in 3D graphics is a matrix operation. When a game engine renders a scene at 60 frames per second, the GPU is applying transformation matrices to millions of vertices per frame. A 4×4 homogeneous transformation matrix can encode rotation, translation, and scaling all at once, which is why graphics pipelines are built around matrix math.

Engineering and Physics

Structural engineers use matrices to model forces across trusses and frames. Electrical engineers write circuit equations as matrix systems to solve for voltages and currents simultaneously. Quantum mechanics describes the state of particles using vectors and transforms them with matrices called operators.

Economics and Data Science

According to the Bureau of Labor Statistics (2025), mathematicians and statisticians hold approximately 30,000 jobsin the United States, with a projected 28% growth rate through 2033 — much faster than average. The skills driving that demand are largely matrix-based: linear regression, principal component analysis, covariance matrices, and graph theory all rely heavily on matrix operations.

Common Mistakes to Avoid

Assuming Multiplication Is Commutative

The most frequent error. A×B and B×A are usually different matrices — and often one of them isn’t even defined. Always check the order before multiplying.

Mismatching Dimensions for Addition

You can only add matrices of identical size. A 2×3 and a 3×2 matrix cannot be added, even though both contain 6 entries. The shape must be exactly the same.

Forgetting the Inner Dimension Rule for Multiplication

To multiply A(m×n) by B(p×q), you need n = p. If the inner dimensions don’t match, the operation is undefined. The resulting matrix has dimensions m×q.

Dividing Matrices

There is no matrix division. Instead, you multiply by the inverse: A/B is written A×B¹. And B¹ only exists when det(B) ≠ 0. This is a frequent conceptual stumbling block for people new to linear algebra.

Work through matrix operations step by step

Use our free Matrix Calculator →

Frequently Asked Questions

How do you multiply two matrices?

To multiply matrix A (m×n) by matrix B (n×p), each entry C[i][j] equals the dot product of row i from A and column j from B — multiply corresponding entries and sum. For example, A = [[2,3],[5,1]] times B = [[1,4],[2,6]] gives C[1][1] = 2×1 + 3×2 = 8, C[1][2] = 2×4 + 3×6 = 26, C[2][1] = 5×1 + 1×2 = 7, C[2][2] = 5×4 + 1×6 = 26. Result: [[8,26],[7,26]].

What is the determinant of a 2×2 matrix?

For a 2×2 matrix [[a,b],[c,d]], the determinant is ad − bc. For A = [[3,2],[1,4]], det(A) = 3×4 − 2×1 = 12 − 2 = 10. If the determinant equals zero, the matrix is singular and has no inverse.

When can you add two matrices?

Only when they share the same dimensions — same number of rows and same number of columns. You add entry by entry: (A+B)[i][j] = A[i][j] + B[i][j]. A 2×3 matrix cannot be added to a 3×2 matrix even though both have 6 entries.

What is the identity matrix?

The identity matrix I is the square matrix with 1s on the main diagonal and 0s everywhere else. It acts like the number 1: A×I = I×A = A for any compatible matrix A. The 2×2 identity is [[1,0],[0,1]] and the 3×3 identity is [[1,0,0],[0,1,0],[0,0,1]].

How do you find the inverse of a 2×2 matrix?

For A = [[a,b],[c,d]] with det(A) = ad − bc ≠ 0: swap a and d, negate b and c, then divide every entry by det(A). So A¹ = (1/det(A)) × [[d,−b],[−c,a]]. For A = [[3,2],[1,4]] with det = 10, A¹ = [[0.4,−0.2],[−0.1,0.3]]. If det = 0, no inverse exists.

What are matrices used for in real life?

Matrices are everywhere. In computer graphics, a 4×4 transformation matrix handles every rotation, translation, and scaling in 3D rendering. In machine learning, neural network layers are matrix multiplications — a large language model performs trillions of them per training step. Google’s original PageRank algorithm computed the principal eigenvector of the web’s link matrix to rank pages. Engineers use matrices to solve systems of equations in circuit analysis and structural mechanics. Wherever multiple interacting quantities exist, matrix algebra provides the framework.