Machine Learning - Assignment 1

 Machine Learning                                        Assignment   1   (Linear   Algebra)   Instructor: Beilun Wang                             Name:Daiyang Luan                            ID:61518421 \begin{array}{|l|} \hline \text { Machine Learning } \\\\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textbf { Assignment 1 (Linear Algebra) }\\\\ \text {Instructor: Beilun Wang }\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \text{Name:Daiyang Luan\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \text{ID:61518421}}\\\\ \hline \end{array}

Problem 1


Let two vectors a = ( 1 , 2 , 3 ) T a=(1,2,3)^{\mathrm{T}} and b = ( 8 , 1 , 2 ) T b=(-8,1,2)^{\mathrm{T}} .Answer the following equations:

(1) Compute the 2 \ell_{2} norm of a a and b b

(2) Calculate the Euclidean distance between a a and b b

(3) Are a a and b b orthogonal?

Solution:

(1)The 2 \ell_{2} norm of a a is 14 \sqrt{14} and the 2 \ell_{2} norm of b b is 69 \sqrt{69} .

(2)The Euclidean distance between a a and b b is 83 \sqrt{83} .

(3)As a T b = 1 × ( 8 ) + 2 × 1 + 3 × 2 = 0 a^{\mathrm{T}}b=1\times (-8)+2\times 1+3\times 2=0 , a a and b b is orthogonal.

Problem 2


Suppose A = [ 1 3 3 3 5 3 6 6 4 ] A=\left[\begin{array}{ccc}{1} & {-3} & {3} \\ {3} & {-5} & {3} \\ {6} & {-6} & {4}\end{array}\right] , answer the following questions:

(1) Calculate A 1 A^{-1} and det ( A ) \operatorname{det}(A) .

(2) The Rank of A A is?

(3) The trace of A A is?

(4) Calculate A + A T A+A^{T}

(5) Is A A an orthogonal matrix? State your reason.

(6) Calculate all the eigenvalue λ \lambda and corresponding eigenvectors of A A .

(7) Diagonalize the matrix A A .

(8) Calculate the 2 , 1 \ell_{2,1} norm A 2 , 1 \|A\|_{2,1} and the Frobenius norm (i.e. 2 \ell_{2} norm) A F \|A\|_{F}

(9) Calculate the nuclear norm A \|A\|_* and the spectral norm A 2 \|A\|_{2}

Solution:
(1) [ A I ] = [ 1 3 3 1 0 0 3 5 3 0 1 0 6 6 4 0 0 1 ] r o w [ 1 0 0 1 / 8 3 / 8 3 / 8 0 1 0 3 / 8 7 / 8 3 / 8 0 0 1 3 / 4 3 / 4 1 / 4 ] = [ I A 1 ] \left[\begin{array}{ccc} A &I\end{array}\right]=\left[\begin{array}{ccc}1&-3&3&1&0&0\\3&-5&3&0&1&0 \\6&-6&4&0&0&1\end{array}\right]\stackrel{row }{\longrightarrow}\left[\begin{array}{ccc}1&0&0&-1/8&-3/8&3/8\\0&1&0&3/8&-7/8&3/8 \\0&0&1&3/4&-3/4&1/4\end{array}\right]=\left[\begin{array}{ccc} I &A^{-1}\end{array}\right]
Hence, A 1 = [ 1 / 8 3 / 8 3 / 8 3 / 8 7 / 8 3 / 8 3 / 4 3 / 4 1 / 4 ] A^{-1}=\left[\begin{array}{ccc}-1/8&-3/8&3/8\\3/8&-7/8&3/8 \\3/4&-3/4&1/4\end{array}\right]
d e t ( A ) = 1 3 3 3 5 3 6 6 4 = 1 3 3 0 4 6 0 0 4 = 16 det(A)= \left|\begin{array}{cccc} 1 & -3 & 3 \\ 3 & -5 & 3\\ 6 & -6 & 4 \end{array}\right| =\left|\begin{array}{cccc} 1 & -3 & 3 \\ 0 & 4 & -6\\ 0 & 0 & 4 \end{array}\right|=16

(2)As d e t ( A ) 0 det(A)\not=0 , A A is a full-rank matrix. Thus, the rank of A A is 3 3 .

(3) t r ( A ) = 1 + ( 5 ) + 4 = 0 tr(A)=1+(-5)+4=0 . That is, the trace of A A is 0 0 .

(4) A + A T = [ 1 3 3 3 5 3 6 6 4 ] + [ 1 3 6 3 5 6 3 3 4 ] = [ 2 0 9 0 10 3 9 3 8 ] A+A^{T}=\left[\begin{array}{ccc}1&-3&3\\3&-5&3\\6&-6&4\end{array}\right]+\left[\begin{array}{ccc}1&3&6\\-3&-5&-6\\3&3&4\end{array}\right]=\left[\begin{array}{ccc}2&0&9\\0&-10&-3\\9&-3&8\end{array}\right]

(5) A T A = [ 46 54 36 54 70 48 36 48 34 ] I A^{T}A=\left[\begin{array}{ccc}46&-54&36\\-54&70&-48\\36&-48&34\end{array}\right]\not=I , so A A is not an orthogonal matrix.

