This week the focus was on performing mathematical computations using matrices in R. We were given the following code:

We were then instructed to find the determinant and inverse of both matrices, if possible, along with a couple other computations. The code that I used for this assignment is as follows:

When multiplying matrices, you need to be careful that the the rows of the first matrix match the columns of the second. This code works because we ensured that:
- Because A has 10 columns,
ahas 10 numbers, thus A × a works - Because B has 100 columns,
bhas 100 numbers, thus B × b works
With this code, we get the following result:

I then proceeded to perform matrix by matrix multiplication, which gave the following interesting results:

A × tA remained a square 10 × 10 matrix, becuase both A and tA were 10 × 10. However, B × tB turned into a square matrix 10 × 10 matrix despite B starting as a 10 × 100 matrix and tB starting as a 100 × 10 matrix. Despite their differences of dimensions, we are able to multiple them becuase their inner dimensions (100 × 100) match. When we multiple them, the resulting matrix takes on their outer dimensions (10 × 10), which is why we get the result we got.
Next, we wanted to calculate the determinant and inverse of both matrices, if possible:

In the end, we determined that while we were able to caluclate the determinant of A becuase it was a square matrix, it had a determinant of 0 which means it does not have an inverse. On the contrast, we were not able to calculate either for B because it was not an square matrix and thus R gave an error when the det() function was used on B.
I thought while this was a very difficul assignment, it was very fulfilling once I figured out exactly what it meant to multiple matrices. I am still getting the hang of them, but they make much more sense after this assignment. Another concept that really helped me understand this is recently my Calculus professor gave us a mini lecture on Group Theory, indentity elements, and the role of inverses.
Basically, an inverse is something that undoes a member of a set and creates the identity element. So an inverse matrix is a matrix that “undoes” another matrix to create the identity element for the Matrix group, which looks like the following:

Once it clicked in my head exactly what inverse matrices were, how matrix multiplcation works, and how they fit into this idea of Group Theory, this assignment because to make alot more sense! It feels a little weird to rely on abstract mathematics to understand something like matrix multiplcation, but it makes alot more sense in my head becuase of that foundation. I’ll have to thank my Calculus professor for the improptu Group Theory lesson!
As always, you can find my code for this assignment on my github: here
Leave a comment