# Matrices (Pt. 4): Types

## Types of Matrices

In this page, we will be discussing on the commonly-used matrices, which serves to lead on to our ultimate discussion of *Linear Algebra*. 🎨

### Identity Matrices

An identity is like a **copy** of something.

* It may be helpful to think of identity matrices as the **"value 1"**, as any value that is multiplied with 1 *returns itself* as well
* Similarly, an identity matrix when multiplied to a matrix, **replicates** the matrix

An identity matrix is simply a matrix with the value 1 ranging diagonally from the upper-left to the bottom-right.&#x20;

It also has to be **n x n** sized, in which **n** should simply satisfy the matrix multiplication operation.&#x20;

In this case, identity matrices are **commutative** (refer to matrix multiplication properties), in which for a matrix of A and identity matrix of I:

$$
AI = IA
$$

{% hint style="info" %}
There exists a identity matrix for every possible matrix
{% endhint %}

![Identity Matrices of different orders](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-LwsXyQgmy5fC8qzr9wr%2F-LwsYELZ9A2F2NEaKAPV%2Fimage.png?alt=media\&token=722cbc14-2038-4e61-9d64-833556efacbc)

This order of identity matrices to be used should not be a big challenge. Since the non-commutative property does not apply, as long as the matrix multiplication operation passes, it should be fine.

In the example following this, the identity matrix example is acting as the **left-matrix** in the multiplication operation, and thus the multiplication will work accordingly as long as the **amount of rows** of the matrix to be applied is the same as **n**.&#x20;

![Identity Matrix performed on matrix  of different sizes](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-LwsXyQgmy5fC8qzr9wr%2F-LwsYyZnsEPc9pEPtZo8%2Fimage.png?alt=media\&token=6496ec70-c6e9-4deb-a160-84e1092bdf41)

### Permutation Matrix

The meaning of permutate is to simply *change the order or arrangement.* Hence, a permutation matrix acts to primarily **switch between either rows or columns** of a matrix.

With this, a permutation matrix is extremely similar to an identity matrix, as the interest is only in *changing the order* instead of its values.&#x20;

As to be expected a permutation matrix contains the values of 0s and 1s, but should not contain the diagonal structure an identity matrix has. However, for the structure of a permutation matrix:

* There should only be a "1" for **every** row and column

![A valid permutation matrix](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-LwseI5VnHv5ltzqcGCF%2F-Lwsj3C8LGonfyMah3qT%2Fimage.png?alt=media\&token=3c72bd80-deee-4016-978b-7490c1d4043c)

The matrix above is a valid permutation matrix as it can be seen that the value 1 exist only once for its row and column.

{% hint style="info" %}
It may help to think this as Sudoku, where there can only exist the value of "1" for both row and column.
{% endhint %}

{% tabs %}
{% tab title="Column Permutation" %}

#### Column Permutation

As would the name suggest, a column permutation matrix acts to *re-order* a matrix's columns. To differentiate itself from a row matrix, as positioning matters (non-commutative), it is positioned as a **right-matrix**.

The big question is, for what column permutation matrix is needed for a particular desired re-ordering of columns? An arbitrary scenario of swapping columns (1, 2, 3) to (2, 3, 1) will demonstrate this concept.

![Column Permutation](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-Lwsk4PMEeOFjEx71l3W%2F-LwuYmmWp1W3-KZU2lF8%2Fimage.png?alt=media\&token=6071a329-6ed3-458b-a42d-2ed51e12dc57)

For column permutation, by simply identifying the desired change, we can then draft out the required permutation matrix for such desirable change.

![Column Permutation Matrix required for such change](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-Lwuf4rkB1LPqrCfSAvl%2F-Lwughre2pCWGqeASdNt%2Fimage.png?alt=media\&token=f76e2d26-6c8c-48eb-b7fb-687c9960e53d)

Hence, to put everything together, we can perform a re-ordering of columns by placing the permutation matrix as the **right-matrix** of the operation.