(6)The characteristic determinant of A A is λ 1 3 3 3 λ + 5 3 6 6 λ 4 = ( λ + 2 ) 2 ( λ 4 ) . \left|\begin{array}{cccc} \lambda-1 & 3 & -3 \\ -3 & \lambda+5 & -3\\ -6 & 6 & \lambda-4 \end{array}\right|=(\lambda+2)^{2}(\lambda-4). Thus, all the eigenvalues of A A are λ 1 = λ 2 = 2 , λ 3 = 4. \lambda_{1}=\lambda_{2}=-2,\lambda_{3}=4. Let A α i = λ i α i , i = 1 , 2 , 3 A\alpha_{i}=\lambda_{i}\alpha_{i},i=1,2,3 . Then we have α 1 = [ 1 1 0 ] , α 2 = [ 0 1 1 ] , α 3 = [ 1 1 2 ] \alpha_{1}=\left[\begin{array}{ccc}1\\1\\0\end{array}\right],\alpha_{2}=\left[\begin{array}{ccc}0\\1\\1\end{array}\right],\alpha_{3}=\left[\begin{array}{ccc}1\\1\\2\end{array}\right] . α i ( i = 1 , 2 , 3 ) \alpha_{i}(i=1,2,3) are the corresponding eigenvectors.

(7)The diagonal matrix corresponding to matrix A A is [ 2 0 0 0 2 0 0 0 4 ] \left[\begin{array}{cccc} -2 & 0 & 0 \\ 0 & -2 & 0\\ 0 &0 & 4 \end{array}\right]

(8)In order to calculate the 2 , 1 \ell_{2,1} norm A 2 , 1 \|A\|_{2,1} , we first calculate the 2-norm of each row: 19 , 43 , 2 22 \sqrt{19},\sqrt{43},2\sqrt{22} . Thus, A 2 , 1 = 19 + 43 + 2 22 \|A\|_{2,1}=\sqrt{19}+\sqrt{43}+2\sqrt{22} .
A F = ( i = 1 m j = 1 n ( a i j ) 2 ) 1 2 = 1 + 9 + 9 + 9 + 25 + 9 + 36 + 36 + 16 = 150 . \Vert A \Vert_F=\left({\sum\limits_{i=1}^{m}{\sum\limits_{j=1}^n{(a_{ij})^2}}}\right)^{{\frac{1}{2}}}=\sqrt{1+9+9+9+25+9+36+36+16}=\sqrt{150}.

(9)The nuclear norm A \|A\|_* is defined as the sum of all the singular values of matrix A A . As is calculated above, A T A = [ 46 54 36 54 70 48 36 48 34 ] A^{T}A=\left[\begin{array}{ccc}46&-54&36\\-54&70&-48\\36&-48&34\end{array}\right] . Supposing the eigenvalues of A T A A^TA are λ i , i = 1 , 2 , 3 \lambda_i, i=1,2,3 , we have λ I A = 0 |\lambda I-A|=0 .
That is,
λ 46 54 36 54 λ 70 48 36 48 λ 34 = 0 \left|{\begin{array}{l} \lambda-46&54&-36\\ 54&\lambda-70&48\\ -36&48&\lambda-34 \end{array}}\right|=0
Hence, we have λ 3 150 λ 2 + 648 λ 256 = 0 \lambda^3-150\lambda^2+648\lambda-256=0
The solution of the equation is:
λ 1 = 4 \lambda_1=4 λ 2 = 73 + 9 65 \lambda_2=73+9\sqrt{65} λ 3 = 73 9 65 \lambda_3=73-9\sqrt{65}
Thus, A = 2 + 73 + 9 65 + 73 9 65 14.727922061357859 \|A\|_*=2+\sqrt{73+9\sqrt{65}}+\sqrt{73-9\sqrt{65}}\approx14.727922061357859 .
A 2 = m a x ( A T A ) = 73 + 9 65 12.064838156174618 \|A\|_2=\sqrt{max(A^TA})=\sqrt{73+9\sqrt{65}}\approx 12.064838156174618

Problem 3​

