Singular Matrices The following code generates 100 2 times 2
Singular Matrices The following code generates 100 2 times 2 matrices with integer coefficients in the ranges k = 1, 2, ..., 20. For each fixed k, it finds the percent that are singular percent = zeros (1, 20)\'; for k = 1:20 for i = 1:100 if det (floor((2*k + l)*rand(2) - k)) == 0 percent(k) = percent(k) + 1; end end end percent a. What do the values of the answer percent tell you about the percent of matrices that are singular as k increases? b. Repeat the experiment for 3 times 3 matrices. What can you say about the percent of singular matrices in this case? c. What does this indicate about the percent of singular matrices as the size of the matrix increases?
Solution
(a)
the values of percent are:
percent =
36
17
12
5
5
4
5
3
2
5
1
1
3
0
1
3
1
0
1
0
(b)
code
percent=zeros(1,20)\';
for k=1:20
for i=1:100
if det(floor((2*k+1)*rand(3)-k))==0
percent(k)=percent(k)+1
end
end
end
percent
sample output:
percent =
44
18
7
4
1
2
0
2
2
0
1
1
0
0
0
0
0
0
0
0
(c)
No, the size of the martrix is not increases

