06.09.2021 Views

Linear Algebra, 2020a

Linear Algebra, 2020a

Linear Algebra, 2020a

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Topic: Speed of Calculating Determinants 375<br />

Exercises<br />

1 To get an idea of what happens for typical matrices we can use the ability of<br />

computer systems to generate random numbers (of course, these are only pseudorandom<br />

in that they come from an algorithm but they pass a number of reasonable<br />

statistical tests for randomness).<br />

(a) Fill a 5×5 array with random numbers say, in the range [0 ... 1)). See if it is<br />

singular. Repeat that experiment a few times. Are singular matrices frequent or<br />

rare in this sense?<br />

(b) Time your computer algebra system at finding the determinant of ten 10×10<br />

arrays of random numbers. Find the average time per array. Repeat the prior<br />

item for 20×20 arrays, 30×30 arrays, . . . 100×100 arrays, and compare to the<br />

numbers given above. (Notice that, when an array is singular, we can sometimes<br />

decide that quickly, for instance if the first row equals the second. In the light of<br />

your answer to the first part, do you expect that singular systems play a large<br />

role in your average?)<br />

(c) Graph the input size versus the average time.<br />

2 Compute the determinant of each of these by hand using the two methods discussed<br />

above.<br />

2 1 0 0<br />

(a)<br />

∣ 2 1<br />

3 1 1<br />

5 −3∣<br />

(b)<br />

−1 0 5<br />

(c)<br />

1 3 2 0<br />

∣−1 2 −2∣<br />

0 −1 −2 1<br />

∣<br />

0 0 −2 1<br />

∣<br />

Count the number of multiplications and divisions used in each case, for each of<br />

the methods.<br />

3 The use by the timing routine of do_matrix has a bug. That routine does<br />

two things, generate a random matrix and then do gauss_method on it, and the<br />

timing number returned is for the combination. Produce code that times only the<br />

gauss_method routine.<br />

4 What 10×10 array can you invent that takes your computer the longest time to<br />

reduce? The shortest?<br />

5 Some computer language specifications requires that arrays be stored “by column,”<br />

that is, the entire first column is stored contiguously, then the second column, etc.<br />

Does the code fragment given take advantage of this, or can it be rewritten to<br />

make it faster, by taking advantage of the fact that computer fetches are faster<br />

from contiguous locations?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!