Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 31
1
\documentclass{article}
2
3
% set font encoding for PDFLaTeX or XeLaTeX
4
\usepackage{ifxetex}
5
\ifxetex
6
\usepackage{fontspec}
7
\else
8
\usepackage[T1]{fontenc}
9
\usepackage[utf8]{inputenc}
10
\usepackage{lmodern}
11
\fi
12
13
% used in maketitle
14
\title{Lab 1 Report}
15
\author{Isaac Shaeffer and Satori Kubo}
16
17
% Enable SageTeX to run SageMath code right inside this LaTeX file.
18
% documentation: http://mirrors.ctan.org/macros/latex/contrib/sagetex/sagetexpackage.pdf
19
% \usepackage{sagetex}
20
21
\usepackage{amsmath}
22
\usepackage{amssymb}
23
\usepackage{listings}
24
25
\begin{document}
26
\maketitle
27
28
\begin{enumerate}
29
% 1a - 1d
30
\item
31
\begin{enumerate}
32
% 1a
33
\item The show() function renders uses formated text or Latex to render output.
34
% 1b
35
\item Changing the ring from QQ to RR forces the data in the matrix $A$ to be treated as floating point values. Changing the ring from QQ to RDF forces the data to take on a single decimal point.
36
% 1c
37
\item $ B \sim \left[\begin{array}{rrr} 1 & 0 & \frac{21}{2} \\ 0 & 1 & -\frac{1}{2} \end{array} \right] $
38
% 1d
39
\item The command \verb|I4 = identity_matrix(4)| assigns the \( \mathbb{R}^4 \) identity matrix to the variable \verb|I4|. Changing the number 4 to some other integer, say n, assigns the identity matrix for $ \mathbb{R}^n $ to a variable.
40
\end{enumerate}
41
42
% 2a - 2d
43
\item
44
\begin{enumerate}
45
% 2a
46
47
\item Assuming we are using the matrices $A$ and $B$ defined in part 1, we can use matrix addition or subtraction if we restrict the number of columns of $B$ to match the number columns in $A$ with the command \verb|matrix_from_columns([0,1])|. Note that in the argument \verb|[0,1]|, the number 0 is referring to the first column of B and 1 is referring to the second column. The following code
48
\begin{lstlisting}[language=Python]
49
A = matrix(QQ,[[1, 2],[3,4]])
50
B = matrix(QQ, [[0, 2, -1],[1, 1, 10]])
51
52
C = A + B.matrix_from_columns([0,1])
53
show(C)
54
\end{lstlisting}
55
generates the output $\left[\begin{array}{rr} 1 & 4 \\4 & 5 \end{array}\right].$
56
57
\item The command \verb|B.transpose()| creates a new matrix $B^T$ that uses of the rows of B as its columns. That is
58
$$
59
B \sim \left[\begin{array}{rrr}
60
0 & 2 & -1 \\
61
1 & 1 & 10
62
\end{array}\right]
63
\text{ and } B^T \sim
64
\left[\begin{array}{rr}
65
0 & 1 \\
66
2 & 1 \\
67
-1 & 10
68
\end{array}\right].
69
$$
70
71
\item
72
\begin{enumerate}
73
74
% 2. (c) i.
75
\item Does $(AB)^T = A^TB^T$ for any two matrices $A, B$ where $AB$ is defined?
76
No, since there exist two matrices $A, B$ where $AB$ is defined but $(AB)^T \neq A^TB^T$. \par
77
For example, let $A = \left(\begin{array}{rr}1 & 1 \\1 & 1\end{array}\right) \text{ and } B = \left[\begin{array}{rr}-2 & -3 \\0 & 7\end{array}\right]$. Then
78
$$
79
(AB)^T = \left[\begin{array}{rr}
80
-2 & -2 \\
81
4 & 4
82
\end{array}\right]
83
\text{ and } A^TB^T =
84
\left[\begin{array}{rr}
85
-5 & 7 \\
86
-5 & 7
87
\end{array}\right].
88
$$
89
90
Thus $(AB)^T \neq A^TB^T$.
91
92
% 2. (c) ii.
93
94
\item Does $(A+B)^T =A^T +B^T$ for any two matrices A,B where $A+B$ is defined? \par
95
96
Yes, since by Theorem 2.3 part b., we have $(A+B)^T =A^T +B^T$ for any two matrices $A,B$ where $A+B$ is defined.
97
98
% 2. (c) iii.
99
100
\item Does $(cA)^T = cA^T$ for any matrix A and scalar c? \par
101
102
Yes, since by Theorem 2.3 part c., we have $(rA)^T = rA^T$ for a matrix A and any scalar r.
103
\end{enumerate}
104
105
% 2. (d)
106
\item
107
108
\begin{enumerate}
109
% 2. (d) i.
110
\item What happens when you use the inverse command on matrix A from lab task 1? Does it match the formula for a $2 \times 2$ matrix inverses given in section 2.1? \par
111
112
Using \verb|A.inverse()| gives us the the matrix $\left[\begin{array}{rr} -2 & 1 \\\ \frac{3}{2} & -\frac{1}{2} \end{array}\right]$. The inverse formula from section 2.1 gives us the same matrix. So the formula matches what we get from the inverse command.
113
114
% 2. (d) ii.
115
\item What happens when you use the determinant command on matrix A from lab task 1? Does it match the formula for a $2 \times 2$ matrix determinant given in exam 1? \par
116
117
Using \verb|A.det()| returns $-2$. Since $det(A) = 4\cdot 1 - 2\cdot 3 = -2$, \verb|A.det()| matches the formula for a $2 \times 2$ matrix given in exam 1.
118
119
% 2. (d) iii.
120
\item What happens when you use the inverse command on matrix B from lab task 1? Explain what’s happening here? \par
121
122
Using \verb|B.inverse()| returns the error message $$\texttt{ArithmeticError: self must be a square matrix}.$$ This error occurs because inverse matrices are only defined for square matrices and $B$ is not a square matrix.
123
124
125
% 2. (d) iv.
126
\item Define a $2 \times 2$ matrix whose determinant is zero. What happens when you try to determine the inverse of this matrix in Sage? \par
127
128
We have $det(A) = 0$ when $D = \displaystyle \left[\begin{array}{rr} 6 & 3 \\ 4 & 2 \end{array} \right]$. Using \verb|D.inverse()| returns the error $$\texttt{ZeroDivisionError: Matrix is singular}$$
129
130
% 2. (d) v.
131
\item Does $(A^T)^{-1} = (A^{-1})^T$, where A is the matrix from lab task 1? In your report, write down the lines of code you used to determine if this is true or not. \par
132
133
The relationship $(A^T)^{-1} = (A^{-1})^T$ is true for the matrix $A$ since
134
\[
135
(A^T)^{-1} =
136
\left[\begin{array}{rr}
137
-2 & \frac{3}{2} \\
138
1 & -\frac{1}{2}
139
\end{array}\right]
140
\text{ and }
141
(A^{-1})^T =
142
\left[\begin{array}{rr}
143
-2 & \frac{3}{2} \\
144
1 & -\frac{1}{2}
145
\end{array}\right]
146
\]
147
148
We used the following code in Sage:
149
\begin{lstlisting}[language=Python]
150
151
A = matrix(QQ,[[1, 2],[3,4]])
152
153
(A.transpose()).inverse()
154
(A.inverse()).transpose()
155
156
show("$(A^T)^{-1}$ =", (A.transpose()).inverse())
157
show("$(A^{-1})^T$ =", (A.inverse()).transpose())
158
159
\end{lstlisting}
160
161
162
\end{enumerate}
163
164
\end{enumerate}
165
166
% 3a - 3i.
167
\item Let's explore the geometry of linear transformation $T: \mathbb{R}^2 \to \mathbb{R}^2 $. Use the code below to define $ M = \displaystyle \left[\begin{array}{rr} -1 & 0 \\ 0 & 1 \end{array} \right] $ and the column vectors, $ \vec{e_1} $ and $ \vec{e_2} $ of the $ 2 \times 2 $ identity matrix.
168
169
\begin{enumerate}
170
% 3a
171
\item Describe the output of this code. What are the blue arrows compared to the purple arrows? \par
172
173
The blue arrows are the vectors, $\vec{e_1}=\verb|[1,0]|$, $\vec{e_2}=\verb|[0,1]|$, $\vec{u_1}=\verb|[1,2]|$, and $\vec{u_2}=\verb|[-2,-1]|$. The purple arrows are the transformed vectors, $M*\vec{e_1}=\verb|[-1,0]|$, $M*\vec{e_2}=\verb|[0,1]|$, $M*\vec{u_1}=\verb|[-1,2]|$, and $M*\vec{u_2}=\verb|[2,-1]|$.
174
175
% 3b
176
\item Consider $M : \mathbb{R}^2 \to \mathbb{R}^2$ as a linear transformation. Describe how $M$ transforms an input vector $\vec{v}$. \par
177
The geometry of the transformation is a reflection through the ${x_2}$-axis.
178
179
% 3c
180
\item Change matrix $M$ in the code to $M1=\displaystyle \left[\begin{array}{rr} 0 & 1 \\ 1 & 0 \end{array} \right]$ and describe how $M1$ transforms vectors in $\mathbb{R}^2$. \par
181
The geometry of the transformation is a reflection through the line ${x_2}$ = ${x_1}$. \par
182
183
% 3d
184
\item Change matrix $M$ in the code to $M2=\displaystyle \left[\begin{array}{rr} 0 & -1 \\ -1 & 0 \end{array} \right]$ and describe how $M2$ transforms vectors in $\mathbb{R}^2$. \par
185
The geometry of the transformation is a reflection through the line ${x_2}$ = $-{x_1}$. \par
186
187
% 3e
188
\item Change matrix $M$ in the code to $M3=\displaystyle \left[\begin{array}{rr} 1 & 0 \\ 0 & 0 \end{array} \right]$ and describe how $M3$ transforms vectors in $\mathbb{R}^2$. \par
189
The geometry of the transformation is a projection onto the ${x_1}$-axis. \par
190
191
% 3f
192
\item Change matrix $M$ in the code to $M4=\displaystyle \left[\begin{array}{rr} 0 & 2 \\ 4 & 0 \end{array} \right]$ and describe how $M4$ transforms vectors in $\mathbb{R}^2$. \par
193
The geometry of the transformation is a reflection through the line ${x_2}$ = ${x_1}$ and stretching horizontally and vertically by factors of 2 and 4, respectively. \par
194
195
% 3g
196
\item Change the first two lines in the code to the following. Then change the value of $\theta$ (theta) to see what happens to the vectors. Describe what the transformation $R=\displaystyle \left[\begin{array}{rr} \cos(\theta) & \sin(\theta) \\ -\sin(\theta) & \cos(\theta) \end{array} \right]$ does to vectors in $\mathbb{R}^2$. \par
197
The geometry of the transformation is a clockwise rotation around the origin by $\theta$ radians.
198
199
% 3h
200
%\item Compute $M2*R$ and describe the transformation it does to vectors in $\mathbb{R}^2$. Then do the same for $R*M2$. \par
201
%$M2*R = \left(\begin{array}{rr}\sin\left(\theta\right) & -\cos\left(\theta\right) \\-\cos\left(\theta\right) & -\sin\left(\theta\right)\end{array}\right)$;
202
%therefore, the geometry of the transformation is a reflection through the ${x_1}$-axis. Also, $R*M2 = \displaystyle \left[\begin{array}{rr} -1 & 0 \\ 0 & 1 \end{array} \right]$; therefore, the geometry of the transformation is a reflection through the ${x_2}$-axis. \par
203
204
% 3. (h) redo
205
\item Compute $M2*R$ and describe the transformation it does to vectors in $\mathbb{R}^2$. Then do the same for $R*M2$. \par
206
207
The matrix $M2*R = \left[\begin{array}{rr} \sin\left(\theta\right) & -\cos\left(\theta\right) \\ -\cos\left(\theta\right) & -\sin\left(\theta\right) \end{array}\right]$. \par
208
This transformation rotates a vector clockwise $\theta$ radians about the origin and then reflects the rotated vector through the line $x_2 = -x_1$.
209
210
The matrix $R*M2 = \left[\begin{array}{rr} -\sin\left(\theta\right) & -\cos\left(\theta\right) \\ -\cos\left(\theta\right) & \sin\left(\theta\right) \end{array}\right]$. \par
211
This transformation first reflects a vector through the line $x_2 = -x_1$ and then rotates the reflected vector clockwise $\theta$ radians about the origin.
212
213
214
% 3i
215
\item For $\theta=\frac{\pi}{2}$, compute $R^2=R*R$ and describe the transformation it does to vectors in $\mathbb{R}^2$. \par
216
$R^2=R*R= \left[\begin{array}{rr} 0 & 1 \\ -1 & 0 \end{array}\right] \left[\begin{array}{rr} 0 & 1 \\ -1 & 0 \end{array}\right] = \left [\begin {array}{rr} -1 & 0 \\ 0 & -1 \end {array} \right]$. Therefore, the geometry of the transformation is a reflection through the origin. \par
217
218
219
\end{enumerate}
220
221
% 4
222
\item
223
\begin{enumerate}
224
\item Let $I_2 = \left[ \vec{e}_1 \text{ } \vec{e}_2\right] = \left[\begin{array}{rr}1 & 0 \\ 0 & 1\end{array}\right]$ , let $T: \mathbb{R}^2 \to \mathbb{R}^2 \text{ be the transformation } T\left( \left[ \begin{array}{r} a \\ b \end{array} \right] \right) = \left[ \begin{array}{r} a - b \\ a+ b \end{array} \right]$ and let $A$ be the standard matrix for T. \par
225
226
First, we will show that $T$ is linear. Thus,
227
\[
228
\begin{split}
229
T\left( \left[ \begin{array}{r} a \\ 0 \end{array} \right] + \left[ \begin{array}{r} 0 \\ b \end{array} \right]\right) &= T\left( \left[ \begin{array}{r} a \\ b \end{array} \right] \right) \\
230
&= \left[ \begin{array}{r} a - b \\ a + b \end{array} \right] \\
231
&= \left[ \begin{array}{r} a - 0 \\ a + 0 \end{array} \right] + \left[ \begin{array}{r} 0 - b \\ 0 + b \end{array} \right] \\
232
&= T\left(\left[ \begin{array}{r} a \\ 0 \end{array} \right] \right) + T\left(\left[ \begin{array}{r} 0 \\ b \end{array} \right] \right). \\
233
\end{split}
234
\]
235
236
Now we will find the standard matrix of T. Thus
237
238
\[
239
\begin{split}
240
T(\vec{e}_1 )
241
&= T\left(\left[ \begin{array}{r} 1 \\ 0 \end{array} \right] \right)
242
= \left[ \begin{array}{r} 1 - 0 \\ 1 + 0 \end{array} \right]
243
= \left[ \begin{array}{r} 1 \\ 1 \end{array} \right] \text{ and }\\
244
T(\vec{e}_2)
245
&= T\left(\left[ \begin{array}{r} 0 \\ 1 \end{array} \right] \right)
246
= \left[ \begin{array}{r} 0 - 1 \\ 0 + 1 \end{array} \right]
247
= \left[ \begin{array}{r} -1 \\ 1 \end{array} \right].
248
\end{split}
249
\]
250
So it follows that \[
251
A
252
= \left[ T(\vec{e_1}) \text{ } T(\vec{e_2}) \right]
253
= \left[ \begin{array}{rr} 1 & -1 \\ 1 & 1 \end{array} \right].
254
\]
255
256
\item Evaluating the left side changes the standard matrix to $\left(\begin{array}{rr}1 & 1 \\ -1 & 1\end{array}\right)$.
257
258
\end{enumerate}
259
260
% 5
261
\item Let $J: \mathbb{R}^2 \to \mathbb{R}^4$ map
262
$\left[ \begin{array}{r} x_1 \\ x_2 \end{array} \right] = \left[ \begin{array}{cc} 2x_1 -5x_1 \\ 0 \\ x_1 + 4x_2 \\ x_2 \end{array} \right].$ \par
263
Then the columns of the standard matrix for J are
264
\[
265
\begin{split}
266
&J \left( \left[ \begin{array}{r} 1 \\ 0 \end{array} \right] \right) = \left[ \begin{array}{cc} 2\cdot1 -5\cdot0 \\ 0 \\ 1 + 4\cdot0 \\ 0 \end{array} \right] = \left[ \begin{array}{cc} 2 \\ 0 \\ 1 \\ 0 \end{array} \right] \text{ and } \\
267
&J \left( \left[ \begin{array}{r} 0 \\1 \end{array} \right] \right) = \left[ \begin{array}{cc} 2\cdot0 -5\cdot1 \\ 0 \\ 0 + 4\cdot1 \\ 1 \end{array} \right] = \left[ \begin{array}{rr} -5 \\ 0 \\ 4 \\ 2 \end{array} \right].
268
\end{split}
269
\]
270
Therefore, the standard matrix for J is $ \left[ \begin{array}{rr} 2 & -5 \\ 0 & 0 \\ 1 & 4 \\ 0 & 1 \end{array}\right]$.
271
\end{enumerate}
272
273
\end{document}
274