![Column Permutation Operation](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-Lwsk4PMEeOFjEx71l3W%2F-LwubZ-OwiuTcJopUg6z%2Fimage.png?alt=media\&token=c3d40627-3318-435f-b391-263c2de39aae)
{% endtab %}

{% tab title="Row Permutation" %}

#### Row Permutation

Having the similar concept to a column permutation, a row permutation matrix acts to re-order the rows of a matrix. However, a row permutation matrix sits as a **left-matrix** in a multiplication operation as opposed to a column matrix. An example follows this to facilitate our discussion.

![Row Permutation](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-LwucpTDxnKKN43hDt4v%2F-LwuewajYgZWmV_m1m7n%2Fimage.png?alt=media\&token=9d242f82-6aaf-44c9-bcb6-ff9beb7c8fc8)

As contrary to column permutation, notice how the order of element identified to be required to construct the permutation matrix is reversed.

![Row Permutation Matrix required for such change](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-Lwuf4rkB1LPqrCfSAvl%2F-Lwugq-XNXSCTME7nSax%2Fimage.png?alt=media\&token=876d4d7e-8af9-4ff8-9cd2-22dd59d70a1a)

After identifying the row permutation matrix required, by placing it acting as the **left-matrix** of the operation, we will be able to create such a change.

![Row Permutation Matrix operation](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-Lwuf4rkB1LPqrCfSAvl%2F-LwuiLgwiUh_mpX11mA-%2Fimage.png?alt=media\&token=6fa9e5ca-5c4f-49b0-8a29-542278312c90)
{% endtab %}
{% endtabs %}

### **Transpose Matrix**

Very very much like permutation, except instead of **re-ordering either rows or columns**, transposition **switches rows for columns** (it is not wrong if you think it switches columns with rows as well).&#x20;

The definition of transpose is to "switch places". In this case, again, transposition of a matrix refers to *interchanging rows with columns*.&#x20;

![Transposition of Matrix A](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-Lwvmd6zkZ9f4snt_yT9%2F-LwvobvZOtGPwsNYds_g%2Fimage.png?alt=media\&token=a874e97d-46e0-44f9-83e6-e18588debbb9)

* Matrix of size (m x n) initially will have size (n x m)&#x20;
* Elements in the same row are represented as a new column (or columns are represented as a new row 💁‍♀️)

Another important thing to know is that as due to the non-commutative property of matrices, the result of the transposition of a product of matrices is the product of its transposed factors, in the reverse order.

![](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-LwfyQdV5_8_KcrcXJ7D%2F-LwfyZ68TDDSY0qznlHF%2Fimage.png?alt=media\&token=b6965d42-0497-493a-8aaf-6e104356ed3d)

Looking at RHS, through the act of both&#x20;

* Transposing itself, and
* Reversal of order of factors,

This ensures that the number of columns of the left matrix and the rows of the right matrix is the same (n).

### Inverse Matrix

The inverse of a random variable *x* looks something like this:

$$
\frac{1}{x}
$$

The above expression would be similarly re-written as:

$$
x^{\mathrm{-1}}
$$

Now, we know for a fact that

$$
x^{\mathrm{-1}}\times x=1
$$

This idea extends to matrices as well, where

$$
A^{\mathrm{-1}}\times A=I
$$

* $$A^{\mathrm{-1}}$$is the inverse of Matrix A
* A is Matrix A
* I is an identity matrix

Firstly, it might be good to mention that **not all matrices are invertible**. This is because sometimes $$A^{\mathrm{-1}}\times A=0$$instead of 1.&#x20;

However, assuming that Matrix A is indeed invertible, how would we then find $$A^{\mathrm{-1}}$$?&#x20;

We will discuss this only at elimination in Linear Algebra😎 (stay tuned!!).

![trololo](https://3978845189-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwfxeT-UMPxSGzkwagB%2F-LxB18fgJ2X0ZUb2dEQr%2F-LxB3FjRGVPqf4GPQk3C%2Fgiphy.gif?alt=media\&token=6f11ec7b-9fa1-4b75-9513-c08804612956)
