# Matrix arithmetics

Matrix arithmetics are defined for addition, subtraction and multiplication. For the two former the matrices must have equal dimensions and the operations are commutative. Multiplication is however not commutative, and is only defined for when the number of rows of the left matrix is equal to the number of columns of the right matrix. ## Intro

A pixel refers to a small region on your screen represented by three numbers between 0 and 255 that indicate the intensity of the red, green, and blue component respectively.

We use pixels to form digital images, and to change the appearance of a picture, we tweak the values of its pixels. Setting the colors to similar values produces a gray-scale image and increasing or decreasing them will result in a lighter or darker appearance respectively.

By changing the intensity of the three components of the constituent pixels, there are endless other ways in which images can be manipulated to enhance certain features. Matrix arithmetic allows us to do so effectively.

Consequently, it is the part of mathematics to thank for the filters that make your Instagram posts look amazing.

## Concept

As with vectors, operations on matrices are done, element-by-element, in different ways. There is in fact a strong connection between vectors and matrices.

A vector can be considered a matrix with only one row or column, making it a row vector or a column vector.

A matrix is a collection of vectors, and matrix operations are similar to vector operations

Conversely, matrices can be viewed as a collection of either row or column vectors attached vertically or horizontally respectively.

In light of this, we can apply what we know about vector operations to matrix arithmetic.

## Math

Addition and subtraction of two matrices and is straightforward. All elements are simply added or subtracted to the elements in the corresponding position.

Matrix multiplication is slightly more verbose, but not particularly hard. Lets return to the connection with vectors. To obtain the element in the row and column of the product , we take the dot product of row of with column of .

## Matrix arithmetics

### Definition of a matrix

A matrix is a rectangular list of numbers, called elements. Each matrix has rows and columns and its size is called (read "m times n"). Here are a few examples:

Furthermore, matrices are usually noted as integers (A, B, C, etc.). Let the matrix A be a -matrix. Each element and its i.d. (position in the matrix) are usually noted as in the following way:

Summation of matrices can only take place elementally and if the matricies have the same dimensions. Let both and be a pair of -matrices, and that and that then it applies that;

Here we have two examples:

### Scalar multiplication

Let be an -matrix. Then the following applies to all vectors and in and each scalar :

Scalar multiplication with a matrix works intuitively. Let be a -matrix summed times. Then it applies that:

and for each element in it applies that:

### Matrix multiplication

In order for the multiplication between two matrices to be defined, it is required that the number of columns of the left matrix must correspond to the number of rows of the right matrix. That is, the dimensions of the result matrix are the number of rows of the left matrix times the number of columns of the right matrix. In other words:

But what will be the result matrix of ? We show the simplest multiplication between matrix and vector :

Let's take an example:

We know from the above that the dimensions of the result of become and the result is:

Let's take another example of matrix multiplication where has an additional column and thus is noted as the matrix :

We know from the above that the dimensions of the result of become . The result is:

On a general basis, we conclude that the product of two matrices, and , is calculated by multiplying the rows of with the columns of . So the result is:

where the elements of the matrix become:

### Inner and outer products

In linear algebra, we talk about inner and outer products between two vectors of the same dimension, and . These two are defined as follows:

• inner product: , i.e. a scalar

• outer product: , a matrix

Take the following example, let:

Then it applies that the inner and outer product are:

### Identity, inverse and transpose

The student needs to be aware of the following matrices that we deal with in this section:

• (the identity matrix)

• (the inverse of )

• (the transpose of )

#### The identity matrix

above refers to the identity matrix, which can be seen as a multidimensional one, an -matrix where all elements are 0 except the diagonal elements, which are all 1.

The identity matrix functions as 1 being the identity operator for all numbers:

namely that:

Note here that multiplication by is commutative.

#### Inverse

The identity matrix also causes the existence of an inverse matrix, noted as . The following property applies:

If is a multidimensional one, then can be seen as , even if that operation is mathematically illegal.

#### Transpose

Last but not least, we have the transpose of , which is noted . It can be seen as a rotation of , where its rows become columns, as follows:

### The laws of matrix arithmetic

The following laws apply to matrix addition;

• (commutative law)

• (associative law)

#### Laws of multiplication

Note that the commutative law does not apply to matrix multiplication, i.e.:

However, the following laws do apply:

• (associative law)

• (distributive law)

• (identity)

• (linearity)

• (linearity)

## Trace

For a square matrix , the trace of is the sum of the diagonals and is called . As an example, we take:

In general therefore, for each square matrix , the trace is defined as follows:

The laws for the trace of a square matrix are:  