Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Jul 14, 2024
1 parent b604db7 commit 64c0c33
Showing 1 changed file with 46 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,19 @@ r = np.cross(p, q) # [-8 5 1]

A matrix is an array of numbers that are arranged into rows and columns.

```bash
A = [
1 2 3
4 5 6
]
```
<BlockMath>{`\\begin{equation}A = \\begin{bmatrix}
1 & 2 & 3 \\\\
4 & 5 & 6
\\end{bmatrix}
\\end{equation}`}</BlockMath>

This is how you indicate each element in the matrix:

```bash
A = [
a₁,₁ a₁,₂ a₁,₃
a₂,₁ a₂,₂ a₂,₃
]
```
<BlockMath>{`\\begin{equation}A = \\begin{bmatrix}
a_{1,1} & a_{1,2} & a_{1,3} \\\\
a_{2,1} & a_{2,2} & a_{2,3}
\\end{bmatrix}
\\end{equation}`}</BlockMath>

In Python, we can define the matrix as a 2-dimensional array:

Expand All @@ -282,21 +280,17 @@ A = np.array([[1,2,3],

To add two matrices of the same size together, just add the corresponding elements in each matrix:

```bash
[ [ [
1 2 3 + 6 5 4 = 7 7 7
4 5 6 3 2 1 7 7 7
] ] ]
```
<BlockMath>
{`\\begin{equation}\\begin{bmatrix}1 & 2 & 3 \\\\4 & 5 & 6\\end{bmatrix}+ \\begin{bmatrix}6 & 5 & 4 \\\\3 & 2 & 1\\end{bmatrix} = \\begin{bmatrix}7 & 7 & 7 \\\\7 & 7 & 7\\end{bmatrix}\\end{equation}`}
</BlockMath>

Here's how we calculate it:

```bash
[
a₁,₁ + b₁,₁, a₁,₂ + b₁,₂, a₁,₃ + b₁,₃
a₂,₁ + b₂,₁, a₂,₂ + b₂,₂, a₂,₃ + b₂,₃
]
```
<BlockMath>{`\\begin{equation}A = \\begin{bmatrix}
a_{1,1} + b_{1,1} & a_{1,2} + b_{1,2} & a_{1,3} + b_{1,3} \\\\
a_{2,1} + b_{2,1} & a_{2,2} + b_{2,2} & a_{2,3} + b_{2,3}
\\end{bmatrix}
\\end{equation}`}</BlockMath>

In Python, we can just sum the two matrices:

Expand All @@ -314,26 +308,19 @@ A + B

Subtraction of two matrices works the same way:

```bash
[ [ [
1 2 3 - 6 5 4 = -5 -3 -1
4 5 6 3 2 1 1 3 5
] ] ]
```
<BlockMath>
{`\\begin{equation}\\begin{bmatrix}1 & 2 & 3 \\\\4 & 5 & 6\\end{bmatrix}- \\begin{bmatrix}6 & 5 & 4 \\\\3 & 2 & 1\\end{bmatrix} = \\begin{bmatrix}-5 & -3 & -1 \\\\1 & 3 & 5\\end{bmatrix}\\end{equation}`}
</BlockMath>

The nagative of a matrix, is just a matrix with the sign of each element reversed.

```bash
C = [
-5 -3 -1
1 3 5
]

-C = [
5 3 1
-1 -3 -5
]
```
<BlockMath>
{`\\begin{equation}C = \\begin{bmatrix}-5 & -3 & -1 \\\\1 & 3 & 5\\end{bmatrix}\\end{equation}`}
</BlockMath>

<BlockMath>
{`\\begin{equation}-C = \\begin{bmatrix}5 & 3 & 1 \\\\-1 & -3 & -5\\end{bmatrix}\\end{equation}`}
</BlockMath>

In Python, we can use the minus sign:

Expand All @@ -351,13 +338,9 @@ C

Matrix Transposition is when we switch the orientation of its rows and columns:

```bash
[ [
1 2 3 = 1 4
4 5 6 2 5
] ͭ 3 6
]
```
<BlockMath>
{`\\begin{equation}\\begin{bmatrix}1 & 2 & 3 \\\\4 & 5 & 6\\end{bmatrix}^{T} = \\begin{bmatrix}1 & 4\\\\2 & 5\\\\3 & 6 \\end{bmatrix}\\end{equation}`}
</BlockMath>

In Python, we have the `T` method:

Expand All @@ -374,12 +357,9 @@ A.T

Scalar multiplication in matrices looks similar to scalar multiplication in vectors. To multiply a matrix by a scalar value, you just multiply each element by the scalar to produce a new matrix:

```bash
[ [
2 · 1 2 3 = 2 4 6
4 5 6 8 10 12
] ]
```
<BlockMath>
{`\\begin{equation}2 \\times \\begin{bmatrix}1 & 2 & 3 \\\\4 & 5 & 6\\end{bmatrix} = \\begin{bmatrix}2 & 4 & 6 \\\\8 & 10 & 12\\end{bmatrix}\\end{equation}`}
</BlockMath>

In Python, we simply perform the multiplication of two values:

Expand All @@ -394,15 +374,9 @@ A = np.array([[1,2,3],

To mulitply two matrices, we need to calculate the dot product of rows and columns.

```bash
A · B

[ [
1 2 3 · 9 8
4 5 6 7 6
] 5 4
]
```
<BlockMath>
{`\\begin{equation}\\begin{bmatrix}1 & 2 & 3 \\\\4 & 5 & 6\\end{bmatrix} \\cdot \\begin{bmatrix}9 & 8 \\\\ 7 & 6 \\\\ 5 & 4\\end{bmatrix}\\end{equation}`}
</BlockMath>

How to calculate this multiplication:

Expand All @@ -422,12 +396,9 @@ Resulting in these calculations:

Resulting in this matrix:

```bash
[
38 32
101 86
]
```
<BlockMath>
{`\\begin{equation}\\begin{bmatrix}38 & 32\\\\101 & 86\\end{bmatrix} \\end{equation}`}
</BlockMath>

In Python, we can use the `dot` method or `@`:

Expand Down Expand Up @@ -469,23 +440,15 @@ Identity matrices are matrices that have the value 1 in the diagonal positions a

An example:

```bash
[
1 0 0
0 1 0
0 0 1
]
```
<BlockMath>
{`\\begin{equation}\\begin{bmatrix}1 & 0 & 0\\\\0 & 1 & 0\\\\0 & 0 & 1\\end{bmatrix} \\end{equation}`}
</BlockMath>

Multiplying a matrix by an identity matrix results in the same matrix. It's like multiplying by 1.

```bash
[ [ [
1 2 3 1 0 0 1 2 3
4 5 6 · 0 1 0 = 4 5 6
7 8 9 0 0 1 7 8 9
] ] ]
```
<BlockMath>
{`\\begin{equation}\\begin{bmatrix}1 & 2 & 3 \\\\4 & 5 & 6\\\\7 & 8 & 9\\end{bmatrix} \\cdot \\begin{bmatrix}1 & 0 & 0\\\\0 & 1 & 0\\\\0 & 0 & 1\\end{bmatrix} = \\begin{bmatrix}1 & 2 & 3 \\\\4 & 5 & 6\\\\7 & 8 & 9\\end{bmatrix} \\end{equation}`}
</BlockMath>

### Matrix Division

Expand Down

0 comments on commit 64c0c33

Please sign in to comment.