Let \(M\) be the outer product of two random vectors with 5 entries, generated with
rand. Display the rank and determinant of \(M\text{.}\)
Solution.
a = rand(5, 1); b = rand(5, 1); M = a*b'; disp(rank(M)) disp(det(M))
The result should be: rank is 1, and the determinant is some extremely small (but nonzero) number, for example
3.2391e-69. Mathematically this is impossible: a 5×5 matrix of rank less than 5 must have determinant equal to 0. But the reality of computer arithmetic is that floating point numbers rarely add up exactly to zero, as noted in Section 6.4. Matlab’s rank command takes this into account and reports the rank as 1 when the matrix is “close enough” to actually having rank 1.
