61
Andrzej Banburski (based on slides of Xavier Boix, in turn based on those of Joe Olson) Tutorial on Linear Algebra Brains, Minds & Machines Summer School 2018

Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Andrzej Banburski

(based on slides of Xavier Boix, in turn based on thoseof Joe Olson)

Tutorial on Linear AlgebraBrains, Minds & Machines Summer School 2018

Page 2: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 3: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 4: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 5: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 6: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 7: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 8: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 9: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 10: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 11: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 12: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 13: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 14: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Convolution as Toeplitz matrix

For experts: even a convolution operation can be recast as matrix multiplication:

https://stackoverflow.com/questions/48768555/toeplitz-matrix-with-an-image

Page 15: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Norms

A function that measures the “size” of a vector is called a norm.

The 𝐿𝑝 norm us given by

More generally, the norm has to satisfy the following:• 𝑓 𝑥 = 0 ⇒ 𝑥 = 0• 𝑓 𝑥 + 𝑦 ≤ 𝑓 𝑥 + 𝑓(𝑦) (triangle inequality• ∀𝛼 ∈ ℝ, 𝑓 𝛼𝑥 = 𝛼 𝑓 𝑥

𝑥 𝑝 =

𝑖

𝑥𝑖𝑝

1𝑝

Page 16: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Norms

The most commonly used norm for vectors is 𝑝 = 2, which is compatible with the inner product

Another useful norm is the 𝐿∞ norm, also known as max norm:

The most natural measure of matrix “size” is the Frobenius norm:

𝑥 2 = 𝑥 ⋅ 𝑥

𝑥 ∞ = max𝑖

𝑥𝑖

𝐴 𝐹 =

𝑖,𝑗

𝐴𝑖𝑗2

Page 17: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Trace

The trace of a matrix is the sum of its’ diagonal entries

Some useful properties:

• 𝑇𝑟 𝐴 = 𝑇𝑟 𝐴𝑇

• 𝑇𝑟 𝐴𝐵𝐶 = 𝑇𝑟 𝐶𝐴𝐵 = 𝑇𝑟(𝐵𝐶𝐴) (if defined)

𝑇𝑟 𝐴 =

𝑖

𝐴𝑖𝑖

Page 18: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Determinant

The determinant is a value that can be computed for a square matrix.

For a 2x2 matrix it is given by 𝑎 𝑏𝑐 𝑑

= 𝑎𝑑 − 𝑏𝑐.

Interpretation: volume of parallelepiped is the absolute value of the determinant of a matrix formed of row vectors r1, r2, r3.

In general for an (n,n) matrix it is given by

Computed over all permutations 𝜎 of the set {1,…,n}.

det 𝐴 =

𝜎∈𝑆𝑛

sgn(𝜎)ෑ

𝑖=1

𝑛

𝐴𝑖,𝜎(𝑖)

Page 19: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 20: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 21: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 22: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 23: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 24: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 25: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 26: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 27: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 28: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 29: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 30: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 31: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 32: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 33: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 34: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 35: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 36: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 37: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 38: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 39: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

When is a matrix invertible

In general, for an inverse matrix 𝐴−1 to exist, 𝐴 has to be square and its’ columns have to form a linearly independent set of vectors – no column can be a linear combination of the others.

A necessary and sufficient condition is that det 𝐴 ≠ 0.

Finding the inverse is usually quite arduous, even though an explicit expression exists:

𝐴−1 =1

det(𝐴)

𝑠=0

𝑛−1

𝐴𝑠

𝑘1,𝑘2,…,𝑘𝑛

𝑙=1

𝑛−1(−1)𝑘𝑙+1

𝑘𝑙! 𝑙𝑘𝑙

𝑇𝑟 𝐴𝑙𝑘𝑙

Page 40: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 41: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 42: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 43: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 44: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 45: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 46: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 47: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 48: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 49: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 50: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Eigendecomposition and SVD

In fact, if a square matrix has n linearly independent eigenvectors, it can always be diagonalized 𝐴 = 𝑈 𝑑𝑖𝑎𝑔 𝜆 𝑈𝑇.

In this case we also immediately get the inverse matrix

For a non-square 𝑚 × 𝑛 matrix we can at best perform the Singular Value Decomposition: 𝐴 = 𝑈 𝐷 𝑉𝑇, where 𝑈 is an 𝑚 ×𝑚 orthogonal matrix, 𝐷 is diagonal 𝑚 × 𝑛 and 𝑉 another n× 𝑛 orthogonal matrix. Elements of 𝐷 are known as singular values

𝐴−1 = 𝑈 𝑑𝑖𝑎𝑔1

𝜆𝑈𝑇

Page 51: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Moore-Penrose Pseudoinverse

Matrix inversion is not defined for non-square matrices. Suppose we have a linear equation 𝐴𝑥 = 𝑦 and we want to solve for 𝑥. • If 𝐴 is taller than wider, there might be no solutions• If it is wider than taller, there might be many solutions.

The pseudoinverse is defined as

In practice we calculate it as 𝐴+ = 𝑉𝐷+𝑈𝑇, where 𝑈,𝐷, 𝑉 are the SVD of 𝐴and 𝐷+ is calculated by taking the reciprocal of non-zero singular values and taking the transpose of the result. (Note this is clearly discontinuous)

𝐴+ = lim𝛼→0+

𝐴𝑇𝐴 + 𝛼𝐼−1𝐴𝑇

Page 52: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 53: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 54: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 55: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 56: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 57: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 58: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 59: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 60: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Linear Algebra

Page 61: Tutorial on Linear AlgebraLinear Algebra When is a matrix invertible In general, for an inverse matrix −1to exist, has to be square and its’ columns have to form a linearly independent

Thanks!