CalcNova Sign in

Matrix Calculator

AdSense Space (In-Article Fluid)
AdSense Space (300x250)

What is a Matrix?

A matrix, in a mathematical context, is a rectangular array of numbers, symbols, or expressions that are arranged in rows and columns. Matrices are often used in scientific fields such as physics, computer graphics, probability theory, statistics, calculus, numerical analysis, and more.

The dimensions of a matrix A are typically denoted as m × n. This means that A has m rows and n columns. When referring to a specific value in a matrix, called an element, a variable with two subscripts is often used to denote each element based on its position in the matrix. For example, given ai,j, where i = 1 and j = 3, a1,3 is the value of the element in the first row and the third column of the given matrix.

Matrix operations such as addition, multiplication, subtraction, etc., are similar to what most people are likely accustomed to seeing in basic arithmetic and algebra, but do differ in some ways, and are subject to certain constraints. Below are descriptions of the matrix operations that this calculator can perform.

Matrix addition

Matrix addition can only be performed on matrices of the same size. This means that you can only add matrices if both matrices are m × n. For example, you can add two or more 3 × 3, 1 × 2, or 5 × 4 matrices. You cannot add a 2 × 3 and a 3 × 2 matrix, a 4 × 4 and a 3 × 3, etc. The number of rows and columns of all the matrices being added must exactly match.

If the matrices are the same size, matrix addition is performed by adding the corresponding elements in the matrices. For example, given two matrices, A and B, with elements ai,j and bi,j, the matrices are added by adding each element, then placing the result in a new matrix, C, in the corresponding position in the matrix:

A =
12
34
; B =
56
78

In the above matrices, a1,1 = 1; a1,2 = 2; b1,1 = 5; b1,2 = 6; etc. We add the corresponding elements to obtain ci,j. Adding the values in the corresponding rows and columns:

a1,1 + b1,1 = 1 + 5 = 6 = c1,1
a1,2 + b1,2 = 2 + 6 = 8 = c1,2
a2,1 + b2,1 = 3 + 7 = 10 = c2,1
a2,2 + b2,2 = 4 + 8 = 12 = c2,2

Thus, matrix C is:

C =
68
1012

Matrix subtraction

Matrix subtraction is performed in much the same way as matrix addition, described above, with the exception that the values are subtracted rather than added. Like matrix addition, the matrices being subtracted must be the same size. If the matrices are the same size, then matrix subtraction is performed by subtracting the elements in the corresponding rows and columns:

a1,1 − b1,1 = 1 − 5 = −4 = c1,1
a1,2 − b1,2 = 2 − 6 = −4 = c1,2
a2,1 − b2,1 = 3 − 7 = −4 = c2,1
a2,2 − b2,2 = 4 − 8 = −4 = c2,2

Thus, matrix C is:

C =
-4-4
-4-4

Matrix multiplication

Scalar multiplication: Matrices can be multiplied by a scalar value by multiplying each element in the matrix by the scalar. For example, given a matrix A and a scalar c = 5, the product of c and A is:

5 ×
12
34
=
510
1520

Matrix-matrix multiplication: Multiplying two (or more) matrices is more involved than multiplying by a scalar. In order to multiply two matrices, the number of columns in the first matrix must match the number of rows in the second matrix. For example, you can multiply a 2 × 3 matrix by a 3 × 4 matrix, but not a 2 × 3 matrix by a 4 × 3. Note that when multiplying matrices, A × B does not necessarily equal B × A. In fact, just because A can be multiplied by B doesn't mean that B can be multiplied by A.

If the matrices are the correct sizes, matrices are multiplied by performing what is known as the dot product. The dot product involves multiplying the corresponding elements in the row of the first matrix by the columns of the second matrix, and summing the result, producing a single value. The dot product then becomes the value in the corresponding row and column of the new matrix, C: c1,1 = a1,1×b1,1 + a1,2×b2,1 + a1,3×b3,1. When multiplying two matrices, the resulting matrix will have the same number of rows as the first matrix and the same number of columns as the second, so with A at 2 × 3 and B at 3 × 4, C will be a 2 × 4 matrix:

A =
121
341
; B =
5611
7811
1111

C =
202344
445188
c1,1 = 1×5 + 2×7 + 1×1 = 20
c1,2 = 1×6 + 2×8 + 1×1 = 23
c1,3 = 1×1 + 2×1 + 1×1 = 4
c1,4 = 1×1 + 2×1 + 1×1 = 4
c2,1 = 3×5 + 4×7 + 1×1 = 44
c2,2 = 3×6 + 4×8 + 1×1 = 51
c2,3 = 3×1 + 4×1 + 1×1 = 8
c2,4 = 3×1 + 4×1 + 1×1 = 8

Power of a matrix

