Debian Codegraph @

texmf-dist/doc/latex/seu-ml-assign/seu-ml-assign-sample.tex

raw
1 %! TEX program = pdflatex
2
3 \documentclass[oneside,solution]{seu-ml-assign}
4
5 \title{Assignment}
6 \author{Teddy van Jerry}
7 \studentID{61520522}
8 \instructor{TeX - LaTeX Stack Exchange}
9 \date{\today}
10 \duedate{20:00 March 21, 2022}
11 \assignno{1}
12 \semester{SEU --- 2022 Spring}
13 \mainproblem{Linear Algreba}
14
15 \begin{document}
16
17 \maketitle
18
19 % \startsolution[print]
20
21 \problem{Basic Vector Operations}
22 \subproblem{}
23 $\|\mathbf{a}\|_2=\sqrt{1^2+2^2+3^2}=\sqrt{14},\quad \|\mathbf{b}\|_2=\sqrt{(-8)^2+1^2+2^2}=\sqrt{69}$.
24
25 \subproblem{}
26 $\|\mathbf{a}-\mathbf{b}\|_2=\sqrt{9^2+1^2+1^2}=\sqrt{83}$.
27
28 \subproblem{}
29 $\mathbf{a}$ and $\mathbf{b}$ are orthogonal.
30 \begin{proof}
31 The inner product of vectors $\mathbf{a}$ and $\mathbf{b}$ is
32 \begin{equation}
33 \langle\mathbf{a},\mathbf{b}\rangle=\mathbf{a}^T\mathbf{b}=1\times(-8)+2\times 1+3\times 2=0,
34 \end{equation}
35 therefore $\mathbf{a}$ and $\mathbf{b}$ are orthogonal.
36 \end{proof}
37
38 \problem{Basic Matrix Operations}
39 According to the consensus, the matrix notation should be the bold upper-case letter like $\mathbf{A}$ or $\bm{A}$, not $A$.
40
41 \subproblem{}
42 \begin{equation}
43 \begin{aligned}
44 [\mathbf{A}, \mathbf{I}_3]&=
45 \begin{bNiceArray}{rrr:rrr}
46 1&-3&3&1&0&0\\3&-5&3&0&1&0\\6&-6&4&0&0&1
47 \end{bNiceArray}\sim
48 \begin{bNiceArray}{rrr:rrr}
49 1&-3&3&1&0&0\\0&4&-6&-3&1&0\\0&12&-14&-6&0&1
50 \end{bNiceArray}\sim
51 \begin{bNiceArray}{rrr:rrr}
52 1&-3&3&1&0&0\\0&4&-6&-3&1&0\\0&0&4&3&-3&1
53 \end{bNiceArray}\\
54 &\sim
55 \begin{bNiceArray}{rrr:rrr}
56 1&-3&0&-\frac{5}{4}&\frac{9}{4}&\frac{3}{4}\\[0.3em]0&4&0&\frac{3}{2}&-\frac{7}{2}&-\frac{3}{2}\\[0.3em]0&0&1&\frac{3}{4}&-\frac{3}{4}&\frac{1}{4}
57 \end{bNiceArray}\sim
58 \begin{bNiceArray}{rrr:rrr}
59 1&0&0&-\frac{1}{8}&-\frac{3}{8}&\frac{3}{8}\\[0.3em]0&1&0&\frac{3}{8}&-\frac{7}{8}&\frac{3}{8}\\[0.3em]0&0&1&\frac{3}{4}&-\frac{3}{4}&\frac{1}{4}
60 \end{bNiceArray},
61 \end{aligned}
62 \end{equation}
63 where $\mathbf{I}_3$ is the $3\times 3$ identity matrix.
64 Therefore we have
65 \begin{equation}\label{eq:2-1-inv}
66 \mathbf{A}^{-1}=
67 \begin{bNiceArray}{rrr}
68 -\frac{1}{8}&-\frac{3}{8}&\frac{3}{8}\\[0.3em]\frac{3}{8}&-\frac{7}{8}&\frac{3}{8}\\[0.3em]\frac{3}{4}&-\frac{3}{4}&\frac{1}{4}
69 \end{bNiceArray}.
70 \end{equation}
71 The determinant of matrix $\mathbf{A}$ can be calculated as
72 \begin{equation}\label{eq:2-1-det}
73 \mathrm{det}(\mathbf{A})=1\times\begin{vNiceArray}{rr}
74 -5&3\\-6&4
75 \end{vNiceArray}-(-3)\times\begin{vNiceArray}{rr}
76 3&3\\6&4
77 \end{vNiceArray}+3\times\begin{vNiceArray}{rr}
78 3&-5\\6&-6
79 \end{vNiceArray}=1\times(-2)+3\times(-6)+3\times 12=16,
80 \end{equation}
81 where $|\cdot|$ denotes the determinant.
82
83 \subproblem{}
84 The rank of matrix $\mathbf{A}$ is $3$ because as is shown in Eq.~\eqref{eq:2-1-inv} the matrix $\mathbf{A}$ is invertible.
85
86 \subproblem{}
87 The trace of matrix $\mathbf{A}$ is
88 \begin{equation}
89 \mathrm{tr}(\mathbf{A})=\sum_{i=1}^{3}a_{ii}=1+(-5)+4=0.
90 \end{equation}
91
92 \begin{equation}
93 \mathbf{A}+\mathbf{A}^{T}=\begin{bNiceArray}{rrr}
94 1&-3&3\\3&-5&3\\6&-6&4
95 \end{bNiceArray}+
96 \begin{bNiceArray}{rrr}
97 1&3&6\\-3&-5&-6\\3&3&4
98 \end{bNiceArray}=
99 \begin{bNiceArray}{rrr}
100 2&0&9\\0&-10&-3\\9&-3&8
101 \end{bNiceArray}.
102 \end{equation}
103
104 \subproblem{}
105 \begin{equation}
106 \mathbf{A}+\mathbf{A}^{T}=\begin{bNiceArray}{rrr}
107 1&-3&3\\3&-5&3\\6&-6&4
108 \end{bNiceArray}+
109 \begin{bNiceArray}{rrr}
110 1&3&6\\-3&-5&-6\\3&3&4
111 \end{bNiceArray}=
112 \begin{bNiceArray}{rrr}
113 2&0&9\\0&-10&-3\\9&-3&8
114 \end{bNiceArray}.
115 \end{equation}
116
117 \subproblem{}
118 $\mathbf{A}$ is not an orthogonal matrix.
119 \begin{proof}
120 Assume $\mathbf{A}$ is an orthogonal matrix,
121 therefore
122 \begin{equation}
123 \mathbf{AA}^{T}=\mathbf{I}_3,
124 \end{equation}
125 Take the determinant at both side, it can be derived that
126 \begin{equation}
127 |\mathrm{det}(\mathbf{A})|=\sqrt{|\mathbf{A}||\mathbf{A}^T|}=|\mathrm{det}(\mathbf{I}_3)|=1,
128 \end{equation}
129 which contradicts with Eq.~\eqref{eq:2-1-det}.
130 Therefore, the assumption is false.
131 \end{proof}
132
133 \subproblem{}
134 Let $f(\lambda)$ be the characteristic function of matrix $\mathbf{A}$ and
135 \begin{equation}\label{eq:2-6-f}
136 f(\lambda)=\begin{vNiceArray}{ccc}
137 \lambda-1&3&-3\\-3&\lambda+5&-3\\-6&6&\lambda-4
138 \end{vNiceArray}=(\lambda-4)(\lambda+2)^2,
139 \end{equation}
140 therefore the eigenvalues are $\lambda_1=4, \lambda_2=\lambda_3=-2$.
141 Let the corresponding eigenvectors be $\bm{\alpha}_i$, $i=1,2,3$.
142 \begin{equation}
143 (\mathbf{A}-\lambda_i\mathbf{I}_3)\bm{\alpha}_i=\mathbf{0},\quad i=1,2,3,
144 \end{equation}
145 and the corresponding eigenvectors are
146 \begin{equation}
147 \bm{\alpha}_1=\begin{bNiceArray}{ccc}1&1&2\end{bNiceArray}^T,\quad
148 \bm{\alpha}_{2,3}=\begin{bNiceArray}{ccc}1&1+c_{2,3}&c_{2,3}\end{bNiceArray}^T,
149 \end{equation}
150 where $c_{2,3}\in\mathbb{R}$.
151 Without loss of generality, we take $c_2=0$ and $c_3=-1$, and we have $\bm{\alpha}_2=\begin{bNiceArray}{ccc}1&1&0\end{bNiceArray}^T$ and $\bm{\alpha}_2=\begin{bNiceArray}{ccc}1&0&-1\end{bNiceArray}^T$.
152
153 \subproblem{}
154 Use the result from Eq.~\eqref{eq:2-6-f}, the matrix $\mathbf{A}$ can be diagonalized as
155 \begin{equation}
156 \bm{\Lambda}=\begin{bNiceArray}{rrr}
157 4&0&0\\0&-2&0\\0&0&-2
158 \end{bNiceArray}.
159 \end{equation}
160
161 \subproblem{}
162 The $\ell_{2,1}$ norm of $\mathbf{A}$ is
163 \begin{equation}
164 \|\mathbf{A}\|_{2,1}=\sum_{i=1}^3\sqrt{\sum_{j=1}^3a_{ij}^2}=\sqrt{46}+\sqrt{70}+\sqrt{34}\approx 20.98,
165 \end{equation}
166 and the Frobenius norm of $\mathbf{A}$ is
167 \begin{equation}
168 \|\mathbf{A}\|_F=\sqrt{\sum_{i,j=1,\mathrlap{2,3}}a_{ij}^2}=\sqrt{150}=5\sqrt{6}\approx 12.247.
169 \end{equation}
170
171 \subproblem{}
172 The nuclear norm of $\mathbf{A}$ is
173 \begin{equation}
174 \|\mathbf{A}\|_*=\mathrm{tr}(\sqrt{\mathbf{A}\mathbf{A^*}})=\sum_{i=1}^3\sigma_i(\mathbf{A})\approx 14.728,
175 \end{equation}
176 and the spectral norm of $\mathbf{A}$ is
177 \begin{equation}
178 \|\mathbf{A}\|_2=\max\sigma_i(\mathbf{A})\approx 12.065.
179 \end{equation}
180
181 \vspace{2mm}
182 \begin{lstlisting}[language=Matlab, title={MATLAB Code for Check}]
183 A = [1, -3, 3; 3, -5, 3; 6, -6, 4]; % define the matrix A
184 inv(A) % calculate and print the inverse of A
185 det(A) % the determinant of A
186 rank(A) % the rank of A
187 trace(A) % the trace of A
188 A + A.' % the sum of A and the transpose of A
189 sum(sum(A * A.' ~= eye(3))) % check if A is orthogonal
190 [X, D] = eig(A) % the eigenvectors and the corresponding eigenvalues of A
191 sum(sqrt(sum(A .^ 2))) % l-2,1 norm of A
192 norm(A, 'fro') % Frobenius norm of A
193 sum(svd(A)) % nuclear norm of A
194 max(svd(A)) % spectral norm of A
195 \end{lstlisting}
196
197 \problem{Linear Equations}
198 \subproblem{}
199 It is evident to solve the linear equation
200 \begin{equation}\label{eq:3-1}
201 \left\{
202 \begin{aligned}
203 x_1&=-1, \\
204 x_2&=0, \\
205 x_3&=1.
206 \end{aligned}
207 \right.
208 \end{equation}
209
210 \subproblem{}
211 Let
212 \begin{equation}
213 \mathbf{A}=\begin{bNiceArray}{rrr}
214 2&2&3\\1&-1&0\\-1&2&1
215 \end{bNiceArray},\quad
216 \mathbf{b}=
217 \begin{bNiceArray}{r}
218 1\\-1\\2
219 \end{bNiceArray},
220 \end{equation}
221 and we have $\mathbf{Ax}=\mathbf{b}$ as
222 \begin{equation}
223 \begin{bNiceArray}{rrr}
224 2&2&3\\1&-1&0\\-1&2&1
225 \end{bNiceArray}
226 \begin{bNiceArray}{r}
227 x_1\\x_2\\x_3
228 \end{bNiceArray}=
229 \begin{bNiceArray}{r}
230 1\\-1\\2
231 \end{bNiceArray}.
232 \end{equation}
233
234 \subproblem{}
235 Since there is a unique solution shown in Eq.~\eqref{eq:3-1}, we know
236 \begin{equation}\label{eq:3-3}
237 \mathrm{rank}(\mathbf{A})=3.
238 \end{equation}
239
240 \subproblem{}
241 \begin{equation}
242 \begin{aligned}
243 [\mathbf{A}, \mathbf{I}_3]&=
244 \begin{bNiceArray}{rrr:rrr}
245 2&2&3&1&0&0\\1&-1&0&0&1&0\\-1&2&1&0&0&1
246 \end{bNiceArray}\sim
247 \begin{bNiceArray}{rrr:rrr}
248 2&2&3&1&0&0\\1&-1&0&0&1&0\\0&1&1&0&1&1
249 \end{bNiceArray}\sim
250 \begin{bNiceArray}{rrr:rrr}
251 1&1&\frac{3}{2}&\frac{1}{2}&0&0\\1&-1&0&0&1&0\\0&1&1&0&1&1
252 \end{bNiceArray}\\
253 &\sim
254 \begin{bNiceArray}{rrr:rrr}
255 1&1&\frac{3}{2}&\frac{1}{2}&0&0\\[0.3em]0&-2&-\frac{3}{2}&-\frac{1}{2}&1&0\\[0.3em]0&1&1&0&1&1
256 \end{bNiceArray}\sim
257 \begin{bNiceArray}{rrr:rrr}
258 1&1&\frac{3}{2}&\frac{1}{2}&0&0\\[0.3em]0&-1&-\frac{3}{4}&-\frac{1}{4}&\frac{1}{2}&0\\[0.3em]0&0&\frac{1}{4}&-\frac{1}{4}&\frac{3}{2}&1
259 \end{bNiceArray}\sim
260 \begin{bNiceArray}{rrr:rrr}
261 1&1&0&2&-9&-6\\[0.3em]0&-1&0&-1&5&3\\[0.3em]0&0&1&-1&6&4
262 \end{bNiceArray}\\
263 &\sim
264 \begin{bNiceArray}{rrr:rrr}
265 1&0&0&1&-4&-3\\0&1&0&1&-5&-3\\0&0&1&-1&6&4
266 \end{bNiceArray},
267 \end{aligned}
268 \end{equation}
269 therefore the inverse of $\mathbf{A}$ is
270 \begin{equation}\label{eq:3-4-inv}
271 \mathbf{A}^{-1}=\begin{bNiceArray}{rrr}
272 1&-4&-3\\1&-5&-3\\-1&6&4
273 \end{bNiceArray}.
274 \end{equation}
275 The determinant of $\mathbf{A}$ can be calculated as
276 \begin{equation}
277 \mathrm{det}(\mathbf{A})=2\times\begin{vNiceArray}{rr}
278 -1&0\\2&1
279 \end{vNiceArray}-2\times\begin{vNiceArray}{rr}
280 1&0\\-1&1
281 \end{vNiceArray}+3\times\begin{vNiceArray}{rr}
282 1&-1\\-1&2
283 \end{vNiceArray}=2\times(-1)-2\times 1+3\times 1=-1.
284 \end{equation}
285
286 \subproblem{}
287 As is shown in Eq.~\eqref{eq:3-3}, $\mathbf{A}$ is invertible and with the result in Eq.~\eqref{eq:3-4-inv}
288 \begin{equation}
289 \mathbf{x}=\mathbf{A}^{-1}\mathbf{b}=
290 \begin{bNiceArray}{rrr}
291 1&-4&-3\\1&-5&-3\\-1&6&4
292 \end{bNiceArray}
293 \begin{bNiceArray}{r}
294 1\\-1\\2
295 \end{bNiceArray}=
296 \begin{bNiceArray}{r}
297 -1\\0\\1
298 \end{bNiceArray},
299 \end{equation}
300 and it is exactly the same result with Eq.~\eqref{eq:3-1}.
301
302 \subproblem{}
303 The inner product
304 \begin{equation}
305 \langle\mathbf{x},\mathbf{b}\rangle=\mathbf{x}^T\mathbf{b}=1\times 1+0\times(-1)+1\times 2=1,
306 \end{equation}
307 and the outer product is
308 \begin{equation}
309 \mathbf{x}\otimes\mathbf{b}=\mathbf{x}\mathbf{b}^T=
310 \begin{bNiceArray}{r}
311 -1\\0\\1
312 \end{bNiceArray}
313 \begin{bNiceArray}{rrr}
314 1&-1&2
315 \end{bNiceArray}=
316 \begin{bNiceArray}{rrr}
317 -1&1&-2\\0&0&0\\1&-1&2
318 \end{bNiceArray}.
319 \end{equation}
320
321 \subproblem{}
322 $\|\mathbf{b}\|_1=|1|+|-1|+|2|=4,\quad\|\mathbf{b}\|_2=\sqrt{1^2+(-1)^2+2^2}=\sqrt{6},\quad\|\mathbf{b}\|_{\infty}=\max\{|1|,|-1|,|2|\}=2.$
323
324 \subproblem{}
325 Let $\mathbf{y}=\begin{bNiceArray}{rrr}
326 y_1&y_2&y_3
327 \end{bNiceArray}^T$,
328 we have
329 \begin{equation}
330 \mathbf{y}^T\mathbf{Ay}=
331 \begin{bNiceArray}{rrr}
332 y_1&y_2&y_3
333 \end{bNiceArray}
334 \begin{bNiceArray}{rrr}
335 2&2&3\\1&-1&0\\-1&2&1
336 \end{bNiceArray}
337 \begin{bNiceArray}{r}
338 y_1\\y_2\\y_3
339 \end{bNiceArray}=2y_1^2-y_2^2+y_3^2+3y_1y_2+2y_2y_3+2y_1y_3,
340 \end{equation}
341 and
342 \begin{equation}
343 \bigtriangledown_{\mathbf{y}}\mathbf{y}^T\mathbf{Ay}=
344 \begin{bNiceArray}{r}
345 \frac{\partial}{\partial y_1}\mathbf{y}^T\mathbf{Ay} \\[.3em]
346 \frac{\partial}{\partial y_2}\mathbf{y}^T\mathbf{Ay} \\[.3em]
347 \frac{\partial}{\partial y_3}\mathbf{y}^T\mathbf{Ay}
348 \end{bNiceArray}=
349 \begin{bNiceArray}{r}
350 4y_1+3y_2+2y_3 \\
351 3y_1-2y_2+2y_3 \\
352 2y_1+2y_2+2y_3
353 \end{bNiceArray}.
354 \end{equation}
355
356 \subproblem{}
357 The equation $\mathbf{A}_1\mathbf{x}=\mathbf{b}_1$ can be represented as
358 \begin{equation}
359 \begin{bNiceArray}{rrr}
360 2&2&3\\1&-1&0\\-1&2&1\\-1&2&1
361 \end{bNiceArray}
362 \begin{bNiceArray}{r}
363 x_1\\x_2\\x_3
364 \end{bNiceArray}=
365 \begin{bNiceArray}{r}
366 1\\-1\\2\\2
367 \end{bNiceArray}.
368 \end{equation}
369
370 \subproblem{}
371 $\mathrm{rank}(\mathbf{A}_1)=3$.
372 \begin{proof}
373 On one hand, $\mathrm{rank}(\mathbf{A}_1)\geq\mathrm{rank}(\mathbf{A})=3$ which is shown in Eq.~\eqref{eq:3-3}.
374 On the other hand, $\mathrm{rank}(\mathbf{A}_1)\leq\min\{3,4\}=3$.
375 Therefore, $\mathrm{rank}(\mathbf{A}_1)=3$.
376 We can also find the first three equations are linearly independent while the last equation is actually the same with the third equation which makes it meaningless.
377 \end{proof}
378
379 \subproblem{}
380 Yes.
381 \begin{proof}
382 Since $\mathrm{rank}(\mathbf{A}_1)=\|\mathbf{x}\|_0$, i.e. rank of $\mathbf{A}_1$ is equal to the dimension of $\mathbf{x}$, the formula can be solved with a unique solution the same as Eq.~\eqref{eq:3-1}.
383 \end{proof}
384
385 \end{document}