Please give some proper steps to show how you get the answer. Let x = ( x 1 , x 2 , x 3 ) T x=\left(x_{1}, x_{2}, x_{3}\right)^{T} and
{ 2 x 1 + 2 x 2 + 3 x 3 = 1 x 1 x 2 = 1 x 1 + 2 x 2 + x 3 = 2 \left\{\begin{array}{l} 2 x_{1}+2 x_{2}+3 x_{3}=1 \\ x_{1}-x_{2}=-1 \\ -x_{1}+2 x_{2}+x_{3}=2 \end{array}\right.
Answer the following questions:

(1) Solve the linear equations

(2) Write it into matrix form(i.e. A x = b A x=b ) and we will use the same A A and b b in the following questions.

(3) The Rank of A A is?

(4) Calculate A 1 A^{-1} and det ( A ) \operatorname{det}(A)

(5) Use (4) to solve the linear equations

(6) Calculate the inner product and outer product of x x and b b .(i.e. x , b \langle x, b\rangle and x b x \otimes b )

(7) Calculate the 1 , 2 \ell_{1}, \ell_{2} and \ell_{\infty} norm of b b

(8) Suppose y = ( y 1 , y 2 , y 3 ) , y=\left(y_{1}, y_{2}, y_{3}\right), calculate y T A y , y y T A y y^{T} A y, \nabla_{y} y^{T} A y

(9) We add one linear equation x 1 + 2 x 2 + x 3 = 2 -x_{1}+2 x_{2}+x_{3}=2 into linear equations above. Write it into matrix form(i.e. A 1 x = b ) \left.A_{1} x=b\right)

(10) The rank of A 1 A_{1} is?

(11) Could these linear equations A 1 x = b A_{1} x=b be solved? State reasons.

Solution:
(1)Solving the linear equations, we have: x 1 = 1 , x 2 = 0 , x 3 = 1 x_1=-1, x_2=0, x_3=1 .

(2)The linear equation can be written into matrix form A x = b Ax=b where
A = [ 2 2 3 1 1 0 1 2 1 ] A=\left[\begin{array}{l} 2&2&3 \\ 1&-1&0 \\ -1&2&1 \end{array}\right]
and
b = [ 1 1 2 ] b=\left[\begin{array}{l} 1\\-1\\2 \end{array}\right]

(3)The rank of A A is 3.

(4) A 1 = [ 1 4 3 1 5 3 1 6 4 ] A^{-1}=\left[\begin{array}{l} 1&-4&-3 \\ 1&-5&-3 \\ -1&6&4 \end{array}\right]
d e t ( A ) = 1. det(A)=-1.

(5) x = A 1 b = [ 1 4 3 1 5 3 1 6 4 ] [ 1 1 2 ] = [ 1 0 1 ] x=A^{-1}b=\left[\begin{array}{l} 1&-4&-3 \\ 1&-5&-3 \\ -1&6&4 \end{array}\right]\left[\begin{array}{l} 1\\-1\\2 \end{array}\right]=\left[\begin{array}{l} -1\\0\\1 \end{array}\right]
That is, x 1 = 1 , x 2 = 0 , x 3 = 1 x_1=-1, x_2=0, x_3=1 , which is consistent with the result of question1.

(6) < x , b > = 1 , x b = [ 1 3 1 ] T <x,b>=1,x\bigotimes b=\left[\begin{array}{l} 1&3&1 \end{array}\right]^T

(7)The 1 \ell_1 norm of b b is b 1 = 1 + 1 + 2 = 5 \|b\|_1=1+1+2=5 .
The 2 \ell_2 norm of b b is b 2 = 1 + 1 + 4 = 6 \|b\|_2=\sqrt{1+1+4}=\sqrt{6} .
The \ell_\infty norm of b b is b = m a x ( 1 , 1 , 2 ) = 2 \|b\|_\infty=max(1,1,2)=2 .

(8) y T A y = [ y 1 y 2 y 3 ] [ 2 2 3 1 1 0 1 2 1 ] [ y 1 y 2 y 3 ] = 2 y 1 2 y 2 2 + y 3 2 + 3 y 1 y 2 + 2 y 2 y 3 + 2 y 1 y 3 y^TAy=\left[\begin{array}{l} y_1&y_2&y_3 \end{array}\right]\left[\begin{array}{l} 2&2&3 \\ 1&-1&0 \\ -1&2&1 \end{array}\right]\left[\begin{array}{l} y_1\\y_2\\y_3 \end{array}\right]=2y_1^2-y_2^2+y_3^2+3y_1y_2+2y_2y_3+2y_1y_3
y y T A y = [ 4 y 1 + 3 y 2 + 2 y 3 3 y 1 2 y 2 + 2 y 3 2 y 1 + 2 y 2 + 2 y 3 ] \nabla_yy^TAy=\left[\begin{array}{l} 4y_1+3y_2+2y_3\\3y_1-2y_2+2y_3\\2y_1+2y_2+2y_3 \end{array}\right]

(9)The new linear equation can be written into matrix form A 1 x = b 1 A_1x=b_1 where
A 1 = [ 2 2 3 1 1 0 1 2 1 1 2 1 ] A_1=\left[\begin{array}{l} 2&2&3 \\ 1&-1&0 \\ -1&2&1\\-1&2&1 \end{array}\right]
and
b 1 = [ 1 1 2 2 ] b_1=\left[\begin{array}{l} 1\\-1\\2\\2 \end{array}\right]

(10)The rank of A 1 A_1 is 3.

(11)Yes.
The number of variables is the same as the rank of the new matrix A 1 A_1 and thus there is no more than one solution to the non homogeneous linear equations. Moreover, after diagonalizing the matrix A A , we can see that after deleting the row whose elements are all zero, determinant of the new matrix is not zero. This indicates that a solution exists for these linear equations.

发布了3 篇原创文章 · 获赞 6 · 访问量 183

猜你喜欢

转载自blog.csdn.net/Hibara_AI/article/details/104545322