Project 6

Last revision:  April 15 1998

Author: YourNameGoesHere

Part A (Individually Pledged or Pledged with One Partner):  Determinants and Recursion

1. Given a square matrix, the determinant  can be calculated via the following recipe.  Write a recursive function implementing the recipe.  

First, the determinant of any matrix of size "1,1" is simply the value of the element inside, so that the determinant of "{{1}}" is 1.  

Now suppose the matrix is called "a" and has size "n,n", where "n" is greater than 1.  For each column "i" (from 1 to "n"), form the product of "a[[1,i]]", "(-1)^(1+i)", and the determinant of the square matrix "b" of size "n-1,n-1" formed by the rule 

          b[[j,k]] = a[[j+1,k+1]] , if "k" is greater than or equal to "i", or 
          b[[j,k]] = a[[j+1,k]]   , if "k" is less than "i", 

where "j" and "k" range over 1 to "n-1".  The determinant is the sum of these products.

Note that the matrix "b" is different for each "i", and that Mathematica has a function "Det[]", which you should not use but should mimic.

Here is an example.  Let "a" be the matrix "{{1,2},{3,4}}".  Following our recipe, the products we form should be as follows:
...for i=1:  a[[1,1]] * (-1)^(1+1) * determinant(b1), where b1 = {{4}};
...for i=2:  a[[1,2]] * (-1)^(1+2) * determinant(b2), where b2 = {{3}}.
Since determinant(b1)=4 and determinant(b2)=3, our products are 1*1*4 and 2*(-1)*3, and the sum is 4-6=-2.

Part B (Individually Pledged or Pledged with One Partner):  Matrix Multiplication and Iteration

Given a matrix "a" of size "m,n" and another matrix "b" of size "n,r", the standard matrix product of "a" and "b" is defined as follows:  the product "c" is a matrix of size "m,r", the elements of which satisfy the formula 

     c[[i,j]] = a[[i,1]]*b[[1,j]] 
             + a[[i,2]]*b[[2,j]] 
             + a[[i,3]]*b[[3,j]] 
             + ... 
             + a[[i,n]]*b[[n,j]]

as "i" ranges from 1 to "m" and "j" ranges from 1 to "r".  

Write a function using "Do[]", "For[]", "While[]", or a combination to perform the matrix product of two parameter matrices "a" and "b".

Note that the "Dot[]" function or the dot operator "." accomplishes matrix multiplication in Mathematica; use these to check your answer, but do not use them in your program.