Linear Algebra 4. Matrix multiplication.
When you apply one LT and then the other LT (example: 90° clockwise rotation and then shear (shift) the overall effect is another LT which is composition of two LT. This LT will capture overall effect of applying 2 LTs into a single LT.
Applying several LT to one vector is like using several functions and using output of one function as input to the other:
ƒ(g(x)) where:
Applying several LT to one vector is like using several functions and using output of one function as input to the other:
ƒ(g(x)) where:
- g is the first LT with input "x"
- ƒ is the second LT with input from the previous LT
So the same as with functions - we apply LT from right to the left.
The composition of two LTs is multiplication / product / dot product of two LT - product of two matrices:
C = AB where:
- A have the same number of columns as B has rows or mathematically
- Al x m and Bm x n
- easy way - to check dot product possibility
- example: A2 x 3 and B3 x 4
- Write dimensions of matrices one after the other with "=" sign between them:
- 2 x 3 = 3 x 4 as you see 3 = 3, so we can dot-product these matrices
- example: A2 x 2 and B3 x 3
- 2 x 2 = 3 x 3 as you see 2 = 3 is not true, so we can't multiply that matrices
-
Ci,j = m Ai,k Bk,j ∑ k=1
⌈ | 0 | 2 | ⌉ | ⌈ | 1 | -2 | ⌉ |
⌊ | 1 | 0 | ⌋ | ⌊ | 1 | 0 | ⌋ |
A2 x 2 and B2 x 2 find k: 2 x 2 = 2 x 2 , 2 = 2, k = 2, k shows how many times we sum product of factors A and B:
Change general formula for this particular case:
Then:
C1,2 = A1,1 ⋅ B1,2 + A1,2 ⋅ B2,2= 0*(-2) + 2*0 = 0
C2,1 = A2,1 ⋅ B1,1 + A2,2 ⋅ B2,1= 1*1 + 0*1 = 1
C2,2 = A2,1 ⋅ B1,2 + A2,2 ⋅ B2,2= 1*(-2) + 0*0 = -2
The simplest way to calculate matrix dot product is to approach it as matrix vector product:
First we find î of the right matrix after applying left matrix (LT):
Secondly we find ĵ hat of the right matrix after applying left matrix (LT):
Matrix product properties:
A(B + C) = AB + AC distributive property
A(BC) = (AB)C associative property
But AB≠BA (because matrix is LT, and LT is like function, so apply right to left)
Also matrix element wise product (or Hadamard product) exists. It is supported only for matrices of the same shape:
C = A ⊙ B where Ci,j = Ai,j Bi,j
With 3-D Tensor basis are î , ĵ and k̂ and it's linear combination is:
Ci,j = | 2 | Ai,k Bk,j |
∑ | ||
k=1 |
C1,1 = | 2 | A1,k Bk,1 | = | A1,1 B1,1 + | A1,2 B2,1 = | 0*1 + 2*1 = 2 |
∑ | ||||||
k=1 |
C1,2 = A1,1 ⋅ B1,2 + A1,2 ⋅ B2,2= 0*(-2) + 2*0 = 0
C2,1 = A2,1 ⋅ B1,1 + A2,2 ⋅ B2,1= 1*1 + 0*1 = 1
C2,2 = A2,1 ⋅ B1,2 + A2,2 ⋅ B2,2= 1*(-2) + 0*0 = -2
The simplest way to calculate matrix dot product is to approach it as matrix vector product:
First we find î of the right matrix after applying left matrix (LT):
⌈ | 0 | 2 | ⌉ | ⋅ | ⌈ | 1 | ⌉ |
⌊ | 1 | 0 | ⌋ | ⌊ | 1 | ⌋ |
⌈ | 0 | 2 | ⌉ | ⋅ | ⌈ | -2 | ⌉ |
⌊ | 1 | 0 | ⌋ | ⌊ | 1 | ⌋ |
Matrix product properties:
A(B + C) = AB + AC distributive property
A(BC) = (AB)C associative property
But AB≠BA (because matrix is LT, and LT is like function, so apply right to left)
Also matrix element wise product (or Hadamard product) exists. It is supported only for matrices of the same shape:
C = A ⊙ B where Ci,j = Ai,j Bi,j
With 3-D Tensor basis are î , ĵ and k̂ and it's linear combination is:
v = | î | xî + yĵ + zk̂ |
ĵ = | ||
k̂ |
These materials were used while preparing this blog-post:
No comments:
Post a Comment