Assignment 1

CS 300 Applied Symbolic Computation
Instructor: Jeremy Johnson 
Due date: Tue. April 15 (by the start of class)

Overview

In this assignment you will use Maple to explore the correctness and efficiency of Strassen's matrix multiplication algorithm.  The assignment will provide students with an opportunity to create a Maple worksheet, use Maple's symbolic and numeric computing features and Maple's plotting features, and to write some simple Maple functions.

In 1969, Volker Strassen discovered an algorithm to multiply two n X n matrices in time O(n^(2.81)) instead of O(n^3) as is required by the standard algorithm.  The algorithm is based on a clever way to multiply 2 X 2 matrices using 7 multiplications and 18 additions/subtractions.  On the face of it this is worse than the standard approach which uses 8 multiplications and 4 additions; however, when applied to 2 X 2 matrices whose elements are m X m matrices this observation leads to a factor of 7/8's improvement as m gest large since matrix addition is of order n^2 and matrix multiplication is of order n^3 when the standard algorithm is used.  The improvement is even greater when Strassen's trick is used recursively for the 7 products of size m.  The computing time satisfies the recurrence T(n) = 7*T(n/2) + 18*(n/2)^2, which can be shown to be O(n^(2.81)).

Shortly after Strassen's result, S. Winograd found a way to multiply 2 X 2 matrices using 7 multiplications and 15 additions/subtractions.  This observation improves the constant but does not change the asymptotic computing time.  Winograd subsequently showed that 7 multiplications and 15 additions/subtractions is optimial for 2 X 2 matrix multiplication.  His approach is based on the following equations.

             [ A11  A12 ]                [ B11  B12 ]               [ C11  C12 ]
Let A = [                 ]  and  B = [                 ]  and C = [                 ] = A*B.
             [ A21  A22]                 [ B21  B22 ]               [ C21  C22 ]

S1 = A21 + A22,  T1 = B12 - B11
S2 = S1 - A11,     T2 = B22 - T1
S3 = A11 - A21,  T3 = B22 - B12
S4 = A12 - S2,    T4 = B21 - T2

P1 = A11*B11
P2 = A12*B21
P3 = S1*T1
P4 = S2*T2
P5 = S3*T3
P6= S4*B22
P7 = A22*T4

U1 = P1 + P2
U2 = P1 + P4
U3 = U2 + P5
U4 = U3 + P7
U5 = U3 + P3
U6 = U2 + P3
U7 = U6 + P6

Then C11 = U1, C12 = U7, C21 = U4, and C22 = U5.
 

What to do

  1. Create a Maple worksheet and organize it to present answers to the following questions.  Make sure you include a title, your name, the course and instructor's name along with an overview of your work and text explaining your solutions to the questions.
  2. Use Maple to verify that Winograd's variant of Strassen's algorithm is correct.  I.E.  Symbolically evaluate the equations to verify that the compute the product of two 2 X 2 matrices.
  3. Assume n = 2^k.  Use the rsolve command to determine the number of arithmetic operations used by Winograd's variant of Strassen's algorithm.  Compute the ratio of the number of operations used by Winograd's variant of Strassen's algorithm to the standard algorithm. Plot the ratio as k becomes sufficient large so that the asymptotic behavior is apparent.  When does Strassen's algorithm become faster?
  4. The cross over point observed in part 2 convinced many people that Strassen's algorithm was impractical; however, if a hybrid algorithm is used, where the regular algorithm is used when it is faster than applying Strassen's algorithm, then the cross over point is much smaller.  Find the optimal hybrid algorithm and determine the point at which it becomes faster than the ordinary algorithm.
  5. As stated Strassen's algorithm requires the input size to be a power of two.  However, this limitation can be removed by padding with zeros.  Verify that if A and B are n X n matrices and are embedded in the upper left hand corner of (n+m) X (n+m) matrices A' and B' whose last m columns and rows are zero than the lower left hand n X n block of A'*B' = A*B.  This observation provides several strategies for applying Strassen's algorithm for arbitrarily sized matrices.  For each approach below write a Maple function that determines the number of arithmetic operations used to multiply n X n matrices.  By computing ratios and showing plots compare the different approaches.  Obtain an exact count and comparison for n = 2^k + 1 and n = 2^k - 1.
    1. Embed A and B in 2^k X 2^k matrices A' and B' where k is the smallest integer such that n <= 2^k.
    2. At each recursive step of Strassen's algorithm, if n is odd add an extra row and column of zeros so that A and B are embedded in (n+1) X (n+1) matrices A' and B'.  If n is even no embedding is necessary.
    3. At each recursive step in Strassen's algorithm, if n is odd view A and B as 2 X 2 matrices whose upper left hand block A11 and B11 are (n-1) X (n-1) matrices.  Perform the multiplication of A11*B11 using a recursive call to Strassen's algorithm.  The remaining multiplications are performed using ordinary matrix multiplication.

Guidelines

Make sure that your maple functions are documented and that enough text is provided in the worksheet so that it is easy to understand what you did and clearly state what conclusions you draw for each part and for the assignment as a whole.  Make sure your worksheet is well organized and easy to traverse.  Use sections as needed.

You should start right away and organize your time so that you have plenty of time to complete the assignment.  If you do not understand any part of the assignment, make sure you ask the instructor or TA - do so before you spend a lot of wasted time because you do not know what to do.

All work must be done by yourself.  Any violation of this will result in a zero grade for the assignment.  A second violation may lead to an F for the course.

How to submit your assignment

Please submit your assignment electronically using the "submit" command that is available on the MCS Sun computers. To learn more about submit, see the man page (i.e. "man submit").

The steps to submit your homework.

  1. Place all of the files you want to submit in one directory. Note that you should not submit executable or object files. You must include instructions for me to rebuild and execute your program. You should submit all source code, header files, makefiles, description files, sample input and output files, along with a readme file out that lists all files submitted and their contents.
  2. enter the submit command and select me as the instructor.
  3. select cs300 for the class.
  4. select assign1 for the assignment.
  5. select the files you want to submit.
  6. make sure you enter "submit" to submit the files you selected. You must also reply "yes" to force the submission to occur. When you do so you should see a list of the files you submitted.
  7. You may resubmit a file; however, each submitted file is time stamped. If you use submit again, you may list the files you have already submitted.