COMPUTER PROBLEMS 12.4

\(\def\ds{\displaystyle} \def\l{\lambda} \) 1 (a) The command numpy.linalg.svd calculates the singular value decomposition. To find the best rank-one approximation of the matrix \(A\), replace \(s_i\) with \(0\) for \(i>0\) and recalculate the product:
A = np.array([[1,2],[2,3]])
U, S, Vh = np.linalg.svd(A)
S[1:]=0
A1 = U@np.diag(S)@Vh.T
The result is \({\displaystyle \left[\begin{array}{rr} 1.1708 & -1.8944\\ 1.8944& -3.0652\\ \end{array}\right]}\).

1 (b) Similar to part (a). The rank-one approximation is \({\displaystyle \left[\begin{array}{rr} 1.5607 & 3.7678\\ 1.3536 & 3.2678\\ \end{array}\right]}\).

1 (c) Similar to part (a). The rank-one approximation is \({\displaystyle \left[\begin{array}{rrr} 1.0107 & 2.5125 & 3.6436\\ 0.9552 & 2.3746 & 3.4436\\ 0.1787 & 0.4442 & 0.6441\\ \end{array}\right]}\).

1 (d) Similar to part (a). The rank-one approximation is \({\displaystyle \left[\begin{array}{rrr} -0.5141 & 5.2343 & 1.9952\\ 0.2070 & -2.1076 & -0.8033\\ -0.1425 & 1.4510 & 0.5531\\ \end{array}\right]}\).


3 (a) According to section 12.4.2, the best least squares one-dimensional subspace is found by finding the SVD of the data matrix \[A= \left[\begin{array}{rrr} 1&1&2\\4&5&4\\ \end{array}\right]=USV^T.\] Set the entry \(S_{22}=0\) to form \(S_1\) and recalculate to find the best line: \[A_1=US_1V^T= \left[\begin{array}{rrr} 1.1934&1.4707&1.2774\\3.9415&4.8575&4.2188\\ \end{array}\right].\] The best line is \(y=3.3028x\), projections are \(\left[\begin{array}{r} 1.1934\\3.9415\\ \end{array}\right]\), \(\left[\begin{array}{r} 1.4707\\4.8575\\ \end{array}\right]\), \(\left[\begin{array}{r} 1.2774\\4.2188\\ \end{array}\right]\)

3 (b) Best line \(y=0.3620x\), projections are \(\left[\begin{array}{r} 1.7682\\0.6402\\ \end{array}\right]\), \(\left[\begin{array}{r} 3.8565\\1.3963\\ \end{array}\right]\), \(\left[\begin{array}{r} 3.2925\\1.1921\\ \end{array}\right]\).

3 (c) Similar to part (a). Best line \([x(t),y(t),z(t)]=[0.3015, 0.3416, 0.8902]t\),

projections are \(\left[\begin{array}{r} 1.3702\\1.5527 \\4.0463\\ \end{array}\right]\), \(\left[\begin{array}{r} 1.8325\\2.0764\\5.4111\\ \end{array}\right]\), \(\left[\begin{array}{r} 1.8949\\2.1471\\5.5954\\ \end{array}\right]\), \(\left[\begin{array}{r} 0.9989\\1.1319\\2.9498\\ \end{array}\right]\).


5 Exact factorizations given in solutions to Exercise 12.3.2.