## Part 1

1. ½Ð¼g¤@­Ó MATLAB µ{¦¡½X testMat01.m¡A½Ð¨Ì¤U¦C¨BÆJ¶i¦æ¦¹§@·~¡G
1. ¨Ï¥Î randn «ü¥O²£¥Í¤@­Ó 10¡Ñ10 ªº¯x°} A¡C
3. ­pºâ¯x°} B ªº©T¦³¦V¶q e1, e2, ... e10¡C
4. Please use 3 lines of MATLAB statements to solve the following simultaneous linear equations: $$\left\{ \begin{matrix} x+y+z=1\\ 3x-y-3z=4\\ x+5y-9z=0\\ \end{matrix} \right.$$
5. ½Ð¼g¤@­Ó MATLAB µ{¦¡½X lse01.m¡A¨Ï¥Î MATLABªº¡u¥ª°£¡v§ä¥X¤@ÂI P¡A¨Ï±o P ¨ì¤U¦C¤T±øª½½uªº¶ZÂ÷¥­¤è©M¬°³Ì¤p¡G $$\left\{ \begin{matrix} 2x-y = 2\\ x-2y = -2\\ x+y = 1\\ \end{matrix} \right.$$ ½Ð°Ý P ­È¬°¦ó¡H¦¹®É³Ì¤p¶ZÂ÷¥­¤è©M¬O¦h¤Ö¡H
6. ½Ð¼g¤@­Ó MATLAB µ{¦¡½X lse02.m¡A±Ä¥Î MATLAB ªº¡u¥ª°£¡v¹Bºâ¡A§ä¥X¤U¦CÁp¥ß¤èµ{¦¡ªº³Ì¤p¥­¤è¸Ñ¡G $$\left\{ \begin{matrix} 3x+2y = 1\\ x+3y = 4\\ 4x+2y = 3\\ x-y = 6\\ \end{matrix} \right.$$ ¦¹®É³Ì¤p¥­¤è»~®t¬O¦h¤Ö¡H

## Part 2

1. Definition of eigenvalues and eigenvectors: What is the definition of eigenvalues and eigenvectors of a square matrix A?
2. Formula for eigenvalue decomposition: What is the formula for eigenvalue decomposition? (Please clearly define your notation.)
3. ¸Õ¥Î MATLABªº¡u¥ª°£¡v¹Bºâ¡A§ä¥X³Ì±µªñ¤U¦C¤­ÂIªº³Ì¤p¥­¤è¤T¦¸¦h¶µ¦¡¡G
(1, 5) (2, 3) (3, 4) (4, 7) (5, 2)
4. Sum of squared distances between a point and multiple planes: ½Ð¨Ï¥Î MATLABªº¡u¥ª°£¡v§ä¥XªÅ¶¡¤¤ªº¤@ÂI P¡A¨Ï±o P ¨ì¤U¦C 4 ­Ó¥­­±ªº¶ZÂ÷¥­¤è©M¬°³Ì¤p¡G $$\left\{ \begin{matrix} 2x-y+2z & = & 2\\ x-2y-2z & = & -2\\ x+y+z & = & 1\\ z & = & 5\\ \end{matrix} \right.$$ ½Ð°Ý P ­È¬°¦ó¡H¦¹®É³Ì¤p¶ZÂ÷¥­¤è©M¬O¦h¤Ö¡H
5. Eigenvalue of same-column-sum matrix: Suppose that a square matrix A has its column sums all equal to k. Prove that k is an eigenvalue of A.
6. Power method to compute page rank: As described in our slides, we can use the power method to find the page rank of a given connectivity matrix. That is, we can repeat $\mathbf{x}=A*\mathbf{x}$ until $\mathbf{x}$ converges to find the page rank, where $A$ is the transition probability matrix derived from the connectivity matrix. Write a function pageRankByPower.m to return the page rank, with the following usage:
[pagerank, iterCount]=pageRankByPower(G, p),
where
• G: the given connectivity matrix
• p: the given probability of following a link in a page
• pagerank: the returned page rank
• iterCount: the iteration count of the power method
More specs are as follows:
• Note that you can only use the power method to implement this function.
• The initial guess of the page rank should be a probability vector of uniform distribution.
• The maximum iteration count is 100. Once the maximum iteration count is reached, the current page rank is returned immediately.
• The iteration stops whenever max(abs(pr-prprev)) < eps, where pr is the current page rank and prprev is the page rank obtained at previous iteration.
You can download the p-file pageRankByPower.p to test your function. Here is a test script with several test cases:

Example 1: 06-½u©Ê¥N¼Æ/pageRankByPower01.mG=[0 0 0 1 0 1;1 0 0 0 0 0;0 1 0 0 0 0;0 1 1 0 0 0;0 0 1 0 0 0;1 0 1 0 0 0]; p=0.85; [pageRank1, iterCount1]=pageRankByPower(G, p) G=[1 0 0 0 0 0 0 1 0 0;1 1 0 0 0 0 0 0 1 0;0 1 1 0 0 0 0 1 0 0;1 0 1 0 0 0 0 0 0 0;0 1 0 0 0 0 1 1 1 0;0 0 0 1 0 0 1 0 0 0;0 0 0 0 0 1 0 0 0 0;0 1 0 0 0 0 0 0 0 0;1 0 0 1 0 0 0 0 0 0;1 1 0 0 0 0 0 0 0 0]; p=0.9; [pageRank2, iterCount2]=pageRankByPower(G, p) pageRank1 = 0.3210 0.1705 0.1066 0.1368 0.0643 0.2007 iterCount1 = 64 pageRank2 = 0.0541 0.0929 0.1110 0.0899 0.1683 0.1417 0.1578 0.0470 0.0805 0.0567 iterCount2 = 74

7. Ranking of sports teams: In this assignment, we shall use the concept of Google's PageRank for team ranking. During a sports season, we have four teams with the following result, with "m-n" indicating that there are m+n games between two teams, with m winning games for the left team and n winning games for the right team. (For instance, 3-1 between teams A and B indicates that A has 3 winning games while B has 1.)

We shall use the following steps to explain how to find the strength (or team rank) of each team.
1. We can use a matrix GD to respresent the result of "difference in winning games": GD = [ 0 2 1 0 -2 0 -2 -2 -1 2 0 0 0 2 0 0]; where GD(i,j) is the no. of difference of winning games between team i and team j. For instance, GD(2,1)=1-3=-2, while GD(1,2)=3-1=2. (Note that GD is anti-symmetric.)
2. We want to find a voting (or recommendation) from each team to the others. Since the voting should be positive and bounded, one way to achieve this is by using a sigmoidal function: A = 1./(1+exp(-GD)); A(1:5:end)=0; Then we can have the voting matrix: A = 0 0.8808 0.7311 0.5000 0.1192 0 0.1192 0.1192 0.2689 0.8808 0 0.5000 0.5000 0.8808 0.5000 0 where A(i,j) is the voting from team j to team i. Note that:
• A(i,j)=0.5 if two teams have the same number of winning games, such as A(4,1).
• A(i,j)<0.5 if team j is stronger than team i, so team j is giving weaker vote to team i. For instance, A(2,1)<0.5 since team 1 is stronger than team 2 by 2 games.
• A(i,j)>0.5 if team j is weaker than team i, so team j is giving stronger vote to team i. , such as A(3,2)>0.5 since team 2 is weaker than team 3 by 2 games.
3. Next, we can convert the vote matrix A to be a transition probability matrix by dividing each column by its corresponding column sum. This can be achieved by B = bsxfun(@rdivide, A, sum(A)); Then we have the transition probability matrix B, with each column summing to 1: B = 0 0.3333 0.5414 0.4467 0.1342 0 0.0883 0.1065 0.3028 0.3333 0 0.4467 0.5630 0.3333 0.3703 0 By following the same concept as Google's PageRank, the team rank x should satisfy $Bx=x$. That is, the team rank x is an eigenvector of matrix B with corresponding eigenvalue of 1.

By following the above reasoning steps, write a function myTeamRank.m to return the team rank, with the following usage:

teamRank=myTeamRank(GD),
where
• GD: the matrix of winning game difference
• teamRank: the returned team rank vector to show the strength of all teams
You can download the p-file myTeamRank.p to test your function. Here is a test script with several test cases:

Example 2: 06-½u©Ê¥N¼Æ/myTeamRank01.mGD=[0 2 1 0;-2 0 -2 -2;-1 2 0 0;0 2 0 0]; teamRank=myTeamRank(GD) teamRank = 0.3186 0.0998 0.2693 0.3123

Hint:
• Note that it is almost impossible to have an eigenvalue of exact 1 after lengthy numerical computation. Instead, you can find the eigenvalue of maximum magnitude instead.
• In general, when using "if" statement for floating-point numbers, you need to be really careful. For instance, after lengthy computation, if you want to determine if x is equal to the square root of 2, it will be risky to write something like "if x==sqrt(2)". Instead, always try to allow some tolerance, for instance, "if abs(x-sqrt(2))<1e-5" is a better version. This will make your code more feasible and reliable.
• Since the final team rank is a probability vector, its elements should be positive and its summation should be equal to 1.
• More explanation on using MATLAB for team ranking can be found in this video.

MATLABµ{¦¡³]­p¡G¶i¶¥½g