ToolNestr

Matrix Calculator

Add, subtract, multiply, and find the determinant or inverse of matrices.

Reviewed by the ToolNestr Editorial Team — July 2026

Matrix A

×

Matrix B

×
Matrix multiplication diagram Two matrices labeled A and B with arrows from rows of A and columns of B converging into result matrix C Matrix A a₁₁a₁₂ a₂₁a₂₂ Matrix B b₁₁b₁₂ b₂₁b₂₂ Matrix C c₁₁c₁₂ c₂₁c₂₂ Row i of A × Column j of B cᵢⱼ = Σ aᵢₖ · bₖⱼ Element-wise operations (addition, subtraction) combine same-position entries. Matrix multiplication uses row-by-column dot products: cᵢⱼ = Σₖ aᵢₖ · bₖⱼ.
Matrix multiplication: each element cᵢⱼ is the dot product of row i of A and column j of B

How matrix arithmetic works

A matrix is a rectangular arrangement of numbers in rows and columns. The size of a matrix is written as rows × columns (e.g., a 2×3 matrix has 2 rows and 3 columns). Matrices are fundamental in linear algebra and appear throughout mathematics, physics, engineering, computer graphics, and data science.

Addition and subtraction are performed element-wise. Every element in the first matrix is added to or subtracted from the corresponding element in the second matrix. This requires both matrices to have identical dimensions: if A is 2×3 and B is 2×3, then A + B and A − B are both defined and result in another 2×3 matrix. For example, if A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], then A + B = [[6, 8], [10, 12]] and A − B = [[−4, −4], [−4, −4]].

Multiplication is more involved than simple element-wise operations. Given matrix A of size m × n and matrix B of size n × p, the product C = A × B is of size m × p. Each element cᵢⱼ is computed as the dot product of row i from A and column j from B:

cᵢⱼ = Σₖ aᵢₖ · bₖⱼ

The number of columns of A must equal the number of rows of B for multiplication to be valid. Matrix multiplication is not commutative: in general A × B ≠ B × A. In fact, if A is 2×3 and B is 3×2, the product A × B is 2×2 while B × A is 3×3, so they are not even the same shape.

Worked example: 2×2 matrix multiplication

Multiply A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]].

c₁₁: 1·5 + 2·7 = 5 + 14 = 19
c₁₂: 1·6 + 2·8 = 6 + 16 = 22
c₂₁: 3·5 + 4·7 = 15 + 28 = 43
c₂₂: 3·6 + 4·8 = 18 + 32 = 50

Result: C = [[19, 22], [43, 50]].

The determinant of a matrix

The determinant is a scalar value computed from a square matrix (same number of rows and columns). It is denoted as det(A) or |A|. The determinant has profound geometric meaning: it represents the volume scaling factor of the linear transformation described by the matrix. A zero determinant means the transformation collapses space into a lower dimension (the matrix is singular and not invertible).

2×2 determinant

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

det(A) = ad − bc

This is the area of the parallelogram formed by the column vectors (or row vectors) of the matrix. If det(A) = 0, the parallelogram collapses to a line or point.

3×3 determinant

For a 3×3 matrix, expand using the first row (cofactor expansion):

det(A) = a(ei − fh) − b(di − fg) + c(dh − eg)

where the elements are arranged as [[a, b, c], [d, e, f], [g, h, i]]. This corresponds to the volume of the parallelepiped formed by the three column vectors.

4×4 determinant (recursive computation)

The 4×4 determinant is computed recursively using cofactor expansion along the first row. Each 4×4 determinant breaks down into four 3×3 determinants, each of which breaks down further into 2×2 determinants. This calculator performs this recursion automatically.

Matrix inverse

The inverse of a square matrix A, denoted A⁻¹, is the matrix that satisfies A × A⁻¹ = A⁻¹ × A = I, where I is the identity matrix (ones on the diagonal and zeros elsewhere). Only square matrices with non-zero determinant are invertible. A matrix with zero determinant is called singular and has no inverse.

2×2 inverse formula

For A = [[a, b], [c, d]] with det(A) = ad − bc ≠ 0:

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

Simply swap a and d, negate b and c, then divide every entry by the determinant.

3×3 inverse via adjugate

For larger matrices, the inverse is computed using the adjugate method. The adjugate (or classical adjoint) is the transpose of the cofactor matrix. Each cofactor Cᵢⱼ = (−1)ⁱ⁺ʲ · det(Mᵢⱼ), where Mᵢⱼ is the minor — the matrix obtained by removing row i and column j. The inverse is then:

