Speed of Calculating Determinants
Counting operations to compare row reduction against the permutation expansion, and how each method's cost grows with matrix size.
5 exercises
Exercise 1
To get an idea of what happens for typical matrices we can use the ability of computer systems to generate random numbers (of course, these are only pseudo-random in that they come from an algorithm but they pass a number of reasonable statistical tests for randomness).
-
Fill a array with random numbers say, in the range ). See if it is singular. Repeat that experiment a few times. Are singula…
Exercise 2
Compute the determinant of each of these by hand using the two methods discussed above.
-
(a) (b) (c)
Count the number of multiplications and divisions used in each case, for each of the methods.
Exercise 3
The use by the timing routine of do_matrix has a bug. That routine does two things, generate a random matrix and then do gauss_method on it, and the timing number returned is for the combination. Produce code that times only the gauss_method routine.
Exercise 4
What array can you invent that takes your computer the longest time to reduce? The shortest?
Exercise 5
Some computer language specifications requires that arrays be stored “by column,” that is, the entire first column is stored contiguously, then the second column, etc. Does the code fragment given take advantage of this, or can it be rewritten to make it faster, by taking advantage of the fact that computer fetches are faster from contiguous locations?
Adapted from Linear Algebra © 2016 Jim Hefferon. Licensed under CC BY-SA 3.0 US. Source: Linear Algebra. Imported at revision df2262e.