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 a_{i,j}, where i = 1 and j = 3, a_{1,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 a_{i,j}, and b_{i,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 =
1
2
3
4
; B =
5
6
7
8
In the above matrices, a_{1,1} = 1; a_{1,2} = 2; b_{1,1} = 5; b_{1,2} = 6; etc. We add the corresponding elements to obtain c_{i,j}. Adding the values in the corresponding rows and columns:
a_{1,1} + b_{1,1} = 1 + 5 = 6 = c_{1,1}
a_{1,2} + b_{1,2} = 2 + 6 = 8 = c_{1,2}
a_{2,1} + b_{2,1} = 3 + 7 = 10 = c_{2,1}
a_{2,2} + b_{2,2} = 4 + 8 = 12 = c_{2,2}
Thus, matrix C is:
C =
6
8
10
12
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. If necessary, refer to the information and examples above for a description of notation used in the example below. 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:
A =
1
2
3
4
; B =
5
6
7
8
a_{1,1} - b_{1,1} = 1 - 5 = -4 = c_{1,1}
a_{1,2} - b_{1,2} = 2 - 6 = -4 = c_{1,2}
a_{2,1} - b_{2,1} = 3 - 7 = -4 = c_{2,1}
a_{2,2} - b_{2,2} = 4 - 8 = -4 = c_{2,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:
A =
1
2
3
4
; c = 5
The product of c and A is:
5 ×
1
2
3
4
=
5
10
15
20
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.
Can be multiplied:
A =
a_{1,1}
a_{1,2}
a_{1,3}
a_{2,1}
a_{2,2}
a_{2,3}
; B =
b_{1,1}
b_{1,2}
b_{1,3}
b_{1,4}
b_{2,1}
b_{2,2}
b_{2,3}
b_{2,4}
b_{3,1}
b_{3,2}
b_{3,3}
b_{3,4}
Cannot be multiplied:
A =
a_{1,1}
a_{1,2}
a_{1,3}
a_{2,1}
a_{2,2}
a_{2,3}
; B =
b_{1,1}
b_{1,2}
b_{1,3}
b_{2,1}
b_{2,2}
b_{2,3}
b_{3,1}
b_{3,2}
b_{3,3}
b_{4,1}
b_{4,2}
b_{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, and can be multiplied, 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 that of the columns of the second matrix, and summing up the result, resulting in a single value. The dot product can only be performed on sequences of equal lengths. This is why the number of columns in the first matrix must match the number of rows of the second.
The dot product then becomes the value in the corresponding row and column of the new matrix, C. For example, from the section above of matrices that can be multiplied, the blue row in A is multiplied by the blue column in B to determine the value in the first column of the first row of matrix C. This is referred to as the dot product of row 1 of A and column 1 of B:
The dot product is performed for each row of A and each column of B until all combinations of the two are complete in order to find the value of the corresponding elements in matrix C. For example, when you perform the dot product of row 1 of A and column 1 of B, the result will be c_{1,1} of matrix C. The dot product of row 1 of A and column 2 of B will be c_{1,2} of matrix C, and so on, as shown in the example below:
A =
1
2
1
3
4
1
; B =
5
6
1
1
7
8
1
1
1
1
1
1
When multiplying two matrices, the resulting matrix will have the same number of rows as the first matrix, in this case A, and the same number of columns as the second matrix, B. Since A is 2 × 3 and B is 3 × 4, C will be a 2 × 4 matrix. The colors here can help determine first, whether two matrices can be multiplied, and second, the dimensions of the resulting matrix. Next, we can determine the element values of C by performing the dot products of each row and column, as shown below:
C =
20
23
4
4
44
51
8
8
Below, the calculation of the dot product for each row and column of C is shown:
c_{1,1} = 1×5 + 2×7 + 1×1 = 20
c_{1,2} = 1×6 + 2×8 + 1×1 = 23
c_{1,3} = 1×1 + 2×1 + 1×1 = 4
c_{1,4} = 1×1 + 2×1 + 1×1 = 4
c_{2,1} = 3×5 + 4×7 + 1×1 = 44
c_{2,2} = 3×6 + 4×8 + 1×1 = 51
c_{2,3} = 3×1 + 4×1 + 1×1 = 8
c_{2,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, when using the calculator, "Power of 2" for a given matrix, A, means A^{2}. 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. Refer to the matrix multiplication section, if necessary, for a refresher on how to multiply matrices. Given:
A =
1
3
2
1
A raised to the power of 2 is:
A^{2} =
1
3
2
1
^{2}
=
1
3
2
1
×
1
3
2
1
=
7
6
4
7
As with exponents in other mathematical contexts, A^{3}, would equal A × A × A, A^{4} 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 a_{ij} in matrix A, becomes a_{ji} in A^{T}. If necessary, refer above for a description of the notation used.
An m × n matrix, transposed, would therefore become an n × m matrix, as shown in the examples below:
A =
1
3
2
1
A^{T} =
1
2
3
1
B =
20
23
4
4
44
51
8
8
B^{T} =
20
44
23
51
4
8
4
8
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:
The determinant of a 2 × 2 matrix can be calculated using the Leibniz formula, which involves some basic arithmetic. Given matrix A:
A =
a
b
c
d
The determinant of A using the Leibniz formula is:
|A| =
a
b
c
d
= ad - bc
Note that taking the determinant is typically indicated with "| |" surrounding the given matrix. Given:
A =
2
4
6
8
|A| =
2
4
6
8
=
2×8 - 4×6
=
-8
Determinant of a 3 × 3 matrix:
One way to calculate the determinant of a 3 × 3 matrix is through the use of the Laplace formula. Both the Laplace formula and the Leibniz formula can be represented mathematically, but involve the use of notations and concepts that won't be discussed here. Below is an example of how to use the Laplace formula to compute the determinant of a 3 × 3 matrix:
|A| =
a
b
c
d
e
f
g
h
i
=
a
e
f
h
i
- b
d
f
g
i
+ c
d
e
g
h
From this point, we can use the Leibniz formula for a 2 × 2 matrix to calculate the determinant of the 2 × 2 matrices, and since scalar multiplication of a matrix just involves multiplying all values of the matrix by the scalar, we can multiply the determinant of the 2 × 2 by the scalar as follows:
|A| =
a
b
c
d
e
f
g
h
i
=
a(ei-fh) - b(di-fg) + c(dh-eg)
This can further be simplified to:
|A| = aei + bfg + cdh - ceg - bdi - afh
This is the Leibniz formula for a 3 × 3 matrix.
Determinant of a 4 × 4 matrix and higher:
The determinant of a 4 × 4 matrix and higher can be computed in much the same way as that of a 3 × 3, using the Laplace formula or the Leibniz formula. As with the example above with 3 × 3 matrices, you may notice a pattern that essentially allows you to "reduce" the given matrix into a scalar multiplied by the determinant of a matrix of reduced dimensions, i.e. a 4 × 4 being reduced to a series of scalars multiplied by 3 × 3 matrices, where each subsequent pair of scalar × reduced matrix has alternating positive and negative signs (i.e. they are added or subtracted).
The process involves cycling through each element in the first row of the matrix. Eventually, we will end up with an expression in which each element in the first row will be multiplied by a lower-dimension (than the original) matrix. The elements of the lower-dimension matrix is determined by blocking out the row and column that the chosen scalar are a part of, and having the remaining elements comprise the lower dimension matrix. Refer to the example below for clarification.
Here, we first choose element a. The elements in blue are the scalar, a, and the elements that will be part of the 3 × 3 matrix we need to find the determinant of:
|A| =
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
=
a
f
g
h
j
k
l
n
o
p
- ...
Next, we choose element b:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
⇒
b
e
g
h
i
k
l
m
o
p
Continuing in the same manner for elements c and d, and alternating the sign (+ - + - ...) of each term:
|A| =
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
=
a
f
g
h
j
k
l
n
o
p
- b
e
g
h
i
k
l
m
o
p
+ c
e
f
h
i
j
l
m
n
p
- d
e
f
g
i
j
k
m
n
o
We continue the process as we would a 3 × 3 matrix (shown above), until we have reduced the 4 × 4 matrix to a scalar multiplied by a 2 × 2 matrix, which we can calculate the determinant of using Leibniz's formula. As can be seen, this gets tedious very quickly, but it is a method that can be used for n × n matrices once you have an understanding of the pattern. There are other ways to compute the determinant of a matrix that can be more efficient, but require an understanding of other mathematical concepts and notations.
Inverse of a matrix
The inverse of a matrix A is denoted as A^{-1}, where A^{-1} is the inverse of A if the following is true:
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." For example, the number 1 multiplied by any number n equals n. The same is true of an identity matrix multiplied by a matrix of the same size: A × I = A. Note that an identity matrix can have any square dimensions. For example, all of the matrices below are identity matrices. From left to right respectively, the matrices below are a 2 × 2, 3 × 3, and 4 × 4 identity matrix:
1
0
0
1
;
1
0
0
0
1
0
0
0
1
;
1
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
...
The n × n identity matrix is thus:
I_{n} =
1
0
0
...
0
0
1
0
...
0
0
0
1
...
0
...
...
...
...
...
0
0
0
...
1
Inverse of a 2 × 2 matrix:
To invert a 2 × 2 matrix, the following equation can be used:
A^{-1} =
a
b
c
d
^{-1}
=
1
d
-b
-c
a
det(A)
=
1
d
-b
-c
a
ad - bc
For example, given:
A =
2
4
3
7
A^{-1} =
1
7
-4
-3
2
2×7 - 4×3
=
1
7
-4
-3
2
2
=
3.5
-2
-1.5
1
If you were to test that this is, in fact, the inverse of A you would find that both:
2
4
3
7
×
3.5
-2
-1.5
1
and
3.5
-2
-1.5
1
×
2
4
3
7
are equal to the identity matrix:
I =
1
0
0
1
Inverse of a 3 × 3 matrix:
The inverse of a 3 × 3 matrix is more tedious to compute. An equation for doing so is provided below, but will not be computed. Given: