Xerobit

Matrix Calculator for Addition, Multiplication and Inverses

This matrix calculator performs addition, subtraction, multiplication, determinant and inverse operations on 2x2 and 3x3 matrices. Enter your values as rows separated by spaces, pick an operation, and see the result immediately. All math runs locally in your browser without uploading any data.

Enter rows separated by newlines, elements by spaces or commas. Supports 2x2 and 3x3.

Required for add, subtract and multiply. Must match dimensions of A.

Result

19 22
43 50

How to use the matrix calculator

  1. Enter Matrix A with one row per line and elements separated by spaces or commas.
  2. Select the desired operation from the dropdown menu.
  3. If the operation requires it, enter Matrix B with matching dimensions.
  4. The result updates automatically below the inputs.

How matrix multiplication works

Matrix multiplication combines rows of the first matrix with columns of the second. For two 2x2 matrices, the element at row i and column j is the sum of products of corresponding entries.

Given A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], the top-left entry of the product is computed as: 1*5 + 2*7 = 19. The top-right entry is 1*6 + 2*8 = 22. Repeating this for every row-column pair yields the full result matrix [[19, 22], [43, 50]].

A key rule is that the number of columns in Matrix A must equal the number of rows in Matrix B. This matrix calculator enforces that constraint and only supports square 2x2 and 3x3 matrices to keep input straightforward.

Computing the determinant

The determinant is a single scalar value derived from a square matrix. It tells you whether the matrix has an inverse: if the determinant is zero, the matrix is singular and no inverse exists.

For a 2x2 matrix [[a, b], [c, d]], the formula is a*d - b*c. For example, the determinant of [[1, 2], [3, 4]] is 1*4 - 2*3 = -2.

For a 3x3 matrix, the determinant expands along the first row using cofactors. Given [[a, b, c], [d, e, f], [g, h, i]], the formula is a(ei - fh) - b(di - fg) + c(dh - eg). The matrix above [[1, 2, 3], [0, 1, 4], [5, 6, 0]] gives 1(0 - 24) - 2(0 - 20) + 3(0 - 5) = -24 + 40 - 15 = 1.

Finding the inverse matrix

The inverse of a matrix A, written as A-1, satisfies the equation A * A-1 = I, where I is the identity matrix. Not all matrices have inverses; only those with a nonzero determinant are invertible.

For a 2x2 matrix [[a, b], [c, d]], the inverse is computed by swapping a and d, negating b and c, then dividing every element by the determinant:

StepFormula
Swap diagonal[[d, -b], [-c, a]]
Divide by det(1 / (ad - bc)) * swapped matrix

For 3x3 matrices, the process involves computing the matrix of cofactors, transposing it to get the adjugate, and dividing by the determinant. This matrix calculator handles both sizes automatically.

Common input formats

You can type matrices in several ways. Each row goes on its own line, and elements within a row can be separated by spaces, tabs or commas. Here are equivalent ways to enter a 2x2 matrix:

FormatExample
Space-separated1 2
3 4
Comma-separated1,2
3,4
Mixed1, 2
3 4

Negative numbers and decimals work as expected. Just type them normally, such as -3.5 0.2. Avoid brackets, pipes or other decorative characters since the parser reads only numeric tokens.

Practical uses for matrix operations

Matrices appear across many fields. In computer graphics, transformation matrices rotate, scale and translate objects in 2D and 3D space. Multiplying a coordinate vector by a rotation matrix changes its orientation without altering its length.

In engineering, systems of linear equations are often expressed as matrix equations. Solving these systems requires computing inverses or determinants, which is exactly what this matrix calculator provides. Students studying linear algebra use these operations to verify hand-computed homework answers quickly.

Data science also relies on matrices. Covariance matrices, weight matrices in neural networks and transition matrices in Markov chains all require addition, multiplication and inversion. Having a fast tool to check small examples saves time before writing code for larger datasets.

Worked examples

Each result below was produced by the same code the tool runs, so you can check your own numbers against them.

ExampleInputResult
Multiply two 2x2 matricesMatrix A: 1 2 / 3 4; Operation: multiply; Matrix B: 5 6 / 7 819 22 / 43 50
Determinant of a 3x3 matrixMatrix A: 1 2 3 / 0 1 4 / 5 6 0; Operation: determinant1
Inverse of a 2x2 matrixMatrix A: 4 7 / 2 6; Operation: inverse0.6 -0.7 / -0.2 0.4
Add two 2x2 matricesMatrix A: 1 2 / 3 4; Operation: add; Matrix B: 5 6 / 7 86 8 / 10 12

FAQ

What matrix sizes does this calculator support?

It supports 2x2 and 3x3 square matrices. Both Matrix A and Matrix B must be the same size for addition, subtraction and multiplication.

Why do I get an error when computing the inverse?

A matrix only has an inverse if its determinant is not zero. If the determinant is zero, the matrix is called singular and cannot be inverted.

Can I use decimals and negative numbers?

Yes. Enter decimals like 3.14 and negatives like -5 directly. Separate each element with a space or comma.

Is my data sent to a server?

No. This matrix calculator runs entirely in your browser. Nothing you type is uploaded anywhere.

How is matrix multiplication different from element-wise multiplication?

Matrix multiplication follows the dot-product rule where rows of the first matrix combine with columns of the second. Element-wise multiplication simply multiplies matching positions, which is not what standard linear algebra uses.

What happens if I leave Matrix B empty?

Operations that need two matrices (add, subtract, multiply) will show an error. Single-matrix operations like determinant and inverse work fine without Matrix B.