Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Linear Algebra Cheatsheet: Basics of Vectors and Matrices, Summaries of Linear Algebra

Cheatsheet on Linear Algebra: Basics of vectors and matrices, Addition and scalar multiplication, Vector to matrix multiplication

Typology: Summaries

2019/2020

Uploaded on 10/09/2020

anarghya
anarghya 🇺🇸

4.2

(21)

255 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Linear Algebra Cheatsheet
UiO Language Technology Group
1 Basics of vectors and matrices
1.1 Matrices
Matrix is a rectangular 2-dimensional array of numbers (scalars).
MRm×nis a matrix Mwith mrows and ncolumns.
For example:
M=
1234
0000
4321
Here, Mis a 3×4matrix: it has 3 rows and 4 columns. 3and 4are the
dimensions of M.
1.2 Entries
Matrices consist of entries.
Mi,j or M[i,j]is the entry in the ith row and jth column of M.
For example:
M0,0= 1
NB: we use 0-indexed notation, following Python conventions.
1.3 Vectors
Vector is a 1×nmatrix (NB: we use row vectors).
vRnis a vector vwith nentries or components (n-dimensional vector).
For example:
v= [4,3,2,1]
Here, vis a 4-dimensional vector.
vior v[i]is the ith entry of the vector.
For example:
v1= 3
1
pf3
pf4
pf5

Partial preview of the text

Download Linear Algebra Cheatsheet: Basics of Vectors and Matrices and more Summaries Linear Algebra in PDF only on Docsity!

Linear Algebra Cheatsheet

UiO Language Technology Group

1 Basics of vectors and matrices

1.1 Matrices

  • Matrix is a rectangular 2-dimensional array of numbers (scalars).
  • M ∈ Rm×n^ is a matrix M with m rows and n columns.
  • For example:

M =

  • Here, M is a 3 × 4 matrix: it has 3 rows and 4 columns. 3 and 4 are the dimensions of M.

1.2 Entries

  • Matrices consist of entries.
  • Mi,j or M[i,j] is the entry in the ith^ row and jth^ column of M.
  • For example: M 0 , 0 = 1
  • NB: we use 0-indexed notation, following Python conventions.

1.3 Vectors

  • Vector is a 1 × n matrix (NB: we use row vectors).
  • v ∈ Rn^ is a vector v with n entries or components (n-dimensional vector).
  • For example: v = [4, 3 , 2 , 1]
  • Here, v is a 4-dimensional vector.
  • vi or v[i] is the ith^ entry of the vector.
  • For example: v 1 = 3

2 Addition and scalar multiplication

2.1 Matrix addition

  • Matrix addition is simply adding the entries of two or more matrices one by one.
  • This summation results in another matrix:
  • M + M = M
  • For example:  
  • NB: we can add only matrices of the same dimensionality!
  • The resulting matrix retains the same dimensions ( 3 × 3 in the example above).
  • One can subtract matrices in the same way.

2.2 Multiplication by scalar

  • To multiply a matrix by scalar (a raw number), one also simply mul- tiplies all its entries by this scalar.
  • It results in another matrix of the same dimensionality.
  • For example: (^) 

 × 2 =

  • Note that the multiplication of a matrix by a scalar and the multiplication of a scalar by a matrix are equal:  

 × 2 = 2 ×

  • One can divide a matrix by a scalar in the same way:  
  • This essentially amounts to the scalar multiplication by fraction:  

 × 1

4.2 Process

  • The result of right-multiplying a vector v ∈ Rm^ (or, equally, v ∈ R^1 ×m) by a matrix W ∈ Rm×n^ is a vector y ∈ Rn - v · W = y - note how the matching dimensions m are ‘self-destroyed’.
  • Each component i of y is a sum of one-by-one multiplying columns of v by the entries of the ith^ column of W.
  • For example:

y = v · W = [2, 3] ·

[

]

= [17, 10 , 9]

  1. y 0 = v 0 × W 0 , 0 + v 1 × W 1 , 0 = 2 × 4 + 3 × 3 = 8 + 9 = 17
  2. y 1 = v 0 × W 0 , 1 + v 1 × W 1 , 1 = 2 × 2 + 3 × 2 = 4 + 6 = 10
  3. y 2 = v 0 × W 0 , 2 + v 1 × W 1 , 2 = 2 × 3 + 3 × 1 = 6 + 3 = 9
  • Here, the result is the 3-dimensional row vector y ∈ R^3.

5 Matrix to matrix multiplication

5.1 Matrix to matrix is another matrix

  • Any row vector is in fact a 1 × n matrix.
  • Thus, to multiply one matrix by another, is conceptually the same as multiplying a vector by a matrix.
  • Again, the number of columns in the left matrix W 1 must match the number of rows of the right matrix W 2 : W 1 ∈ Rm×n, W 2 ∈ Rn×z
  • But the result of this multiplication is another matrix : W 1 · W 2 = W 3 ∈ Rm×z - Again, the matching dimensions n are ‘self-destroyed’.

5.2 Process

  • For example, suppose W 1 ∈ R^2 ×^3 , W 2 ∈ R^3 ×^4 :

W 3 = W 1 · W 2 =

[

]

[

]

  • Here, W 3 ∈ R^2 ×^4
  • It is produced like this:
  • Each row i of W ^ is a product of multiplying the ith^ row of W ^ (a vector) by W ^ (a matrix):

1. W [0,:] = W [0,:] ·W ^ = [4, 2 , 3]·

 = [19, 17 , 19 , 16]

2. W [1,:] = W [1,:] ·W ^ = [3, 2 , 1]·

 = [11, 10 , 11 , 10]

  1. etc...

5.3 Properties of matrix multiplication

  • Matrix multiplication is not commutative: W 1 · W 2 6 = W 2 · W 1
  • Matrix multiplication is associative: W 1 · W 2 · W 3 = W 1 · (W 2 · W 3 ) = (W 1 · W 2 ) · W 3