## Matrix

A matrix is a rectangular array of numbers.

The size of a matrix is its dimension, namely the number of rows and columns of the matrix.

For operations of matrices, please use the two calculators below.

To find inverse of matrix, you can also use the Gauss-Jordan Elimination method.

### Matrix Operations

#### Addition and Subtraction of Matrices

If matrices A and B are of the same size,

• the sum A + B is the matrix obtained by adding the entries of B to the corresponding entries of A.
• the difference AB is the matrix obtained by subtracting the entries of B from the corresponding entries of A.
If A =

 a11 a12 … a1n a21 a22 … a2n ⋮ ⋮ ⋱ ⋮ a41 a42 … amn

and B =

 b11 b12 … b1n b21 b22 … b2n ⋮ ⋮ ⋱ ⋮ b41 b42 … bmn

A + B =

 a11+b11 a12+b12 … a1n+b1n a21+b21 a22+b22 … a2n+b2n ⋮ ⋮ ⋱ ⋮ a41+b41 a42+b42 … amn+bmn

AB =

 a11−b11 a12−b12 … a1n−b1n a21−b21 a22−b22 … a2n−b2n ⋮ ⋮ ⋱ ⋮ a41−b41 a42−b42 … amn−bmn

Matrices of different sizes cannot be added or subtracted.

Example

A =

 1 2 0 -3

and B =

 3 1 -1 2

A + B =

 1 2 0 -3

+

 3 1 -1 2

=

 4 3 -1 -1

AB =

 1 2 0 -3

 3 1 -1 2

=

 -2 1 1 -5

#### Multiplication of Matrices

If A is an m × r matrix and B is an r × n matrix, the product AB is an m × n matrix whose entry from row i and column j is the sum of the products of the corresponding entries from row i of A and column j of B.

The entry (AB)ij in row i and column j of AB is given by

(AB)ij = ai1b1j + ai2b2j + ai3b3j + … + airbrj

Matrices A and B can only be multiplied if the number of columns of A is the same as the number of rows of B.

Example

A =

 1 2 1 0 -3 2

and B =

 3 1 0 1 -1 2 3 0 0 -2 1 1

AB =

 1 2 1 0 -3 2

 3 1 0 1 -1 2 3 0 0 -2 1 1

=

 1 3 7 2 3 -10 -7 2

• The element at row 1 and column 1 of AB is obtained from summing up the product of corresponding entries of row 1 of A and column 1 of B, i.e.
(AB)11 = (1)(3) + (2)(-1) + (1)(0) = 1
• The element at row 1 and column 2 of AB is obtained from summing up the product of corresponding entries of row 1 of A and column 2 of B, i.e.
(AB)12 = (1)(1) + (2)(2) + (1)(-2) = 3
• The element at row 2 and column 1 of AB is obtained from summing up the product of corresponding entries of row 2 of A and column 1 of B, i.e.
(AB)21 = (0)(3) + (-3)(-1) + (2)(0) = 3
• And so on

#### Inverse of a Matrix

The inverse of a square matrix A is the matrix A-1 such that A A-1 = I

For example, if

A =

 -3 2 5 -4

, then A-1 =

 -2 -1 -2.5 -1.5

because A A-1 =

 -3 2 5 -4

 -2 -1 -2.5 -1.5

=

 1 0 0 1

One way to get the inverse of a square matrix A is to use the following formula