# Week 1: Vectors and Matrices Notes
## • Vector Operations
- Vectors have both magnitude and direction.
° Example of the **dot product** between two vectors:
$$ \mathbf{a} \cdot \mathbf{b} = \|\mathbf{a}\| \|\mathbf{b}\| \cos(\theta) $$
° The dot product gives us the projection of one vector onto another.
- **Vector Addition :**
° The sum of two vectors
$$
\mathbf{u} + \mathbf{v} = \begin{bmatrix} u_1 \\ u_2 \end{bmatrix} + \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} = \begin{bmatrix} u_1 + v_1 \\ u_2 + v_2 \end{bmatrix}
$$
- **Vector Subtraction :**
° The difference between vectors
$$
\mathbf{u} - \mathbf{v} = \begin{bmatrix} u_1 \\ u_2 \end{bmatrix} - \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} = \begin{bmatrix} u_1 - v_1 \\ u_2 - v_2 \end{bmatrix}
$$
- **Multiplying a scalar Item**
° Given a scalar c and a vector v, the result of multiplying the scalar c by the vector v is:
$$
c \cdot v = [c \cdot v_1, c \cdot v_2, c \cdot v_3, ..., c \cdot v_n]
$$
- **Dot product between two vectors**
° The dot product of u and v is
$$
\mathbf{u} \cdot \mathbf{v} = u_1 v_1 + u_2 v_2
$$
- **Angle Between the two vectors**
° The angle between two vectors u and v can be calculated using the following formula:
$$
\cos \theta = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\| \|\mathbf{v}\|}
$$
- **Cross product (3D)**
° The cross product of two vectors u and v is given by:
$$
\mathbf{u} \times \mathbf{v} = \left[ (u_2 v_3 - u_3 v_2), (u_3 v_1 - u_1 v_3), (u_1 v_2 - u_2 v_1)\right]
$$
- **Magnitude**, **Direction**,**Tangent Function** :
° Magnitude: $|\mathbf{v}| = \sqrt{x^2 + y^2}$
° Direction: $\theta = \arccos \left( \frac{\mathbf{a} \cdot \mathbf{b}}{|\mathbf{a}| |\mathbf{b}|} \right)$
° The tangent function is defined as
$$
\tan(\theta) = \frac{\sin(\theta)}{\cos(\theta)}
$$
° The inverse tangent is written as
$$
\theta = \tan^{-1} \left( \frac{\sin(\theta)}{\cos(\theta)}\right)
$$
## • Trigonometric Definitions
- In **Cartesian coordinates**:
° $x = r \cos(\theta)$
° $y = r \sin(\theta)$
- In **Polar coordinates**:
° $r = \sqrt{x^2 + y^2}$
° $\theta = \arctan \left( \frac{y}{x} \right)$
## • Solving Linear Equations
- Consider the following 2x2 system of linear equations:
° $2x + y = 5$
° $3x - 2y = -1$
- This can be represented in matrix form:
° $A = \begin{bmatrix} 2 & 1 \\ 3 & -2 \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} x \\ y \end{bmatrix}, \quad \mathbf{b} = \begin{bmatrix} 5 \\ -1 \end{bmatrix}$
° The goal is to find **x** and **y** that satisfy this system.
## • Reducing Matrices
- Consider the matrix:
$$ A = \begin{bmatrix} 2 & 1 \\ 3 & -2 \end{bmatrix} $$
- We perform **row reduction** to bring it into row echelon form:
1. **Multiply row 1 by** 1/2:
$$ R_1 \rightarrow \frac{1}{2} \times R_1 $$
This gives the matrix:
$$ A = \begin{bmatrix} 1 & \frac{1}{2} \\ 3 & -2 \end{bmatrix} $$
2. **Subtract** 3 X row 1 from row 2:
$$ R_2 \rightarrow R_2 - 3 \times R_1 $$
This gives the matrix:
$$ A = \begin{bmatrix} 1 & \frac{1}{2} \\ 0 & -\frac{7}{2} \end{bmatrix} $$
- The final row echelon form of the matrix is:
$$ \begin{bmatrix} 1 & \frac{1}{2} \\ 0 & -\frac{7}{2} \end{bmatrix} $$
## • Linear Combinations
- A **linear combination** of vectors is formed by multiplying each vector by a scalar and adding them together:
° $\mathbf{v} = a_1 \mathbf{v_1} + a_2 \mathbf{v_2} + \dots + a_n \mathbf{v_n}$
- Example:
° If $\mathbf{v_1} = \begin{bmatrix} 1 \\ 0 \end{bmatrix}$ and $\mathbf{v_2} = \begin{bmatrix} 0 \\ 1 \end{bmatrix}$, then:
° $\mathbf{v} = a_1 \begin{bmatrix} 1 \\ 0 \end{bmatrix} + a_2 \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} a_1 \\ a_2 \end{bmatrix}$
## • Linear Independence and Linear Dependence
- A set of vectors is **linearly independent** if no vector in the set can be written as a linear combination of the others. Consider K vectors which cannot exist on a lower dimentional space, these vectors can be used to define any point in K - dimentional space. The rank is the number of dimentions of this space.
° Example: $\mathbf{v_1} = \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \mathbf{v_2} = \begin{bmatrix} 0 \\ 1 \end{bmatrix}$
° These vectors are linearly independent.
- Consider three vectors placed on a 2 - dimentional plane, then the third vector is a combination of the other two vectors. These vectors are called linearly dependent vectors.
## • Basis Vectors
- Standard basis vector
° In a 3-dimensional space, the three standard basis vectors are:
$$
\mathbf{e_1} = \begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix},
\mathbf{e_2} = \begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix},
\mathbf{e_3} = \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix}
$$
These vectors are called the **standard basis vectors** because they are used to represent the coordinates of any vector in 3D space. Each of these vectors has a 1 in one component and 0 in the other components.
° These vectors are linearly independent.
° All these vectors are orthogonal and forms a right angle with one another also their dot product is zero.
° Standard basis vector are special case. Otherwise bases are linearly dependent and span the vector space.
## • Matrix Operations
- **Matrix-vector multiplication**:
° Given the matrix $A$ and vector $\mathbf{x}$:
° $A = \begin{bmatrix} 2 & 1 \\ 3 & -2 \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} 1 \\ 1 \end{bmatrix}$
° The result is:
° $A \mathbf{x} = \begin{bmatrix} 3 \\ 1 \end{bmatrix}$
- **Matrix Inverse :**
The **inverse** of a square matrix A is denoted by A^{-1} , and it satisfies the equation:
$$
A \cdot A^{-1} = A^{-1} \cdot A = I
$$
Where I is the identity matrix .
- **Solving linear equations using elimination method**
° The elimination method involves adding or subtracting equations to eliminate one of the variables, making it easier to solve for the remaining variable.
Consider the system of equations:
$$
2x + 3y = 12 \quad \
4x - 3y = 6 \quad \
$$
We add both equations to eliminate y. The coefficients of y in both equations are opposites +3y and -3y, so adding them cancels out y:
$$
(2x + 3y) + (4x - 3y) = 12 + 6
$$
This simplifies to:
$$
6x = 18
$$
Now, we solve for x:
$$
x = \frac{18}{6} = 3
$$
Substitute x = 3 into Equation :
$$
2(3) + 3y = 12
$$
This simplifies to:
$$
6 + 3y = 12
$$
Now, solve for y :
$$
3y = 12 - 6
$$
$$
3y = 6
$$
$$
y = \frac{6}{3} = 2
$$
The solution to the system of equations is:
$$
x = 3, \quad y = 2
$$
- Identity and Inverse
° To find the inverse of a matrix A, we use the identity matrix I and perform a sequence of **row operations** on the augmented matrix [A | I] .
° Form an augmented matrix [A | I] .
° Perform row operations to convert the left part of the augmented matrix into the identity matrix.
° The right part of the augmented matrix will become the inverse of A.
Consider the matrix:
$$
A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}
$$
Set up the augmented matrix :
$$
\left[\begin{array}{cc|cc}
1 & 2 & 1 & 0 \\
3 & 4 & 0 & 1
\end{array}\right]
$$
Subtract 3 times the first row from the second row:
$$ R_2 \rightarrow R_2 - 3 \times R_1 $$
$$
\left[\begin{array}{cc|cc}
1 & 2 & 1 & 0 \\
0 & -2 & -3 & 1
\end{array}\right]
$$
Divide the second row by -2
$$ R_2 \rightarrow \frac{1}{-2} R_2 $$
$$
\left[\begin{array}{cc|cc}
1 & 2 & 1 & 0 \\
0 & 1 & 1.5 & -0.5
\end{array}\right]
$$
Subtract 2 times the second row from the first row:
$$ R_1 \rightarrow R_1 - 2 \times R_2 $$
$$
\left[\begin{array}{cc|cc}
1 & 0 & -2 & 1 \\
0 & 1 & 1.5 & -0.5
\end{array}\right]
$$
**Result**
$$
A^{-1} = \begin{bmatrix} -2 & 1 \\ 1.5 & -0.5 \end{bmatrix}
$$
## • LaTeX Practice
- Try writing more LaTeX symbols, such as:
° Summation: $$\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$$
° Derivatives: $\frac{d}{dx} \left( x^2 \right) = 2x$