# Define sections for each chapter sequentially
sections <- c(
"2.1", "2.2", "2.3", "2.4",
"3.1", "3.2", "3.3", "3.4",
"4.1", "4.2", "4.3",
"5.1", "5.2", "5.3", "5.4", "5.5",
"6.1", "6.2", "6.3",
"7.1", "7.2", "7.3", "7.4", "7.5", "7.6",
"8.1", "8.2", "8.3"
)
# Initialize variables
weeks_list <- list()
sec_index <- 1
total_sections <- length(sections)
week_number <- 1
# Fill in the list
while (sec_index <= total_sections) {
week_schedule <- data.frame(
Day = c("Mon", "Tues", "Wed", "Thurs", "Fri"),
cover_computation = character(5),
cover_studying = character(5),
stringsAsFactors = FALSE
)
for (day in 1:5) {
if (sec_index <= total_sections) {
# Assign current section to computation
week_schedule$cover_computation[day] <- sections[sec_index]
# If there's another section, assign it to studying
if (sec_index + 1 <= total_sections) {
week_schedule$cover_studying[day] <- sections[sec_index + 1]
}
# Increment section index
sec_index <- sec_index + 1
}
}
# Add the week's schedule to the list
weeks_list[[paste("wk", week_number)]] <- week_schedule
week_number <- week_number + 1
}
# Display the weeks list
weeks_list
## $`wk 1`
## Day cover_computation cover_studying
## 1 Mon 2.1 2.2
## 2 Tues 2.2 2.3
## 3 Wed 2.3 2.4
## 4 Thurs 2.4 3.1
## 5 Fri 3.1 3.2
##
## $`wk 2`
## Day cover_computation cover_studying
## 1 Mon 3.2 3.3
## 2 Tues 3.3 3.4
## 3 Wed 3.4 4.1
## 4 Thurs 4.1 4.2
## 5 Fri 4.2 4.3
##
## $`wk 3`
## Day cover_computation cover_studying
## 1 Mon 4.3 5.1
## 2 Tues 5.1 5.2
## 3 Wed 5.2 5.3
## 4 Thurs 5.3 5.4
## 5 Fri 5.4 5.5
##
## $`wk 4`
## Day cover_computation cover_studying
## 1 Mon 5.5 6.1
## 2 Tues 6.1 6.2
## 3 Wed 6.2 6.3
## 4 Thurs 6.3 7.1
## 5 Fri 7.1 7.2
##
## $`wk 5`
## Day cover_computation cover_studying
## 1 Mon 7.2 7.3
## 2 Tues 7.3 7.4
## 3 Wed 7.4 7.5
## 4 Thurs 7.5 7.6
## 5 Fri 7.6 8.1
##
## $`wk 6`
## Day cover_computation cover_studying
## 1 Mon 8.1 8.2
## 2 Tues 8.2 8.3
## 3 Wed 8.3
## 4 Thurs
## 5 Fri
This section introduces the concept of linear transformations, focusing on their definition, properties, and how they map vectors from one space to another. It explores the relationship between linear transformations and matrices, showing how every linear transformation can be represented by a matrix. The section also covers the concept of inverse transformations, explaining how and when a linear transformation can be reversed, and the conditions under which an inverse exists.
LINEAR TRANSFORMATIONS:
\[ \vec{y} = A \vec{x} \]
\[T(\vec{x}) = A \vec{x} = \vec{b}\]
A linear-transformation is a special kind of function — i.e. \(T(\vec{x})\)
when we perform a linear transformation, we are either doing one of or a combination of:
Furthermore, note:
\[ A \vec{x} = \vec{y} \]
suppose: \(A\) = \(I\) then:
\[ I \vec{x} = \vec{y} \]
\[ \ \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \vec{x} = \vec{y} \]
Note that we can dilate and reflect \(\vec{x}\) by multiplying by some constant (\(C\)).
\[ C\ \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \vec{x} = \vec{y} \]
\[ \ \begin{bmatrix} C & 0 \\ 0 & C \end{bmatrix} \vec{x} = \vec{y} \]
Furthermore, the affect in the x-direction held within the 1st row, and the affect in the y-direction held within the 2nd row. It has a multiplicative relationship described by matrix-vector multiplication.
Consider the transformations from ℝ^3 to ℝ^3, Is this Transformation linear?
Recall:
When, \(T(\vec{x})\) is
linear, the following 2 cond. must be true:
Therefore, suppose \(\vec{x} = <1,1,1>\) and, \(C=2\)
Therefore, no. Not a linear transformation. This appears to be an affine-transformation
Determine whether the matrix is invertible.
\[ A =\ \begin{bmatrix} 2 & 3 \\ 6 & 9 \end{bmatrix} \]
Recall the following def. of inverse matrix:
\[ AA^{-1} = I_{} \]
Therefore:
\[ \ \begin{bmatrix} 2 & 3 \\ 6 & 9 \end{bmatrix}A^{-1}= I_{2 } \]
\[ \ \begin{bmatrix} 2 & 3 \\ 6 & 9 \end{bmatrix}A^{-1}= \ \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \]
and if this is true then,
\[ A\vec{x}=\vec{b} \]
so,
\[ \ \begin{bmatrix} 2 & 3 \\ 6 & 9 \end{bmatrix}\vec{x}=\vec{b} \]
\[ \vec{x}= \ \begin{bmatrix} x_{1} \\ x_{2} \end{bmatrix}, \vec{b} = \ \begin{bmatrix} b_{1} \\ b_{2} \end{bmatrix} \] \[ \ \begin{bmatrix} 2 & 3 \\ 6 & 9 \end{bmatrix}\ \begin{bmatrix} x_{1} \\ x_{2} \end{bmatrix}=\ \begin{bmatrix} b_{1} \\ b_{2} \end{bmatrix} \]
\[ 2x_{1} + 3x_{2} = b_{1} \]
\[ x_{1} + 9x_{2} = b_{2} \]
\[ \ \begin{bmatrix} 2 & 3 & b_{1}\\ 6 & 9 & b_{2} \end{bmatrix} \]
\[ \ \begin{bmatrix} 2 & 3 & b_{1}\\ 2 & 3 & \frac{b_{2}}{3} \end{bmatrix} \therefore A^{-1} DNE\]
Determine whether the matrix is invertible.
Recall the following def. of inverse matrix:
\[ AA^{-1} = I_{} \longrightarrow A\vec{x}=\vec{b} \]
\[ \therefore \]
\[ \begin{bmatrix} 1 & 2 \\ 4 & 9 \end{bmatrix} \]
\[ \implies \begin{bmatrix} 1 & 2 \\ 4 & 9 \end{bmatrix} \vec{x} = \vec{b} \]
\[ \implies \begin{bmatrix} 1 & 2 \\ 4 & 9 \end{bmatrix} \begin{bmatrix} x_{1} \\ x_{2} \end{bmatrix} = \vec{b} \]
\[ \implies \begin{bmatrix} 1 & 2 & b_{1}\\ 4 & 9 & b_{2} \end{bmatrix} \]
\[ \implies \begin{bmatrix} 1 & 2 & b_{1}\\ 0 & 1 & b_{2} -4b_{1} \end{bmatrix} \]
\[ = \begin{bmatrix} 1 & 0 & b_{1} -2(b_{2} -4b_{1})\\ 0 & 1 & b_{2} -4b_{1} \end{bmatrix} \]
\[ = \begin{bmatrix} 1 & 0 & b_{1} -2b_{2} +8b_{1}\\ 0 & 1 & b_{2} -4b_{1} \end{bmatrix} \]
\[ = \begin{bmatrix} 1 & 0 & 9b_{1} -2b_{2}\\ 0 & 1 & b_{2} -4b_{1} \end{bmatrix} \]
\[ \implies I_{2} = \begin{bmatrix} 9b_{1} -2b_{2}\\ b_{2} -4b_{1} \end{bmatrix} \]
\[ \implies x_{1} = 9b_{1} -2b_{2} \]
\[ \implies x_{2} = -4b_{1} + b_{2} \]
\[ \implies A^{-1}= \begin{bmatrix} 9 & -2\\ -4 & 1 \end{bmatrix} \]
verify:
\[ AA^{-1} = \begin{bmatrix} 1 & 2 \\ 4 & 9 \end{bmatrix}\begin{bmatrix} 9 & -2\\ -4 & 1 \end{bmatrix} \]
\[ = \begin{bmatrix} 1*9+2*(-4) & 1*(-2)+2*1\\ 4*(9)+9*(-4) & 4*(-2)+9*1 \end{bmatrix} \]
\[ = \begin{bmatrix} 9-8 & -2+2\\ 36-36 & -8+9 \end{bmatrix} \]
\[ = \begin{bmatrix} 1 & 0\\ 0 & 1 \end{bmatrix} = I_{2} \]
For which values of the constant \(k\) is the matrix invertible
\[ \begin{bmatrix} 2 & 3\\ 5 & k \end{bmatrix} \]
Recall the following def. of inverse matrix:
\[ AA^{-1} = I_{} \longrightarrow A\vec{x}=\vec{b} \]
\[ \implies A = \begin{bmatrix} 2 & 3\\ 5 & k \end{bmatrix} \therefore \begin{bmatrix} 2 & 3\\ 5 & k \end{bmatrix}\vec{x}=\vec{b} \]
\[ \implies \begin{bmatrix} 2 & 3\\ 5 & k \end{bmatrix} \begin{bmatrix} x_{1} \\ x_{2} \end{bmatrix} =\begin{bmatrix} b_{1} \\ b_{2} \end{bmatrix} \]
\[ \implies b_1 = 2x_{1}+3x_{2}\]
\[ \implies b_2 = 5x_{1}+kx_{2}\]
\[ \implies \begin{bmatrix} 2 & 3 & b_1\\ 5 & k & b_2 \end{bmatrix} \]
\[ \implies \begin{bmatrix} 2 & 3 & b_1\\ 1 & k-6 & b_2-2b_1 \end{bmatrix} \]
\[ \implies \begin{bmatrix} 0 & 3-2(k-6) & b_1-2(b_2-2b_1)\\ 1 & k-6 & b_2-2b_1 \end{bmatrix} \]
\[ \implies \begin{bmatrix} 0 & -2k+15 & b_1-2b_2+4b_1\\ 1 & k-6 & b_2-2b_1 \end{bmatrix} \]
\[ \implies \begin{bmatrix} 1 & k-6 & b_2-2b_1\\0 & -2k+15 & b_1-2b_2+4b_1 \end{bmatrix} \]
\[ I_2\implies \]
\[ \implies 1=-2k+15 \]
\[ \implies -14=-2k \]
\[ \implies -7=-k \]
\[ \implies k=7 \]
\[ \implies \begin{bmatrix} 1 & 7-6 & b_2-2b_1\\0 & -2*7+15 & b_1-2b_2+4b_1 \end{bmatrix} \]
\[ \implies \begin{bmatrix} 1 & 1 & b_2-2b_1\\0 & 1 & b_1-2b_2+4b_1 \end{bmatrix} \]
\[ \implies \begin{bmatrix} 1 & 0 & b_2-2b_1-(b_1-2b_2+4b_1)\\0 & 1 & b_1-2b_2+4b_1 \end{bmatrix} \]
\[ \implies \begin{bmatrix} 1 & 0 & b_2-2b_1-b_1+2b_2-4b_1\\0 & 1 & b_1-2b_2+4b_1 \end{bmatrix} \]
\[ \implies \begin{bmatrix} 1 & 0 & 3b_2-7b_1\\0 & 1 & -2b_2+5b_1 \end{bmatrix} \]
\[ \implies x_1 =-7b_1+3b_2\]
\[ \implies x_2 =5b_1-2b_2\]
\[ \implies A^{-1}=\begin{bmatrix}-7 & 3\\5&-2\end{bmatrix} \]
Prove:\[ A^{-1}A=I_2 \]
A_inv <- rbind(c(-7,3), c(5,-2))
A <- rbind(c(2,3), c(5,7))
A%*%A_inv
## [,1] [,2]
## [1,] 1 0
## [2,] 0 1
This section delves into the geometric interpretations of linear transformations, particularly in 2D and 3D spaces. It covers transformations such as rotations, reflections, and scaling, explaining how they alter the shape and orientation of geometric objects. The section uses matrices to represent these transformations, helping to visualize and understand their effects on vectors and shapes.
\[ \implies A=\begin{bmatrix}1 & 0 \\ 0 & 1\end{bmatrix} = I_2 \]
\[ A\vec{x}=\vec{b} \]
\[ \vec{x}=\vec{b} \]
\[ \implies \]
\[ \begin{bmatrix}x \\ y\end{bmatrix} = \vec{x} \]
\[ \begin{bmatrix}x \\ y\end{bmatrix} = \vec{b} \]
\[ A\vec{x}=\vec{b} \]
\[ \begin{bmatrix}0 & 1 \\ 1 & 0\end{bmatrix} \begin{bmatrix}x_1 \\ x_2\end{bmatrix}=\begin{bmatrix}b_1 \\ b_2\end{bmatrix} \]\[ \begin{bmatrix}0 & 1 \\ 1 & 0\end{bmatrix} \begin{bmatrix}x \\ y\end{bmatrix}=\begin{bmatrix}b_1 \\ b_2\end{bmatrix} \]\[ \begin{bmatrix}y \\ x\end{bmatrix} = \vec{b} \]
\[ \begin{bmatrix}x \\ y\end{bmatrix} = \vec{x} \]
\(\vec{x} \rightarrow \vec{b} \implies\) \(x\) becomes \(y\) and \(y\) becomes \(x\).
In other words a change in the x-direction for vector \(\vec{x}\) corresponds with a positively-proportional change in the y-direction in \(\vec{b}\) and a change in the y-direction for vector \(\vec{x}\) corresponds with a proportional change in the x-direction in \(\vec{b}\).
Another way to think about it is that \(\vec{x} \rightarrow \vec{b} \implies\) we say \(x\) and \(y\) and they both positively-correlate to one another.
Notice this is “Switch the X to Y and Y to X“ nearly exactly identical to the previous problem.
\[ \implies A=\begin{bmatrix}0 & 1 \\ -1 & 0\end{bmatrix} \]
\[ A\vec{x}=\vec{b} \]
\[ \begin{bmatrix}0 & 1 \\ -1 & 0\end{bmatrix} \begin{bmatrix}x \\ y \end{bmatrix} = \vec{b} \]
\[ \implies \]
\[ \begin{bmatrix} x \\ y \end{bmatrix} = \vec{x} \]
\[ \begin{bmatrix} y \\ -x \end{bmatrix} = \vec{b} \]
\(\vec{x} \rightarrow \vec{b} \implies\) a change in the x-direction for vector \(\vec{x}\) corresponds with a proportional positive-change in the y-direction in \(\vec{b}\) and a change in the y-direction for vector \(\vec{x}\) corresponds with a proportional negative-change in the x-direction in \(\vec{b}\). In other words, a reflection about the y-axis.
Another way to think about it is that \(\vec{x} \rightarrow \vec{b}\) ,
\(x\) but not \(y\) is positively-correlated to one another.
\[ \implies A=\begin{bmatrix}0 & -1 \\ 1 & 0\end{bmatrix} \]
\[ A\vec{x}=\vec{b} \]
\[ \begin{bmatrix}0 & -1 \\ 1 & 0\end{bmatrix} \begin{bmatrix}x \\ y \end{bmatrix} = \vec{b} \]
\[ \implies \] \[ \begin{bmatrix} x \\ y \end{bmatrix} = \vec{x} \] \[ \begin{bmatrix} -y \\ x \end{bmatrix} = \vec{b} \]
\(\vec{x} \rightarrow \vec{b} \implies\) a change in the x-direction for vector \(\vec{x}\) corresponds with a proportional negative-change in the y-direction in \(\vec{b}\) and a change in the y-direction for vector \(\vec{x}\) corresponds with a proportional positive-change in the x-direction in \(\vec{b}\). A reflection about the x-axis. In other words, the 1 that was pos for before is now negative and vice-versa.
Another way to think about it is that \(\vec{x} \rightarrow \vec{b}\) ,
\(y\) but not \(x\) is positively-correlated to one another.
\[ T_{counter-clock-wise}(\vec{x})=\begin{bmatrix} cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix}\vec{x} = \vec{ \theta} \\ T(\vec{x})=\begin{bmatrix}0 & -1 \\ 1 & 0\end{bmatrix}\vec{x} \\ T_{clock-wise}(\vec{x})=\begin{bmatrix} cos\theta & sin\theta \\ -sin\theta & cos\theta \end{bmatrix}\vec{x} = \vec{ \theta} \\ T(\vec{x})=\begin{bmatrix}0 & 1 \\ -1 & 0\end{bmatrix}\vec{x} \]
where \(r=scale\),
\[ T_{counter-clock-wise}(\vec{x})=\begin{bmatrix} cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix}r\vec{x} = \vec{ \theta} \\ =\begin{bmatrix} a & -b \\ b & a \end{bmatrix} \vec{x}\\ T_{clock-wise}(\vec{x})=\begin{bmatrix} cos\theta & sin\theta \\ -sin\theta & cos\theta \end{bmatrix}r\vec{x} = \vec{ \theta} \\ =\begin{bmatrix} a & b \\ -b & a \end{bmatrix}\vec{x} \]
Consider:
Suppose: \(\vec{x} \in \mathbb{R^{2}}\) (i.e. \(\vec{x}\) is a 2D-vector); then,
The Transformation:
\[T(\vec{x})=\vec{x}^{||}\]
Is considered to be the transformation required to get the orthogonal projection of \(\vec{x}\) onto \(L\). Where \(c\) = “some constant”, \(L=\{c\vec{x}|c \in \mathbb{R}\}\). In other words, \(L\) is the set of all points that can be produced by scaling and reflecting\(\vec{x}\) by \(c\). Furthermore, note:
\[ \vec{x}^{||}:= \vec{x} || L \]
\[ \vec{x}^{\perp} := \vec{x}\perp L \]
\[ \implies \vec{x}^{\perp}+\vec{x}^{||} = \vec{x} \]
\[ proj_L(\vec{x})=\vec{x}^{||} = \vec{x} - \vec{x}^{\perp} \]
suppose:
\[ \vec{w}:=\{\vec{w}||L : \vec{w} \ne 0\}\therefore\vec{w}||\vec{x}^{||} \]
in other words, if \(\vec{w}\) is some vector parallel to \(L\), and vector \(\vec{x}^{||}\) is also parallel to \(L\) then, they are parallel to one another. Therefore:
\[ \vec{x}^{||}=c\vec{w} \]
so–because \(\vec{x}^{||}\) is a determined size, we can say for some constant \(c\) some arbitrary vector that is parallel can describe \(\vec{x}^{||}\) if it is scaled correctly. Recall:
\[ \vec{x}^{\perp}+\vec{x}^{||} = \vec{x} \]
\[ \implies \]
\[ \vec{x}^{\perp} = \vec{x}- \vec{x}^{||} \]
\[ \vec{x}^{\perp} = \vec{x}- c\vec{w} \]
Recall:
\[ \vec{x} \cdot\vec{y}=cos(\theta)(||\vec{x}||)(||\vec{y}||) \]
\[ \implies \]
\[ cos(\theta)=\frac{\vec{x} \cdot\vec{y}}{(||\vec{x}||)(||\vec{y}||)} \]
\[ \theta = 90^{\circ}=\frac{\pi}{2}=\theta^{\perp} \]
\[ \implies \]
\[ cos(\theta) \bigg|_{\theta=\theta^{\perp}}=0 \]
\[ \vec{x} \cdot\vec{y}=cos(\theta)(||\vec{x}||)(||\vec{y}||) \]
\[ \vec{x} \cdot\vec{y}=0 * (||\vec{x}||)(||\vec{y}||) \]
\[ \vec{x} \cdot\vec{y}=0 \implies \vec{x}\perp\vec{y} \]
\[ \therefore \]
\[ \vec{x}^{\perp} = \vec{x}- c\vec{w} \]
\[ \implies \]
\[ 0=(\vec{x}- c\vec{w})\cdot \vec{w} \]
\[ 0=(\vec{x}- \vec{x}^{||})\cdot \vec{w} \]
\[ 0=\vec{x}\cdot\vec{w}-\vec{x}^{||}\cdot\vec{w} \]
\[ 0=\vec{x}\cdot\vec{w}-c(\vec{w}\cdot\vec{w}) \]
\[ \implies \]
\[ -(\vec{x}\cdot\vec{w})=-c(\vec{w}\cdot\vec{w}) \]
\[ (\vec{x}\cdot\vec{w})=c(\vec{w}\cdot\vec{w}) \]
\[ c=\frac{(\vec{x}\cdot\vec{w})}{\vec{w}\cdot\vec{w}} \]
and recall:
\[ proj_L(\vec{x})=\vec{x}^{||}=c\vec{w}\implies proj_L(\vec{x})=\frac{(\vec{x}\cdot\vec{w})}{\vec{w}\cdot\vec{w}}\vec{w} \\for: \ c=\frac{(\vec{x}\cdot\vec{w})}{\vec{w}\cdot\vec{w}}\]
In other words, the projection of \(\vec{x}\) onto \(L\) is in the direction of \(\vec{w}\) reduced to the size \(c\).
Furthermore recall that \(T(\vec{x})\)
is a “Transformation”–and, we previously
learned about “linear Transformations”. So, is \(T(\vec{x})\) Linear? and, if so–how do we
represent it?
\[T(\vec{x})=proj_L(\vec{x})=\vec{x}^{||} \
linear?\]
Well first, lets consider how unique the \(\hat{u}_{unit \ vector}\) is then later use its special-attribute from its uniqueness to find a linear algebra expression for \(proj_L(\vec{x})\)
First, Suppose:
\[ \hat{u}=\hat{u}_{unit \ vector} \rightarrow \hat{u} \implies ||\hat{u}||:=1 \]
\[ \therefore \]
\[ \hat{u}\cdot\hat{u}=||\hat{u}||^2 =1^2=1 \]
then since we are finding \(proj_L(\vec{x})\) –which is the vector in the direction of the line \(L\) with the determined length from the shadow of \(\vec{x}\). We will mult. by the direction of \(\hat{u}\) which is parallel to \(L\) by some constant \(c\), to determine \(proj_L(\vec{x})\).
Recall our definition of \(proj_L(\vec{x})\):
\[ proj_L(\vec{x}):=\frac{(\vec{x}\cdot\vec{w})}{\hat{u}\cdot\hat{u}}\hat{u} \\ for: \ c=\frac{(\vec{x}\cdot\vec{w})}{\hat{u}\cdot\hat{u}} \]
\[ \implies \]
\[ proj_L(\vec{x}):=\frac{(\vec{x}\cdot\vec{u})}{\hat{u}\cdot\hat{u}}\hat{u} \\ =\frac{(\vec{x}\cdot\hat{u})}{1}\hat{u} \\ =(\vec{x}\cdot\hat{u})\hat{u} \\ for: c=\vec{x}\cdot\hat{u} \\ since:\hat{u} \]
So, then how do we make it a linear transformation?
If we imagine \(\vec{x}\) is some
arbitrary vector and, \(\hat{u}\) is the unit-vector then,
we say:
\[
\vec{x}=\begin{bmatrix}
x_1
\\
x_2
\end{bmatrix}
\]
\[ \hat{u}_{unit \ vector}=\begin{bmatrix} u_1 \\ u_2 \end{bmatrix} \]
since now we know \(proj_L(\vec{x})=(\vec{x}\cdot\hat{u})\hat{u}\). if we suppose: \(\hat{u}||L\) then, we say:
\[ proj_L(\vec{x})=(\vec{x}\cdot\hat{u})\hat{u}\\ =(\begin{bmatrix} x_1 \\ x_2 \end{bmatrix} \cdot \begin{bmatrix} \hat{u}_1 \\ \hat{u}_2 \end{bmatrix} ) \begin{bmatrix} \hat{u}_1 \\ \hat{u}_2 \end{bmatrix} \\ =c\begin{bmatrix} \hat{u}_1 \\ \hat{u}_2 \end{bmatrix}\\ =x_1\hat{u_1}+x_2\hat{u_2}\begin{bmatrix} \hat{u}_1 \\ \hat{u}_2 \end{bmatrix} \\ =\begin{bmatrix} x_1\hat{u}_1^{2}+x_2\hat{u}_1\hat{u}_2 \\ x_1\hat{u}_1\hat{u}_2+x_1\hat{u}_2^{2} \end{bmatrix} \\ =\begin{bmatrix} x_1\hat{u}_1^{2}+x_2\hat{u}_1\hat{u}_2 \\ x_1\hat{u}_1\hat{u}_2+x_1\hat{u}_2^{2} \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} \\ =\begin{bmatrix} x_1\hat{u}_1^{2}+x_2\hat{u}_1\hat{u}_2 \\ x_1\hat{u}_1\hat{u}_2+x_1\hat{u}_2^{2} \end{bmatrix}\vec{x} \\ let: A\vec{x}=\begin{bmatrix} \hat{u}_1^{2}+\hat{u}_1\hat{u}_2 \\ \hat{u}_1\hat{u}_2+\hat{u}_2^{2} \end{bmatrix}\vec{x}\rightarrow A\vec{x}=proj_L(\vec{x}) \\ \therefore \\ \begin{bmatrix} {w}_1^{2}+{w}_1+{u}_2 \\ {w}_1{w}_2+{w}_2^{2} \end{bmatrix}\frac{1}{w_1^2+w_2^2} = \begin{bmatrix} \hat{u}_1^{2}+\hat{u}_1\hat{u}_2 \\ \hat{u}_1\hat{u}_2+\hat{u}_2^{2} \end{bmatrix}\ \]
Furthermore recall a linear transformation is described as the following :
\[ \vec{y} = A \vec{x} \]
\[ \therefore \]
\(T(\vec{x})=\vec{x}^{||}\) is a linear-transformation.
which intuitively makes sense because it is just two lines starting from the same point (so not an affine-function) going in different directions in different places.
Suppose, just like previously, there is some line \(L\) and some vector \(\vec{x}\) then, the projection of that vector \(\vec{x}\) onto \(L\) is considered as:
\(Proj_L(\vec{x}):=\vec{x}^{||}:=\vec{x}||L\)
Therefore, as previously noted:
\[ Proj_L(\vec{x})=\vec{x}-\vec{x}^{\perp} \]
\[ \therefore \]
\[ ref_L(\vec{x})\\ =Proj_L(\vec{x})-\vec{x}^{\perp} \\ =\vec{x}^{||}-\vec{x}^{\perp} \\ suppose:\\ eq_1:\vec{x}^{||}-\vec{x}^{\perp} = ref_L(\vec{x}) \\ eq_2: \vec{x}^{||}+\vec{x}^{\perp} = \vec{x}\\ \implies \\ eq_1+eq_2 \\ \implies \\ (2)Proj_L(\vec{x})=ref_L(\vec{x})+\vec{x}\\ \implies \\ ref_L(\vec{x})=(2)Proj_L(\vec{x})-\vec{x} \]
In other words, 2 steps in the \(\vec{x}^{||}\) direction then down \(\vec{x}\) direction brings you to the reflection of \(\vec{x}\) about the \(L\)-axis. Furthermore, note:
\[ ref_L(\vec{x})=(2)Proj_L(\vec{x})-\vec{x} \\ ref_L(\vec{x})=2\vec{x}^{||}-\vec{x} \\ ref_L(\vec{x})=2\vec{x}^{||}-\vec{x}I_2\\ ref_L(\vec{x})=2\vec{x}^{||}-\vec{x}\begin{bmatrix}1 & 0 \\ 0 & 1\end{bmatrix}\\ ref_L(\vec{x})=2\vec{x}^{||}\begin{bmatrix}1 & 0 \\ 0 & 1\end{bmatrix}-\vec{x}\begin{bmatrix}1 & 0 \\ 0 & 1\end{bmatrix}\\ ref_L(\vec{x})=(2\vec{x}^{||}-I_2)\vec{x} \\ \implies \\ ref_L(\vec{x})=2\hat{u}(\vec{x} \cdot\vec{u})-\vec{x} \]
\[ ref_L(\vec{x})=(2\vec{x}^{||}-I_2)\vec{x} \\ =(2\begin{bmatrix} x_1\hat{u}_1^{2}+x_2\hat{u}_1\hat{u}_2 \\ x_1\hat{u}_1\hat{u}_2+x_1\hat{u}_2^{2} \end{bmatrix}\vec{x}-I_2)\vec{x} \\ =(\begin{bmatrix} 2x_1\hat{u}_1^{2}+2x_2\hat{u}_1\hat{u}_2 \\ 2x_1\hat{u}_1\hat{u}_2+2x_1\hat{u}_2^{2} \end{bmatrix}\vec{x}-\begin{bmatrix}1 & 0 \\ 0 & 1\end{bmatrix})\vec{x} \\ =\begin{bmatrix} 2\hat{u}_1^2-1 & 2\hat{u}_1\hat{u}_2 \\ 2\hat{u}_1\hat{u}_2 & 2\hat{u}_2^2-1 \end{bmatrix} \\ \therefore \\ \]
The matrix of \(T(\vec{x})\) is of
the form:
\[
\begin{bmatrix} a & b \\ c & -a \end{bmatrix} \ for: a^2
+b^2=1
\]
Basically keeping one axis the same and making one slide in its direction. So maybe the height stays the same but its pushed to the side.
Change-in-Size-and-Angle-formula:
Consider:
\[ A\vec{x}=\vec{b} \]
\[ \begin{bmatrix} a_{11} & a_{12}\\ a_{21} & a_{22} \end{bmatrix} \begin{bmatrix}x_1\\x_2\end{bmatrix}=\begin{bmatrix}b_1\\b_2\end{bmatrix} \]
\[ \begin{bmatrix} a_{11} & a_{12}\\ a_{21} & a_{22} \end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix}=\begin{bmatrix}b_1\\b_2\end{bmatrix} \]
Recall:
Rectangular \(\rightarrow\) polar
coordinates:
\[ (x,y)\rightarrow(r,\theta) \]
\[ Recall: (rcos(\theta),rsin(\theta)) = (x,y) \]
\[ \implies \]
\[ \vec{b}(b_1,b_2)=\begin{bmatrix}b_1\\b_2\end{bmatrix} \]
\[ \vec{b}(r,\theta)=\begin{bmatrix}b_1\\b_2\end{bmatrix}^{\theta}=\begin{bmatrix}?\\?\end{bmatrix} \]
\[ r=\sqrt(b_1^2+b_2^2) \]
\[ \implies \]
\[ \theta = \tan^{-1}(b_2/b_1) \]
\[ \therefore \]
\[ \vec{b}_{r,\theta}=(r,\theta)_\vec{b}=(\sqrt(b_1^2+b_2^2), \tan^{-1}(b_2/b_1)) \]
\[ \therefore \]
\[ \vec{x}_{r,\theta}=(r,\theta)_\vec{x}=(\sqrt(x_1^2+x_2^2), \tan^{-1}(x_2/x_1)) \]
\[ \implies\Delta_{r,\theta}=(r,\theta)_\vec{b}-(r,\theta)_\vec{x} \]
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
rect2polarLA_func <- function() {
# Ask for the dimensions of the matrix
Nrow <- as.integer(readline(prompt = "Enter the number of rows (Nrow): "))
Ncol <- as.integer(readline(prompt = "Enter the number of columns (Ncol): "))
# Check if the matrix is square
if (Nrow != Ncol) {
stop("Error: The matrix must be square (Nrow must equal Ncol).")
}
# Check if the vector is 2D or 3D
if (Ncol != 2 && Ncol != 3) {
stop("The function currently only supports 2D or 3D vectors.")
}
# Initialize the matrix : EMPTY MATRIX
A_mat <- matrix(0, nrow = Nrow, ncol = Ncol)
# USER INPUT : matrix values
cat("Enter the elements of the matrix row by row:\n")
for (i in 1:Nrow) {
for (j in 1:Ncol) {
A_mat[i, j] <- as.numeric(readline(prompt = paste("Enter element [", i, ",", j, "]: ", sep = "")))
}
}
# Get the vector x from the user
x_vec <- numeric(Ncol)
cat("Enter the elements of the vector x:\n")
for (i in 1:Ncol) {
x_vec[i] <- as.numeric(readline(prompt = paste("Enter element x[", i, "]: ", sep = "")))
}
# Calculate the vector b
b_vec <- A_mat %*% x_vec
# Analysis results
analysis <- ""
if (Ncol == 2) {
# Convert b_vec from rectangular to polar coordinates (2D)
r_b <- sqrt(b_vec[1]^2 + b_vec[2]^2)
theta_b <- atan2(b_vec[2], b_vec[1]) * (180 / pi) # Convert to degrees
# Convert x_vec from rectangular to polar coordinates (2D)
r_x <- sqrt(x_vec[1]^2 + x_vec[2]^2)
theta_x <- atan2(x_vec[2], x_vec[1]) * (180 / pi) # Convert to degrees
# Calculate the differences in radius and angle
delta_r <- r_b - r_x
delta_theta <- theta_b - theta_x
# Output vectors in the specified format
cat("Vector x: vec_x = <", x_vec[1], ",", x_vec[2], ">\n")
cat("Vector b: vec_b = <", b_vec[1], ",", b_vec[2], ">\n\n")
# Output the polar coordinates and differences for 2D
cat("Polar coordinates for b (r, θ):\n")
cat("r_b:", r_b, "\n")
cat("θ_b:", theta_b, "degrees\n\n")
cat("Polar coordinates for x (r, θ):\n")
cat("r_x:", r_x, "\n")
cat("θ_x:", theta_x, "degrees\n\n")
cat("Differences (Δr, Δθ):\n")
cat("Δr:", delta_r, "\n")
cat("Δθ:", delta_theta, "degrees\n")
# Analysis of changes
if (delta_r == 0 && delta_theta == 0) {
analysis <- "Neither the size nor the angle has changed."
} else if (delta_r != 0 && delta_theta == 0) {
analysis <- "The size has changed, but the angle has not."
} else if (delta_r == 0 && delta_theta != 0) {
analysis <- "The angle has changed, but the size has not."
} else {
analysis <- "Both the size and the angle have changed."
}
# Plotting the 2D vectors using ggplot2
plot_df <- data.frame(
x_start = c(0, 0),
y_start = c(0, 0),
x_end = c(x_vec[1], b_vec[1]),
y_end = c(x_vec[2], b_vec[2]),
vector = c("x", "b")
)
# Calculate plot limits to ensure all quadrants are visible
max_range <- max(abs(c(plot_df$x_start, plot_df$x_end, plot_df$y_start, plot_df$y_end)))
plot_limits <- c(-max_range, max_range)
p <- ggplot(plot_df) +
geom_segment(aes(x = x_start, y = y_start, xend = x_end, yend = y_end, color = vector),
arrow = arrow(length = unit(0.2, "cm")), size = 1) +
geom_point(aes(x = x_end, y = y_end, color = vector)) +
xlim(plot_limits) +
ylim(plot_limits) +
labs(title = "2D Vector Plot", x = "X", y = "Y") +
theme_minimal() +
coord_fixed() # Ensure equal scaling on both axes
print(p)
} else if (Ncol == 3) {
# Convert b_vec from rectangular to polar coordinates (3D)
r_b <- sqrt(b_vec[1]^2 + b_vec[2]^2 + b_vec[3]^2)
phi_b <- atan2(b_vec[2], b_vec[1]) * (180 / pi) # Azimuthal angle
theta_b <- atan2(sqrt(b_vec[1]^2 + b_vec[2]^2), b_vec[3]) * (180 / pi) # Elevation angle
# Convert x_vec from rectangular to polar coordinates (3D)
r_x <- sqrt(x_vec[1]^2 + x_vec[2]^2 + x_vec[3]^2)
phi_x <- atan2(x_vec[2], x_vec[1]) * (180 / pi) # Azimuthal angle
theta_x <- atan2(sqrt(x_vec[1]^2 + x_vec[2]^2), x_vec[3]) * (180 / pi) # Elevation angle
# Calculate the differences in radius and angles
delta_r <- r_b - r_x
delta_phi <- phi_b - phi_x
delta_theta <- theta_b - theta_x
# Output vectors in the specified format
cat("Vector x: vec_x = <", x_vec[1], ",", x_vec[2], ",", x_vec[3], ">\n")
cat("Vector b: vec_b = <", b_vec[1], ",", b_vec[2], ",", b_vec[3], ">\n\n")
# Output the polar coordinates and differences for 3D
cat("Polar coordinates for b (r, θ, Φ):\n")
cat("r_b:", r_b, "\n")
cat("θ_b:", theta_b, "degrees\n")
cat("Φ_b:", phi_b, "degrees\n\n")
cat("Polar coordinates for x (r, θ, Φ):\n")
cat("r_x:", r_x, "\n")
cat("θ_x:", theta_x, "degrees\n")
cat("Φ_x:", phi_x, "degrees\n\n")
cat("Differences (Δr, Δθ, ΔΦ):\n")
cat("Δr:", delta_r, "\n")
cat("Δθ:", delta_theta, "degrees\n")
cat("ΔΦ:", delta_phi, "degrees\n")
# Analysis of changes
if (delta_r == 0 && delta_theta == 0 && delta_phi == 0) {
analysis <- "Neither the size nor the angles have changed."
} else if (delta_r != 0 && delta_theta == 0 && delta_phi == 0) {
analysis <- "The size has changed, but the angles have not."
} else if (delta_r == 0 && (delta_theta != 0 || delta_phi != 0)) {
analysis <- "The angles have changed, but the size has not."
} else {
analysis <- "Both the size and the angles have changed."
}
# Plotting the 3D vectors using plotly
plot_ly() %>%
add_trace(
x = c(0, x_vec[1]), y = c(0, x_vec[2]), z = c(0, x_vec[3]),
type = 'scatter3d', mode = 'lines+markers',
line = list(color = 'blue', width = 6),
marker = list(size = 4),
name = 'x'
) %>%
add_trace(
x = c(0, b_vec[1]), y = c(0, b_vec[2]), z = c(0, b_vec[3]),
type = 'scatter3d', mode = 'lines+markers',
line = list(color = 'red', width = 6),
marker = list(size = 4),
name = 'b'
) %>%
layout(title = '3D Vector Plot',
scene = list(
xaxis = list(title = 'X'),
yaxis = list(title = 'Y'),
zaxis = list(title = 'Z')
)) %>%
print()
}
# Output the analysis
cat("\nAnalysis: ", analysis, "\n")
}
# Run the function
#rect2polarLA_func()
\[ T(\vec{x})=\begin{bmatrix} 3 & 1 \\ 1 & 2\end{bmatrix}\vec{x} \\ \begin{bmatrix} 3 & 1 \\ 1 & 2\end{bmatrix}=\begin{bmatrix} 0 & 1 \\ 1 & 0\end{bmatrix} + \begin{bmatrix} 3 & 0 \\ 0 & 2\end{bmatrix} \\ \implies \\ \begin{bmatrix} 0 & 1 \\ 1 & 0\end{bmatrix}\vec{x} + \begin{bmatrix} 3 & 0 \\ 0 & 2\end{bmatrix}\vec{x} \\ \]
\[ let: \vec{x}=<x_1,x_2>=\begin{bmatrix}x_1\\x_2\end{bmatrix}\\ \implies \\ T(\vec{x})=\begin{bmatrix} 0 & 1 \\ 1 & 0\end{bmatrix}\begin{bmatrix}x_1\\x_2\end{bmatrix} + \begin{bmatrix} 3 & 0 \\ 0 & 2\end{bmatrix}\begin{bmatrix}x_1\\x_2\end{bmatrix} \\ notice "Switch\ the\ X\ to\ Y\ and\ Y\ to\ X"\ format + scale\\ =\begin{bmatrix}x_2\\x_1\end{bmatrix}+\begin{bmatrix}3x_1\\2x_2\end{bmatrix} \\ suppose: \vec{x}=<1,1>\ and\ A\vec{x} = \vec{b} \implies \\ \vec{b} = \begin{bmatrix}1\\1\end{bmatrix}+\begin{bmatrix}3\\2\end{bmatrix} = \begin{bmatrix}4\\3\end{bmatrix} \]
Find the matrix of the orthogonal-projection onto the line \(L\) in \(\mathbb{R^{2}}\) for \(\vec{x}^{||}\):
\[ \vec{x}^{||} = \begin{bmatrix} 4 \\ 3\end{bmatrix} \\ \text{for: } L:\implies\{\vec{x}|| L\} \ \text{or, } \\ L=t\vec{x}^{||} \ \text{for: } t\in n\mathbb{R} \\ \therefore \\ \text{recall: } \\ T_{\vec{x}^{||}}(\vec{x})=\vec{x}^{||} \\ T_{\vec{x}^{||}} = \begin{bmatrix} u_1^2 & u_1u_2 \\ u_1u_2 & u_2^2\end{bmatrix} \text{for: } u_1^2+u_2^2 :=1 \\ \implies \]
\[ \text{we should verify the length: of our output-vector } \vec{b}\\ ||\vec{b}||=|| \begin{bmatrix} 4 \\ 3\end{bmatrix}||=\sqrt{4^2+3^2}=\sqrt{16+9}=\sqrt{25}=5 \\ \text{therefore, we can simply solve for } \hat{u} \ \text{and, adjust } \hat{u}\text{'s length by 5} \\ \therefore \\ \vec{b} \rightarrow \hat{u} \\ \implies \\ \hat{u}=\frac{\vec{b}}{||\vec{b}||}=\frac{<4,3>}{5}=<\frac{4}{5},\frac{3}{5}>=<0.8,0.6> =<u_1,u_2>\\ \text{note: } 0.8^2+0.6^2=0.64+0.36=1 \\ \therefore \]
\[ A(u_1,u_2)=\begin{bmatrix} u_1^2 & u_1u_2 \\ u_1u_2 & u_2^2\end{bmatrix} \\ \implies \\ \begin{bmatrix} (0.8)^2 & (0.8)(0.6) \\ (0.8)(0.6) & (0.6)^2\end{bmatrix}= \begin{bmatrix} 0.64 & 0.48 \\ 0.48 & 0.36\end{bmatrix} \\ \therefore \\ T_{\vec{x}^{||}} =\begin{bmatrix} 0.64 & 0.48 \\ 0.48 & 0.36\end{bmatrix} \]
Find the Determinant of all 7 main transformations discussed
in section 2.2:
\[
\text{Recall:} \\
\det
\begin{bmatrix} a & b \\ c & d \end{bmatrix} = ad - bc
\]
\[ for \ C= \text{constant} \\ CI_2= \begin{bmatrix} C & 0 \\ 0 & C \end{bmatrix} \\ det\begin{bmatrix} C & 0 \\ 0 & C \end{bmatrix} = C^2 \\ \]
\[ \text{however, Note:} \\ C\det \begin{bmatrix} 1 & 0 \\ 0 & 1\end{bmatrix} = 1*C=C \therefore \\ \implies \\ C \ne C^2 \\ C\det (I_2) \ne \det(CI_2) \ \text{or,} \\ C\det \begin{bmatrix} 1 & 0 \\ 0 & 1\end{bmatrix} \ne \det\begin{bmatrix} C & 0 \\ 0 & C \end{bmatrix} \]
Meaning the determinant of a scale is the scale squared ( \(C^2\) ).
\[ \text{recall:} \\ \begin{bmatrix} u_1^2 & u_1u_2 \\ u_1u_2 & u_2^2 \end{bmatrix} \\ \implies \\ det\begin{bmatrix} u_1^2 & u_1u_2 \\ u_1u_2 & u_2^2 \end{bmatrix}=u_1^2u_2^2+(u_1u_2)(u_1u_2)=u_1^2u_2^2-u_1^2u_2^2 \\ =0 \\ \therefore \det(proj_L(\vec{x}))=\det(\vec{x}^{||})=0 \]
Geometrically, consider that for the simplest case:
\[
\begin{bmatrix}
1 & 0 \\ 0 & 0
\end{bmatrix} \ \text{and, } \vec{x}=\begin{bmatrix}
x_1\\x_2 \end{bmatrix} \ \text{for: } x_1^2+x_2^2:=1
\]
the Orthogonal Projection is simply a vector which has been projected
into some lower-dimension or, the shadow casted by the original vector (
\(\vec{x}\) ). I have attached a video
and image to drive this point:
https://youtu.be/nklHMEQOkro?si=irEtPfbLvrjJA99a
It may be helpful to note:
\[ \text{Recall from Multivariable-Calculus that: }\\ \text{ "The Dot Product of Orthogonal Vectors is 0" }\\ \vec{x}^{||} \cdot\vec{x}^{\perp}=0 \\ \therefore \\ \vec{x}^{||} \cdot (\vec{x} - \vec{x}^{||} )=0 \]
\[ \text{recall: } \\ ref_L(\vec{x})= \begin{bmatrix} a & b \\ b &-a \end{bmatrix} \text{for: } a^2+b^2=1 \\ \therefore \]
\[ \det\begin{bmatrix} a & b \\ b &-a \end{bmatrix}= -a^2-b^2=-(a^2+b^2)=-1 \]
\[ \text{recall: } \\ Rot_\theta(\vec{x})= \begin{bmatrix} a & -b \\ b & a \end{bmatrix} \text{for: } a^2+b^2=1 \\ \therefore \]
\[ \det\begin{bmatrix} a & -b \\ b & a \end{bmatrix}=a^2-(-b)b=a^2-(-b^2)=a^2+b^2 =1\]
\[ Rot_{\theta,C}(\vec{x}) = \begin{bmatrix} Ca & -b \\ b & Ca \end{bmatrix} \\ \implies \]
\[ \det\begin{bmatrix} Ca & -b \\ b & Ca \end{bmatrix} =C^2a^2+b^2 \]
Horizontal shear:
\[ \text{recall: } \begin{bmatrix} 1 & C \\ 0 & 1 \end{bmatrix} \\ \therefore \\ \det\begin{bmatrix} 1 & C \\ 0 & 1 \end{bmatrix}=1*1+0*C=1+0=1 \]
Verticle shear:
\[ \text{recall: } \begin{bmatrix} 1 & 0 \\ C & 1 \end{bmatrix} \\ \therefore \\ \det\begin{bmatrix} 1 & C \\ 0 & 1 \end{bmatrix}=1*1+C*0=1+0=1 \]
This section focuses on the algebraic properties of matrix multiplication, emphasizing how matrices interact through operations like multiplication. It covers important theorems such as the associative and distributive properties of matrix multiplication, and introduces the concept of block matrices.
For matrices to multiply,
\[ A^{p \times m} \wedge B^{n \times p} \] or, equivalently: \(nrow(A)==ncol(B)\)
In the real-world we say, the number of \(observations\) in \(A\) is equal to the number of \(features\) of \(B\).
which, in mathematics, tell us if:
\[ A^{p \times m} \wedge B^{n \times p} \] \[ \implies BA \implies T(\vec{x}) \\ for:\\ T(\vec{x}) =B(A\vec{x})=(BA)\vec{x} \\ for: \vec{x} \in \mathbb{R^{2}} \]
Meaning, we can imagine \(BA\) as some Transformation ( \(T\) ) and, if we apply some \(T\) (transformation) on \(\vec{x}\), we can think of \(BA\) as a linear transformation on \(\vec{x}\). However, we must also note that due to \(linearity\) , we can perform one \(T_{linear}\) then perform the second. Which is the same as doing everything all at once.
\[\therefore \\ AB \ne T \\ AB \implies T_{linear} \implies \\ AB = \ matrix \]
Computationally, it is defined as:
In other words, its the sum of the observations in A times the features in B
# Function to manually perform matrix multiplication
manual_matrix_multiply <- function(A, B) {
# Get dimensions of matrices
n <- nrow(A)
p <- ncol(A)
m <- ncol(B)
# Initialize the result matrix with zeros
C <- matrix(0, n, m)
#makes code readible
num_observations <- 1:n
num_features <- 1:m
# Perform matrix multiplication
for (each_observation in num_observations){
for (each_feature in num_features) {
#The new matrix is sum(A[each_observation, ] * B[, each_feature])
C[each_observation, each_feature] <- sum(A[each_observation, ] * B[, each_feature])
}
}
#Show me the matrix:
return(C)
}
# Example usage
A <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, ncol = 3)
B <- matrix(c(7, 8, 9, 10, 11, 12), nrow = 3, ncol = 2)
result <- manual_matrix_multiply(A, B)
paste("it is", identical(result, A%*%B), "that manual_matrix_multiply() is matrix-mult. function")
## [1] "it is TRUE that manual_matrix_multiply() is matrix-mult. function"
result
## [,1] [,2]
## [1,] 76 103
## [2,] 100 136
A%*%B
## [,1] [,2]
## [1,] 76 103
## [2,] 100 136
Furthermore, lets note the unique property of the Identity-Matrix ( \(I_n\) ):
\[ I :\implies AI=A \]
\[ Recall: \\ BA \ne AB \\ \]
Meaning, matrix-mult. is not commutative (order matters).
Associative Mechanisms: Mechanisms in which, a change of order doesn’t change the results.
Commutative Mechanisms: Mechanisms in which, a change in order affects the results.
Suppose you have a rubber band ( \(\vec{R}_{ubberBand}\) ). We can describe states of the \(\vec{R}_{ubberBand}\) if we consider variables that may contribute to some outcome state (maybe “untwisted” or “long-twist” ):
\[ \{T,S\} = \{T_{wist},S_{tretch}\} \\ \vec{R}_{ubberBand} = \vec{R} \\ \therefore \\ (TS)\vec{R} \ne (ST)\vec{R} \]
Meaning, if we twist the rubber band then stretch it, we get a different rubber band than if we were to stretch then twist it. So, we know the relationship between \(T_{wist}\) and \(S_{tretch}\) shows us it is a NON-Commutative Mechanism.
This is because when we first twist the rubber band then stretch it, we undoes the twist. Unlike if we stretch the rubber band then twist it, we end up with a still twisted rubber band.
\[ \circ \rightarrow \infty \rightarrow O \\ twist \rightarrow stretch \\ \]
\[ \circ \rightarrow O \rightarrow \infty \\ stretch \rightarrow twist \]
However, suppose:
\[ \{T,S, B\} = \{T_{wist},S_{tretch}, B_{end}\} \\ T(SB)\vec{R}=TS(B\vec{R}) \]
Therefore, if we stretch and bend it then twist it, we get the same as though we bent it, twisted then stretch it. In other words, This tells us a rubber band is \(Associative\) but not \(Communitive\)–Just like matrix multiplication. In other words, this means the sequence of operations can be grouped differently but yield the same result, demonstrating associativity. However, changing the order of operations (like twisting and stretching) doesn’t necessarily yield the same outcome, showing non-commutativity.
Block matrices became a pivotal innovation in the 1960s and 1970s as computational needs surged. By breaking down large matrices into smaller submatrices, they revolutionized matrix multiplication, enabling efficient parallel processing and optimized memory usage. This capability became indispensable in the 2000s with the explosion of big data and the rise of machine learning, where massive Markov matrices are used to model complex systems, such as user behavior or financial markets. Block matrices empower these models to be handled swiftly and at scale, driving advancements in machine learning algorithms like hidden Markov models and enhancing the performance of large-scale data-driven predictions.
As the size of our matrices increases, we break down its dimensionality into “blocks” to create block-matrices forblock-matrix multiplication.
Transition matrices are crucial for modeling systems where the likelihood of events depends on previous states, such as in Markov chains. They became particularly important in big data and machine learning, where they help predict complex behaviors in large systems.
In other words, Transition matrices are matrices that describe the way in which transitions are made between states when, one state depends upon the previous. It is used when events are more or less likely depending on the previous event(s).
## A =
## Rainy Sunny
## Rainy 0.4 0.6
## Sunny 0.3 0.7
Meaning, if the chance of it raining depend upon if it rain the day before, we can use transition-matrices to describe this behavior. As given above^
Note:
We have a regular transition matrix if when we iterate for every future day (\(m\)) in a statistical test, we never get a negative probability. So we say it “regular”.
In other words, \(A^{m}\) tells us we will translate by \(A\), \(m\) times. In other words, if \(A\) is the transition matrix describing the likely hood of weather given the day before, if we iterate it \(m\) times, we are effectively saying:
\[ suppose: \ m = 5, \vec{C}_s=current \ state = \begin{bmatrix}1\\0\end{bmatrix} = \begin{bmatrix}sunny\\0\end{bmatrix} \\ \vec{C}_sA^{5} = \vec{F}_{utureState} \]
meaning, over 5 days, if the first day is sunny, over 5 days, we can expect the future state to be some % chance it is sunny and some % chance it is raining.
## A =
## Rainy Sunny
## Rainy 0.4 0.6
## Sunny 0.3 0.7
## A %*% A %*% A %*% A %*% A %*% current_state
##
## Predicted-Future State after 5 days if starting with Sunny:
## Rainy Sunny
## [1,] 0.33333 0.66667
In this specific data set, we notice the behavior that if it is rainy then it is more likely to be raining again and if it is sunny, it is more likely to be sunny. So since out initial state was “Sunny” (100% chance), we should expect to have a higher chance of it being sunny again–and, as we can see from out output-vector above (33% & 66%), we see this is computationally TRUE.
\[ A= \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \\ B= \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \\ AB=\ ? \\ \implies \\ recall: ncol(A) ==nrow(B) \therefore\\ \backsim \sum(A[i,]B[,k]) \\ let: C=AB \\ C= \begin{bmatrix} 1(1)+1(3) & 1(2) +1(4) \\0(1) +1(3) & 0(2) + 1(4) \end{bmatrix} = \begin{bmatrix} 4 & 6 \\3 & 4 \end{bmatrix} \]
A <- matrix(c(1,1,0,1), nrow =2 , ncol =2 , byrow=TRUE)
B <- matrix(1:4, nrow =2 , ncol =2 , byrow=TRUE)
A %*% B
## [,1] [,2]
## [1,] 4 6
## [2,] 3 4
\[ A= \begin{bmatrix} 1 & -1 \\ 0 & 2 \\ 2 & 1 \end{bmatrix} \\ B= \begin{bmatrix} 3 & 2 \\ 1 & 0 \end{bmatrix} \\ AB=\ ? \\ \implies \\ recall: ncol(A) ==nrow(B) \therefore\\ \backsim \sum(A[i,]B[,k]) \\ let: C=AB \\ C= \begin{bmatrix} 1(3)-1(1) & 1(2)-1(0) \\ 0(3)+2(1) & 0(2)+2(0) \\ 2(3)+1(1) & 2(2)+1(0) \end{bmatrix} = \begin{bmatrix} 2 & 1 \\ 2 & 0 \\ 7 & 4 \end{bmatrix} \]
A <- matrix(c(1,-1,0,2,2,1), nrow =3 , ncol =2 , byrow=TRUE)
B <- matrix(c(3, 2,1,0), nrow =2 , ncol =2 , byrow=TRUE)
A %*% B
## [,1] [,2]
## [1,] 2 2
## [2,] 2 0
## [3,] 7 4
\[ A= \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} \\ B= \begin{bmatrix} 1 & 2\\ 3 & 4 \end{bmatrix} \\ AB = \ ? \\ recall:ncol(A) ==nrow(B) \ but: 3!=2 \\ \therefore \\ AB \ DNE \]
A <- matrix(1:6, nrow =2 , ncol =3 , byrow=TRUE)
B <- matrix(1:4, nrow =2 , ncol =2 , byrow=TRUE)
# A %*% B
\[ A= \begin{bmatrix} 1 & -1 \\ -2 & 2 \end{bmatrix} \\ B= \begin{bmatrix} 7 & 5\\ 3 & 1 \end{bmatrix} \\ AB = \ ? \\ recall:ncol(A) == nrow(B)\\ \therefore \\ let: C=AB \\ C= \begin{bmatrix} 1(7)-1(3) & 1(5)-1(1) \\ -2(7)+2(3) & -2(5)+2(1) \end{bmatrix} = \begin{bmatrix} 4 & 4 \\ -8 & -8 \end{bmatrix} \]
A <- matrix(c(1,-1,-2,2), nrow =2 , ncol =2 , byrow=TRUE)
B <- matrix(c(7,5,3,1), nrow =2 , ncol =2 , byrow=TRUE)
A %*% B
## [,1] [,2]
## [1,] 4 4
## [2,] -8 -8
Have you ever forgotten which key opens your apartment door? Trying key after key until one just works. Inverse transformations are the same: only one function ( \(T^{-1}\) ) or matrix will perfectly reverse the process, “unlocking” the original state. Just like finding the one key that fits, determining the correct inverse for a matrix or function relies on meeting the right conditions. Here are some of the definitions and theorems helpful to understanding which key fits.
Meaning, A Linear Transformation exists if the following exist:
\[ T:X \rightarrow Y \\ T^{-1}:Y \rightarrow X \]
A square matrix ( \(A^{n \times n}\) ) has an inverse function only if:
\[ rref(A^{n \times n})=I_n \]
\[ or, equivalently: \\ rank(A^{n \times n})=n \]
Furthermore, when an \(A^{n \times n}\) is not invertible, it means the system either has infinite solutions or no-solution. This indicates that the system is either overdetermined (no solution) or underdetermined (infinite solutions), much like trying to solve a puzzle with either too many missing pieces or too many pieces that fit in multiple places.
We can think of the inverse of the product of matrices \(A\) and \(B\) as locations encoded to ensure safety against the threat. Consider the following locations:
Picture yourself in the tense atmosphere of World War II, where every coded message could determine the fate of a mission. The matrices \(A\) and \(B\) act as the encryption and decryption keys, masking the true location of a military ship as it journeys from Marseille to Paris. As you decode the messages, you also reveal the ship’s exact position— \(\vec{y}\) is Marseille, \(\vec{z}\) is Paris, and \(\vec{x}\) is the ship.
First consider that:
\[ I_{nverse}(A^{n \times n})=I_n \\ \begin{bmatrix} A^{-1} |& I_n\end{bmatrix} \]
If \(rref\begin{bmatrix} A^{-1} &| \ I_n\end{bmatrix}\) is of the form \(A^{-1}=B\) then, \(A\) is invertible.
If \(rref\begin{bmatrix} A^{-1} & \ | \ I_n\end{bmatrix}\) is of the form \(A^{-1} \ne B\) then, \(A\) is not-invertible.
Note that for any 2D-Matrix:
\[ A= \begin{bmatrix} a & b \\ c & d \end{bmatrix} \\ det(A) \ne 0 \\ \implies \\ A^{-1} \ Exists \\ \implies A^{-1}=\frac{1}{ad-bc} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix} =\frac{1}{det(A)} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}\\ \]
Imagine you’re planning a garden and need to make sure your layout fits perfectly within the space—so you use the determinant. You do this because you know the determinant measures the exact area and angles of your design to ensure everything fits smoothly so you can happily plant, plants. Now recall the key example from the introduction of 2.4, where there is one unique key that “unlocks” the door. This binary nature is reflected in the \(det\)–specifically, if \(det(a) \ne 0\), it means there exists a key on your keychain that opens the door; but if \(det(A) = 0\), unfortunately, this means someone’s playing a trick on you as the key to open the door doesn’t actually exist– meaning nobody can unlock it!
In other words, notice:
\[ \det(A) = \det( \begin{bmatrix} \vec{a} \\ \vec{b}\end{bmatrix}) \ for: A=\begin{bmatrix} \vec{a} \\ \vec{b}\end{bmatrix} \\ \implies \\ \det(A) = ||\vec{a}|| \ ||\vec{b}|| \sin(\theta) \ for: \theta \implies \vec{a} \rightarrow\vec{b} \\ \implies \\ |\det(A)| = A_{rea} \]
Specifically, the \(A_{rea}\) is of a parallelogram spanned by \(\vec{a}\) and \(\vec{b}\), furthermore:
if \(\det(A) = 0:\) then, \(\vec{a}||\vec{b} \implies \theta=0^{\circ}=\pi \ radians\)
if \(\det(A) > 0:\) then, \(0^{\circ}<\theta<180^{\circ}\)
if \(\det(A) < 0:\) then, \(0^{\circ}>\theta>-180^{\circ}\)
Meaning we can imagine the determinant as a representation of:
Area of a parallelogram ( \(|\det(A)|=A_{rea}\) ) or,
angle between vectors ( \(det(a) \{>\ or, < \ or, =\} 0\) )
Decide whether the matrices in Exercises 1 through 15 are invertible. If they are, find the inverse. Do the computa- tions with paper and pencil. Show all your work.
\[ A=\begin{bmatrix} 1 & 2 & 3 \\ 0 & 1 & 2 \\ 0 & 0 & 1 \end{bmatrix} \\ note: A^{3 \times 3} = A^{n \times n} \ \\ Rank(A) = 3 \\ \implies \\ Rank(A) = n \therefore Sol. \ Exists \ and, \\ recall: det(A) \ne 0 \iff A^{-1} \ Exists \\ \therefore \\ \]
\[ det(A)=\begin{bmatrix} 1 & 2 & 3 \\ 0 & 1 & 2 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 2 \\ 0 & 1 \\ 0 & 0 \end{bmatrix} \\ = [(1 * 1 * 1) + (2*2*0)+(3*0*0)]-[(2*0*1)+(1*2*0)+(3*1*0)] \\ =[(1+0+0)-(0+0+0)] \\ = [1-0] \\ = 1 \\ \therefore \\ via \ det(A) \implies \ Sol. Exits \]
\[ recall: \\ A^{-1}A=I_n \\ \implies \\ A^{-1} \begin{bmatrix} 1 & 2 & 3 \\ 0 & 1 & 2 \\ 0 & 0 & 1 \end{bmatrix}= \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \\ Furthermore, \ note: \\ A\vec{x}=\vec{b} \ then \ A^{-1}A\vec{x}=\vec{x} \]
\[ \implies \\ \begin{bmatrix} 1 & 2 & 3 \\ 0 & 1 & 2 \\ 0 & 0 & 1 \end{bmatrix}\vec{x}=\vec{b} \\ \implies \\ \begin{bmatrix} x_1 & 2x_2 & 3x_3 & b_1 \\ 0 & x_2 & 2x_3 & b_2 \\ 0 & 0 & x_3 & b_3 \end{bmatrix} \\ \implies \\ \begin{bmatrix} x_1 & 0 & 0 & (b_1-3b_3)-2(b_2-2b_3) \\ 0 & x_2 & 0 & b_2-2b_3 \\ 0 & 0 & x_3 & b_3 \end{bmatrix} \]
\[ x_1=b_1-2b_2+b_3 \\ x_1=b_2-2b_3 \\ x_2=b_3 \]
\[ A^{-1}=\begin{bmatrix} 1 & -2 & 1 \\ 0 & 1 & -2 \\ 0 & 0 & 1 \end{bmatrix} \]
A <- matrix(c(1,2,3,0,1,2, 0, 0, 1), nrow =3 , ncol =3 , byrow=TRUE)
B <- matrix(c(1, -2, 1, 0, 1, -2, 0, 0, 1), nrow =3 , ncol =3 , byrow=TRUE)
#Verification:
A %*% B
## [,1] [,2] [,3]
## [1,] 1 0 0
## [2,] 0 1 0
## [3,] 0 0 1
\[ A=\begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} \\ note: A^{3 \times 3} = A^{n \times n} \ \\ rref(A)= \begin{bmatrix} 1 & 1 & 1 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix} \\ Rank(rref(A)) = 1 \\ \implies \\ Rank(A) \ne n \therefore Sol. \ DNE \ Exists \]