2. Matrix Mutiplication#

Am×nBn×p=Cm×p

2.1. Interpret by column#

  • We could consider it as A * a set of column vectors, since each column of C only depends on A * each column of B

  • For example

[273849][1601]=[[273849][10],[273849][61]]=[1[234]+0[789],6[234]+1[789]]

2.2. Interpret by row#

  • Rows of C are combination of rows of B

  • For example

[273849][1601]=[[27][1601][38][1601][49][1601]]=[2[16]+7[01]3[16]+8[01]4[16]+9[01]]

2.3. Another mutiplication rule#

  • Z = Column of A * Row of B

  • Example

[273849][1601]
  • E.g.

    [23318424]=[212318424],

    it fits our rule: the columns of C are combinations of columns of A, and rows of C are combinations of rows of B.

    Since $[212318424]$

    can be decomposed as two 3×1 and 1×2 matrices, we can see that no matter the column space or row space,

    [212318424]

    is a line.

    Therefore, AB=sum of (columns of A× rows of B)

    [273849][1601]=[233449][16]+[789][01]=[2×6+73×6+84×6+9]

2.4. The Laws for Matrix Operations#

2.4.1. About addition#

A+B=B+A(commutative law)
c(A+B)=cA+cB(distributive law)
A+(B+C)=(A+B)+C(associative law)

2.4.2. About multiplication#

ABBA(the commutative "law" is usually broken)
A(B+C)=AB+AC(distributive law from the left)
(A+B)C=AC+BC(distributive law from the right)
A(BC)=(AB)C(associative law for ABC) (parentheses not needed)

2.4.3. About Powers#

Ap=AAAA(p factors)
(Ap)(Aq)=Ap+q
(Ap)q=Apq.

2.5. Block multiplication#

If A can be divided into 4 blocks of matrices, A1,A2,A3,A4, and B as B1,B2,B3,B4, then

[A1A2A3A4][B1B2B3B4]=[A1B1+A2B3]

Just like regular matrix multiplication.

2.6. Inverse#

For rectangular matrices, the left inverse is not equal to the right inverse, but for a square matrix,

A1A=I=AA1

2.6.1. Example#

[1327][acbd]=[1001][acbd]=[7321]

2.6.2. property#

image.png

2.7. Two ways to solve the inverse#

2.7.1. Solve them by the meaning#

[13][ab]=[10]a+3b=1a=7,b=2
[27][ab]=[10]2a+7b=0
[13][cd]=[01]c+3d=0c=3,d=1
[27][cd]=[01]2c+7d=1

2.7.2. Gauss -Jordan (Augmented matrix)#

[13102701][13100121][10730121]
E[AI]=[IA1],E is the elimination matrix

2.8. Singular matrix (do not have inverse)#

[1326]

Square matrices do not have an inverse if I can find a vector x with Ax=0.

[1326][31]=[00]

2.9. Important Example#

image.png

The matrix S2 has a useful interpretation. (S2)ij counts the walks of length 2 between node i and node j. Between nodes 2 and 3, the graph has two walks: go via 1 or go via 4. From node 1 to node 1, there are also two walks: 1→2→1 and 1→3→1.

S2=[2112132112122112]S3=[2552545555452552]

Can you find 5 walks of length 3 between nodes 1 and 2?

The real question is why SN counts all the N-step paths between pairs of nodes. Start with S2 and look at matrix multiplication by dot products:

(S2)ij=(row i of S)(column j of S)=si1s1j+si2s2j+si3s3j+si4s4j.(7)

If there is a 2-step path i1j, the first multiplication gives si1s1j=(1)(1)=1. If i1j is not a path, then either i1 is missing or 1j is missing. So the multiplication gives si1s1j=0 in that case.