A⁻¹ = adj(A) / det(A)

This calculator applies this method for 3×3 matrices. The process involves computing nine 2×2 determinants (one for each cofactor), arranging them into the cofactor matrix, transposing to get the adjugate, and finally dividing by the determinant.

Use cases for matrix operations

🎮

3D graphics and game development

Transformation matrices are the backbone of modern 3D rendering. A 4×4 matrix can combine rotation, translation, scaling, and perspective projection into a single operation. Every vertex of a 3D model is multiplied by the model-view-projection matrix to map it onto the 2D screen. Matrix multiplication is performed millions of times per frame in modern games and rendering engines like OpenGL, DirectX, and Vulkan. The inverse of a transformation matrix is used for tasks like camera controls, ray tracing, and collision detection.

📊

Linear regression and data science

The normal equation for linear regression, θ = (XᵀX)⁻¹Xᵀy, involves matrix multiplication and inversion. The design matrix X contains the training data, and solving this equation produces the optimal parameters for a linear model. Matrix operations are also central to principal component analysis (PCA), singular value decomposition (SVD), neural network computations, and covariance matrix analysis. Libraries like NumPy, TensorFlow, and PyTorch perform these operations with highly optimised matrix multiplication routines.

⚛️

Physics simulations

Quantum mechanics represents physical states as vectors in Hilbert space and observables as Hermitian matrices (operators). The time evolution of a quantum system is described by the Schrödinger equation, which involves matrix exponentiation. In classical physics, the moment of inertia tensor is a 3×3 matrix that relates angular momentum to angular velocity. Finite element analysis (FEA) uses large sparse matrices to simulate stress, strain, and heat distribution in physical objects. Solving these systems requires matrix inversion and decomposition at scale.

💰

Economics and finance

Input-output models in economics use large matrices to represent the interdependencies between different sectors of an economy. Leontief's input-output model solves x = (I − A)⁻¹d, where A is the technology matrix and d is the final demand vector. In finance, the covariance matrix of asset returns is central to modern portfolio theory (Markowitz efficient frontier). Markowitz optimisation finds the portfolio weights that minimise risk for a given return by solving linear systems involving the covariance matrix and its inverse.

Properties of matrix operations

PropertyFormulaDescription
Associative(AB)C = A(BC)Order of grouping does not matter in multiplication
DistributiveA(B + C) = AB + ACMultiplication distributes over addition
Non-commutativeAB ≠ BASwapping factors changes the result
IdentityAI = IA = AMultiplying by the identity leaves A unchanged
Inverse propertyAA⁻¹ = IA matrix times its inverse yields identity
Transpose of product(AB)ᵀ = BᵀAᵀTranspose reverses the multiplication order
Determinant of productdet(AB) = det(A)det(B)Determinant of a product is the product of determinants

Related tools

Frequently asked questions

What size matrices are supported?

Up to 4×4. Larger matrices are computationally intensive for browser-side computation.

Can I multiply non-square matrices?

Yes — as long as the number of columns of A equals the number of rows of B.

What is the determinant?

A scalar value computed from a square matrix that indicates whether it is invertible (det ≠ 0).

What is the inverse?

A⁻¹ such that A × A⁻¹ = I. Only square matrices with non-zero determinant have an inverse.

All tool categories

Math (23 tools)
🌐 Networking & IP Tools (36 tools)
🧮 Everyday (26 tools)
💪 Health & Fitness (30 tools)
💰 Finance (34 tools)
📄 PDF Tools (10 tools)
🎨 Creators (12 tools)
💻 Developers (24 tools)
⚡ Engineering & Science (24 tools)
⚛️ Physics (48 tools)
🧪 Chemistry (50 tools)
🧬 Biology (50 tools)
🏠 Construction & Home Improvement (105 tools)
👗 Clothing & Garment Tools (68 tools)
🍳 Cooking & Baking (9 tools)
🚗 Automotive (26 tools)
🖼️ Image Tools (13 tools)
🔐 Security & Hash (15 tools)
📝 Text Tools (15 tools)
🔍 SEO Tools (11 tools)
🔄 Converters (69 tools)
🕐 Time & Date (15 tools)
📊 Chart Generators (11 tools)
🕌 Islamic Tools (16 tools)