c: ⎡a c 1⎤
⎢ ⎥
⎣b d 2⎦
Matrix Algebra Whirlwind Tour
Introduction
In this hopefully short and crisp tour, we will look at elementary operations on matrices: transpose, addition/subtraction and multiplication, and finally the inverse.
What is a Matrix?
An rectangular array of numbers, arranged with rows and columns. A few examples are:
Equation 1 is a 3 x 3 matrix (3 rows and 3 columns).
Equation 2 is a 3 x 4 matrix (3 rows and 4 columns).
Equation 3 is a 1 x 4 matrix (1 rows and 4 columns).
Equation 2 is a 3 x 1 matrix (3 rows and 1 columns).
Transpose
A matrix transpose is accomplished by writing rows as columns and vice versa. Hence an
c: ⎡a b⎤
⎢ ⎥
⎢c d⎥
⎢ ⎥
⎣1 2⎦
Addition and Subtraction
Matrices can be added or subtracted when they are of the same dimensions, rows and columns. Matrix elements are added or subtracted in element-wise fashion.
Addition
c: ⎡a 0⎤
⎢ ⎥
⎣b 1⎦
c: ⎡a c⎤
⎢ ⎥
⎣b 1⎦
c: ⎡2⋅a c⎤
⎢ ⎥
⎣2⋅b 2⎦
Subtraction
c: ⎡a 0⎤
⎢ ⎥
⎣b 1⎦
c: ⎡a c⎤
⎢ ⎥
⎣b 1⎦
c: ⎡0 -c⎤
⎢ ⎥
⎣0 0 ⎦
Multiplication
Matrix multiplication can be visualized in many ways!! According to Gilbert Strang’s famous book on Linear Algebra, there are no less than 4 very useful ways. Let us understand perhaps the easiest one, Linear combination of Columns.
Suppose there are three students who bought two kinds of food and drink:
- Student A: 2 samosas and 1 chai
- Student B: 3 samosas and 0 chai
- Student C: 0 samosa and 2 chai-s (Just before Arvind’s R class.)
Samosas cost 20 and chai costs 10. How much do they pay?
We see that the first number
Suppose they had two options for shops? And the prices were different?
- Samosas cost 20 and chai costs 10 at Shop#1. (as before)
- Samosas cost 15 and chai costs 15 at Shop#2.
Shop#2 is cheaper. Drag peasant#3 and go there, peasants#1 and #2.
How did this multiplication happen? Same story as with one shop/prices, repeated to handle the second shop. Matrix B2 now has two columns for prices, for Shop#1 and Shop#2. Multiplication takes each column in B2 and does the same weighted-column-addition with A2. Hence two columns of answers in C2.
As shown in Gilbert Strang’s book, there are 4 ways of thinking about matrix multiplication:
- Our method of weighting columns in A using columns B and adding
- Weighting rows in B using rows in A and adding
- Multiplying individual values from rows in A and columns in B and adding up, for each location in C. ( This is the common textbook method)
- Multiplying rows in A and columns in B. ( A vectorized version of the previous method).
For now, this one method should suffice.
References
- Gilbert Strang. Linear Algebra and its Applications. Thomson/Brooks-Cole.
- Glenn Henshaw.(Sep 28, 2019) Three Ways to Understand Matrix Multiplication. https://ghenshaw-work.medium.com/3-ways-to-understand-matrix-multiplication-fe8a007d7b26