4.3 LINEAR EQUATIONS
4.2.3 EXERCISES
Strassen’s algorithm is rarely used in actual practice because of the book- keeping necessary to use it recursively. Its importance is that it was the first algorithm for multiplying matrices that was faster than the O(N3) algorithms.
Improving the efficiency of matrix multiplication and perhaps identifying a lower bound continues to be an active area of research.
4.2.3
1. How many multiplications and additions are done by Winograd’s algorithm for an odd value of the shared dimension?
2. Show that Strassen’s algorithm works by using it to multiply the two matri- ces
Compare the result with that of the standard algorithm. Show all work.
One way to try to find the value for each x would be to do substitutions of the equations. In other words, we could take the second equation and rewrite it as x1 = 45 5x2 3x3 2x4 and then substitute this into the other three equations in place of x1. This would give three equations with three unknowns. We could then take one of the remaining three equations and do the same for x2, which would give us two equations with two unknowns.
Doing this one more time with x3 would give one equation with one unknown (x4). We would now know the value for x4 and could substitute this back into one of the two equations in the previous step, which would allow us to solve for the value of x3. Substituting x3 and x4 into one of the three equa- tions we got after the first substitution would allow us to determine the value ofx2, and then using these three values in one of our original equations would give us the value of x1.
This process works extremely well, but a lot of algebra is needed, and it would be easy for a mistake to occur. As the number of equations and unknowns increases, this algebra work can take quite a while to complete. This process is not easily programmed as described, but it is the basis for the Gauss- Jordan method, which will be described next.
■ 4.3.1 Gauss-Jordan Method
We could consider the system of linear equations as a matrix with N rows and N + 1 columns. For the previous example, this would give the matrix
We can now do a series of operations based on the rows to reach the result.
When the first n rows and columns represent the identity matrix, the final col- umn will have the x values that we want. This would look like the following:
2 7 1 5 70
1 5 3 2 45
3 2 4 1 33
8 1 5 3 56
1 0 0 0 x1 0 1 0 0 x2 0 0 1 0 x3 0 0 0 1 x4
The basic plan is to divide the first row by the value in the first column and then subtract multiples of this new first row from each of the other rows. In our example, the second row would have the new first row subtracted from it, the third row would have 3 times the new first row subtracted from it, and the fourth row would have 8 times the new first row subtracted from it. You should recognize that this would create the proper first column. This new matrix is
We now repeat this process for the second row. After we divide each of the values in this row by the number in the second column (1.5), we use the values in the second column of the other rows to determine how much this row is multiplied by for each subtraction. The new matrix is now (values shown are rounded)
We now repeat this process, using the third row to clear out the third col- umn and the fourth row to clear out the fourth column. This gives the next two matrices:
1 3.5 0.5 2.5 35
0 1.5 2.5 –0.5 10
0 –8.5 2.5 –6.5 –72 0 –27 1 –17 –224
1 0 –5.33 3.66 11.7
0 1 1.67 –0.33 6.67
0 0 16.7 –9.3 –15.3
0 0 46 –26 –44
1 0 0 0.68 6.76
0 1 0 0.6 8.2
0 0 1 –0.56 –0.92 0 0 0 –0.24 –1.68
1 0 0 0 2
0 1 0 0 4
0 0 1 0 3
0 0 0 1 7
The final matrix gives us the x values of x1 = 2, x2 = 4, x3 = 3, and x4 = 7.
The problem with this process is that on a computer, we will get round-off errors that may give inaccurate results. Round-off errors can multiply within a computer program so that a minor round-off difference in one calculation will cause the next to be more inaccurate than the last. In a large system of linear equations, round-off errors can be rather significant. There are other algo- rithms to solve or at least control these round-off errors, but the description of those algorithms is more appropriate for a text on numerical analysis and will not be discussed further.
A second concern with this process is what happens if two rows are just multiples of each other. In that case, we will wind up with one row that is entirely zero, and that will lead to a divide by zero error in our algorithm. This problem is called singularity, and modifying this algorithm to handle singular- ity is beyond the scope of this book.
4.3.2
1. Show the steps in the Gauss-Jordan algorithm for the following system of linear equations:
2. Show the steps in the Gauss-Jordan algorithm for the following system of linear equations:
3. From the description of Section 4.2.1, do an analysis of the Gauss-Jordan method for solving a system of N linear equations with N unknowns. Your analysis should determine the number of multiplications and the number of additions that are done.