For the intents of this calculator, "power of a matrix" means to raise a given matrix to a given power. For example, "Power of 2" for a given matrix A means A2. Exponents for matrices function in the same way as they normally do in math, except that matrix multiplication rules also apply, so only square matrices (matrices with an equal number of rows and columns) can be raised to a power. This is because a non-square matrix, A, cannot be multiplied by itself — A × A, in this case, is not possible to compute. Given:

A =
13
21

A2 = A × A =
76
47

As with exponents in other mathematical contexts, A3 would equal A × A × A, A4 would equal A × A × A × A, and so on.

Transpose of a matrix

The transpose of a matrix, typically indicated with a "T" as an exponent, is an operation that flips a matrix over its diagonal. This results in switching the row and column indices of a matrix, meaning that aij in matrix A becomes aji in AT. An m × n matrix, transposed, would therefore become an n × m matrix, as shown in the examples below:

A =
13
21
  AT =
12
31

B =
202344
445188
  BT =
2044
2351
48
48

Determinant of a matrix

The determinant of a matrix is a value that can be computed from the elements of a square matrix. It is used in linear algebra, calculus, and other mathematical contexts. For example, the determinant can be used to compute the inverse of a matrix or to solve a system of linear equations. There are a number of methods and formulas for calculating the determinant of a matrix; the Leibniz formula and the Laplace formula are two commonly used formulas.

Determinant of a 2 × 2 matrix: using the Leibniz formula, for A =

ab
cd
the determinant is |A| = ad − bc. Note that taking the determinant is typically indicated with "| |" surrounding the given matrix. Given A =
24
68
, |A| = 2×8 − 4×6 = −8.

Determinant of a 3 × 3 matrix: one way is through the Laplace formula. Expanding along the first row of

abc
def
ghi
gives |A| = a(ei − fh) − b(di − fg) + c(dh − eg), which simplifies to the Leibniz form |A| = aei + bfg + cdh − ceg − bdi − afh.

Determinant of a 4 × 4 matrix and higher: the determinant can be computed in much the same way, using the Laplace or Leibniz formula. The process cycles through each element of the first row: each element becomes a scalar multiplied by the determinant of the smaller matrix left after blocking out that element's row and column, with alternating + − + − signs. A 4 × 4 matrix reduces to scalars times 3 × 3 determinants, those to scalars times 2 × 2 determinants, and so on until the 2 × 2 Leibniz formula finishes the job. As can be seen, this gets tedious very quickly, but it is a method that can be used for n × n matrices once you understand the pattern.

Inverse of a matrix

The inverse of a matrix A is denoted as A−1, where A−1 is the inverse of A if A × A−1 = A−1 × A = I, where I is the identity matrix.

Identity matrix: The identity matrix is a square matrix with "1" across its diagonal, and "0" everywhere else. The identity matrix is the matrix equivalent of the number "1": just as 1 × n = n for any number, A × I = A for a matrix of the same size. For example, I2 =

10
01
and I3 =
100
010
001
.

Inverse of a 2 × 2 matrix: A−1 = (1 / det(A)) × the matrix formed by swapping a and d and negating b and c — that is, (1 / (ad − bc)) ×

d-b
-ca
. For example, given A =
24
37
:

A−1 = (1 / (2×7 − 4×3)) ×
7-4
-32
= (1/2) ×
7-4
-32
=
3.5-2
-1.51

If you were to test that this is, in fact, the inverse of A, you would find that both A × A−1 and A−1 × A are equal to the identity matrix I2 =

10
01
.

Inverse of a 3 × 3 matrix: The inverse of a 3 × 3 matrix is more tedious to compute. In outline, M−1 = (1 / det(M)) × the transpose of the cofactor matrix, where the cofactors of

abc
def
ghi
are A = ei − fh; B = −(di − fg); C = dh − eg; D = −(bi − ch); E = ai − cg; F = −(ah − bg); G = bf − ce; H = −(af − cd); I = ae − bd. 4 × 4 and larger get increasingly more complicated, and there are other methods for computing them.

Frequently Asked Questions

When can two matrices be added or multiplied?

Addition and subtraction require exactly the same size — the same number of rows and columns in both matrices. Multiplication AB requires the number of columns of A to equal the number of rows of B, and the result has the rows of A and the columns of B.

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

For a matrix with rows (a, b) and (c, d), the determinant is ad − bc. For example, the determinant of the matrix with rows (2, 4) and (6, 8) is 2×8 − 4×6 = −8.

When does a matrix have no inverse?

A matrix has an inverse only if it is square and its determinant is not zero. A determinant of zero means the matrix collapses space onto a lower dimension, so there is no matrix that can undo it.

What does raising a matrix to a power mean?

It means multiplying the matrix by itself that many times: A3 = A × A × A. Only square matrices can be raised to a power, because a non-square matrix cannot be multiplied by itself.