the dsm data matrix
play

The DSM data matrix DSM data are given as a term-term or term-context - PowerPoint PPT Presentation

Introduction The DSM matrix The DSM data matrix DSM data are given as a term-term or term-context matrix: get see use hear eat kill knife 51 20 84 0 3 0 cat 52 58 4 4 6 26 dog 115 83 10 42 33 17 boat 59 39 23 4 0


  1. Vector spaces Formal definition Further properties of vector spaces Further properties of vector spaces: ◮ 0 · u = 0 ◮ λ 0 = 0 ◮ λ u = 0 ⇒ λ = 0 ∨ u = 0 ◮ ( − λ ) u = λ ( − u ) = − ( λ u ) =: − λ u It is easy to show these properties for R n , but they also follow directly from the general axioms for all vector spaces A non-trivial example: vector space C [ a , b ] of continuous real functions f : x �→ f ( x ) over the interval [ a , b ] ◮ vector addition: ∀ f , g ∈ C [ a , b ], we define f + g by ( f + g )( x ) := f ( x ) + g ( x ) ◮ s-multiplication: ∀ λ ∈ R and ∀ f ∈ C [ a , b ], we define λ f by ( λ f )( x ) := λ · f ( x ) ☞ One can show that C [ a , b ] satisfies the vector space axioms Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 15 / 71

  2. Vector spaces Basis & linear subspace Linear combinations & dimensionality Linear combination of vectors u (1) , . . . , u ( n ) : λ 1 u (1) + λ 2 u (2) + · · · + λ n u ( n ) for any coefficients λ 1 , . . . , λ n ∈ R ◮ intuition: all vectors that can be constructed from u (1) , . . . , u ( n ) using the basic vector operations Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 16 / 71

  3. Vector spaces Basis & linear subspace Linear combinations & dimensionality Linear combination of vectors u (1) , . . . , u ( n ) : λ 1 u (1) + λ 2 u (2) + · · · + λ n u ( n ) for any coefficients λ 1 , . . . , λ n ∈ R ◮ intuition: all vectors that can be constructed from u (1) , . . . , u ( n ) using the basic vector operations u (1) , . . . , u ( n ) are linearly independent iff λ 1 u (1) + λ 2 u (2) + · · · + λ n u ( n ) = 0 implies λ 1 = λ 2 = · · · = λ n = 0 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 16 / 71

  4. Vector spaces Basis & linear subspace Linear combinations & dimensionality Linear combination of vectors u (1) , . . . , u ( n ) : λ 1 u (1) + λ 2 u (2) + · · · + λ n u ( n ) for any coefficients λ 1 , . . . , λ n ∈ R ◮ intuition: all vectors that can be constructed from u (1) , . . . , u ( n ) using the basic vector operations u (1) , . . . , u ( n ) are linearly independent iff λ 1 u (1) + λ 2 u (2) + · · · + λ n u ( n ) = 0 implies λ 1 = λ 2 = · · · = λ n = 0 Otherwise, they are linearly dependent ◮ equivalent: one u ( i ) is a linear combination of the other vectors Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 16 / 71

  5. Vector spaces Basis & linear subspace Linear combinations & dimensionality Largest n ∈ N for which there is a set of n linearly independent vectors u ( i ) ∈ V is called the dimension of V : dim V = n It can be shown that dim R n = n Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 17 / 71

  6. Vector spaces Basis & linear subspace Linear combinations & dimensionality Largest n ∈ N for which there is a set of n linearly independent vectors u ( i ) ∈ V is called the dimension of V : dim V = n It can be shown that dim R n = n If there is no maximal number of linearly independent vectors, the vector space is infinite-dimensional (dim V = ∞ ) An example is dim C [ a , b ] = ∞ (easy to show) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 17 / 71

  7. Vector spaces Basis & linear subspace Linear combinations & dimensionality Largest n ∈ N for which there is a set of n linearly independent vectors u ( i ) ∈ V is called the dimension of V : dim V = n It can be shown that dim R n = n If there is no maximal number of linearly independent vectors, the vector space is infinite-dimensional (dim V = ∞ ) An example is dim C [ a , b ] = ∞ (easy to show) Every finite-dimensional vector space V is isomorphic to the Euclidean space R n (with n = dim V ) ☞ We will be able to prove this in a little while Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 17 / 71

  8. Vector spaces Basis & linear subspace Basis & coordinates A set of vectors b (1) , . . . , b ( n ) ∈ V is called a basis of V iff every u ∈ V can be written as a linear combination u = x 1 b (1) + x 2 b (2) + · · · + x n b ( n ) with unique coefficients x 1 , . . . , x n Number of vectors in a basis = dim V Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 18 / 71

  9. Vector spaces Basis & linear subspace Basis & coordinates A set of vectors b (1) , . . . , b ( n ) ∈ V is called a basis of V iff every u ∈ V can be written as a linear combination u = x 1 b (1) + x 2 b (2) + · · · + x n b ( n ) with unique coefficients x 1 , . . . , x n Number of vectors in a basis = dim V For every n -dimensional vector space V , a set of n vectors b (1) , . . . , b ( n ) ∈ V is a basis iff they are linearly independent ☞ Can you think of a proof? Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 18 / 71

  10. Vector spaces Basis & linear subspace Basis & coordinates The unique coefficients x 1 , . . . , x n are called the coordinates b (1) , . . . , b ( n ) � � of u wrt. the basis B := :   x 1 x 2   u ≡ B  =: x  .  .   .  x n Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 19 / 71

  11. Vector spaces Basis & linear subspace Basis & coordinates The unique coefficients x 1 , . . . , x n are called the coordinates b (1) , . . . , b ( n ) � � of u wrt. the basis B := :   x 1 x 2   u ≡ B  =: x  .  .   .  x n x ∈ R n is the coordinate vector of u ∈ V wrt. B ☞ V is isomorphic to R n by virtue of this correspondence Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 19 / 71

  12. Vector spaces Basis & linear subspace Basis & coordinates The unique coefficients x 1 , . . . , x n are called the coordinates b (1) , . . . , b ( n ) � � of u wrt. the basis B := :   x 1 x 2   u ≡ B  =: x  .  .   .  x n x ∈ R n is the coordinate vector of u ∈ V wrt. B ☞ V is isomorphic to R n by virtue of this correspondence We can think of the rows (or columns) of a DSM matrix M as coordinates in an abstract vector space ◮ coordinate transformations play an important role for DSMs Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 19 / 71

  13. Vector spaces Basis & linear subspace Basis & coordinates The components ( u 1 , u 2 , . . . , u n ) of a number vector u ∈ R n correspond to its natural coordinates   u 1 u 2   u = ( u 1 , u 2 , . . . , u n ) ≡ E .   .   .   u n according to the standard basis e (1) , . . . , e ( n ) of R n : e (1) = (1 , 0 , . . . , 0) e (2) = (0 , 1 , . . . , 0) . . . e ( n ) = (0 , 0 , . . . , 1) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 20 / 71

  14. Vector spaces Basis & linear subspace Basis & coordinates u = (4 , 5) ∈ R 2 Basis B of R 2 : x 2 b (1) = (2 , 1) u =(4,5) 6 b (2) = ( − 1 , 1) 5 � 3 � u ≡ B 4 2 3 2 1 x 1 b (2) 1 2 3 4 5 6 b (1) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 21 / 71

  15. Vector spaces Basis & linear subspace Basis & coordinates u = (4 , 5) ∈ R 2 Basis B of R 2 : x 2 b (1) = (2 , 1) u =(4,5) 6 b (2) = ( − 1 , 1) 5 � 3 � u ≡ B 4 2 3 Standard basis: 2 e (1) = (1 , 0) e (2) 1 e (2) = (0 , 1) � 4 � x 1 b (2) 1 2 3 4 5 6 u ≡ E e (1) b (1) 5 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 21 / 71

  16. Vector spaces Basis & linear subspace Linear subspaces The set of all linear combinations of vectors b (1) , . . . , b ( k ) ∈ V is called the span � b (1) , . . . , b ( k ) � � λ 1 b (1) + · · · + λ k b ( k ) | λ i ∈ R � sp := Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 22 / 71

  17. Vector spaces Basis & linear subspace Linear subspaces The set of all linear combinations of vectors b (1) , . . . , b ( k ) ∈ V is called the span � b (1) , . . . , b ( k ) � � λ 1 b (1) + · · · + λ k b ( k ) | λ i ∈ R � sp := b (1) , . . . , b ( k ) � � sp forms a linear subspace of V ◮ a linear subspace is a subset of V that is closed under vector addition and scalar multiplication Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 22 / 71

  18. Vector spaces Basis & linear subspace Linear subspaces The set of all linear combinations of vectors b (1) , . . . , b ( k ) ∈ V is called the span � b (1) , . . . , b ( k ) � � λ 1 b (1) + · · · + λ k b ( k ) | λ i ∈ R � sp := b (1) , . . . , b ( k ) � � sp forms a linear subspace of V ◮ a linear subspace is a subset of V that is closed under vector addition and scalar multiplication b (1) , . . . , b ( k ) form a basis of sp b (1) , . . . , b ( k ) � � iff they are linearly independent ☞ Can you prove that every linear subspace of R n has a basis? Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 22 / 71

  19. Vector spaces Basis & linear subspace Linear subspaces The set of all linear combinations of vectors b (1) , . . . , b ( k ) ∈ V is called the span � b (1) , . . . , b ( k ) � � λ 1 b (1) + · · · + λ k b ( k ) | λ i ∈ R � sp := b (1) , . . . , b ( k ) � � sp forms a linear subspace of V ◮ a linear subspace is a subset of V that is closed under vector addition and scalar multiplication b (1) , . . . , b ( k ) form a basis of sp b (1) , . . . , b ( k ) � � iff they are linearly independent ☞ Can you prove that every linear subspace of R n has a basis? The rank of vectors b (1) , . . . , b ( k ) is the dimension of their span, corresponding to the largest number of linearly independent vectors among them Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 22 / 71

  20. Vector spaces Basis & linear subspace Linear combinations & linear subspace Example: linear subspace U ⊆ R 3 spanned by vectors b (1) = (6 , 0 , 2), b (2) = (0 , 3 , 3) and b (3) = (3 , 1 , 2) ◮ dim U = 2 (why?) x 3 6 5 4 x 2 3 2 1 x 1 1 2 3 4 5 6 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 23 / 71

  21. Vector spaces Basis & linear subspace Linear combinations & linear subspace Example: linear subspace U ⊆ R 3 spanned by vectors b (1) = (6 , 0 , 2), b (2) = (0 , 3 , 3) and b (3) = (3 , 1 , 2) ◮ dim U = 2 (because b (2) = 3 b (3) − 3 2 b (1) ) x 3 6 5 4 x 2 3 2 1 x 1 1 2 3 4 5 6 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 23 / 71

  22. Matrix algebra in a nutshell Matrix as list of vectors Vector u ∈ R n = list of real numbers (coordinates) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 24 / 71

  23. Matrix algebra in a nutshell Matrix as list of vectors Vector u ∈ R n = list of real numbers (coordinates) List of k vectors = rectangular array of real numbers, called a n × k matrix (or k × n row matrix) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 24 / 71

  24. Matrix algebra in a nutshell Matrix as list of vectors Vector u ∈ R n = list of real numbers (coordinates) List of k vectors = rectangular array of real numbers, called a n × k matrix (or k × n row matrix) Example: vectors u , v ∈ R 3     3 2  , u ≡ 0 v ≡ 2    2 1 form the columns of a matrix A :  . .  . .     . . 3 2 a 11 a 12  =   A =  = 0 2 u v a 21 a 22      . .  2 1 a 31 a 32 . . . . Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 24 / 71

  25. Matrix algebra in a nutshell Matrix = list of vectors rank ( A ) = rank of the list of column vectors Column matrices are a convention in linear algebra But DSM matrix often has row vectors for the target terms Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 25 / 71

  26. Matrix algebra in a nutshell Matrix = list of vectors rank ( A ) = rank of the list of column vectors Column matrices are a convention in linear algebra But DSM matrix often has row vectors for the target terms Row rank and column rank of a matrix A are always the same (this is not trivial!) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 25 / 71

  27. Matrix algebra in a nutshell Matrices and linear equation systems Matrices are a versatile instrument and a convenient way to express linear operations on sets of numbers E.g. coefficient matrix of a linear system of equations: a 11 x 1 + a 12 x 2 + · · · + a 1 n x n = b 1 a 21 x 1 + a 22 x 2 + · · · + a 2 n x n = b 2 . . . a k 1 x 1 + a k 2 x 2 + · · · + a kn x n = b k Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 26 / 71

  28. Matrix algebra in a nutshell Matrices and linear equation systems Matrices are a versatile instrument and a convenient way to express linear operations on sets of numbers E.g. coefficient matrix of a linear system of equations: a 11 x 1 + a 12 x 2 + · · · + a 1 n x n = b 1 a 21 x 1 + a 22 x 2 + · · · + a 2 n x n = b 2 . . . a k 1 x 1 + a k 2 x 2 + · · · + a kn x n = b k   x 1     a 11 · · · a 1 n b 1 x 2 . . .   . . . A =  , x =  , b = ➥ .  . .     .  .    .    a k 1 · · · a kn b k x n Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 26 / 71

  29. Matrix algebra in a nutshell Matrix algebra Concise notation of linear equation system by appropriate definition of matrix-vector multiplication a 11 x 1 + a 12 x 2 + · · · + a 1 n x n = b 1 a 21 x 1 + a 22 x 2 + · · · + a 2 n x n = b 2 . . . a k 1 x 1 + a k 2 x 2 + · · · + a kn x n = b k   x 1     a 11 · · · a 1 n b 1 x 2 . .   . . . .  ·  = ➥    .    . . . .      .  · · · a k 1 a kn b k x n Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 27 / 71

  30. Matrix algebra in a nutshell Matrix algebra Concise notation of linear equation system by appropriate definition of matrix-vector multiplication a 11 x 1 + a 12 x 2 + · · · + a 1 n x n = b 1 a 21 x 1 + a 22 x 2 + · · · + a 2 n x n = b 2 . . . a k 1 x 1 + a k 2 x 2 + · · · + a kn x n = b k   x 1     a 11 · · · a 1 n b 1 x 2 . .   . . . .  ·  = ➥    .    . . . .      .  · · · a k 1 a kn b k x n A · x = b ➥ Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 27 / 71

  31. Matrix algebra in a nutshell Matrix algebra The set of all real-valued k × n matrices forms a ( k · n )-dimensional vector space over R : ◮ A + B is defined by element-wise addition ◮ λ A is defined by element-wise s-multiplication ◮ these operations satisfy all vector space axioms Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 28 / 71

  32. Matrix algebra in a nutshell Matrix algebra The set of all real-valued k × n matrices forms a ( k · n )-dimensional vector space over R : ◮ A + B is defined by element-wise addition ◮ λ A is defined by element-wise s-multiplication ◮ these operations satisfy all vector space axioms Additional operation: matrix multiplication ◮ two equation systems: z = B · y and y = C · x ◮ by inserting the expressions for y into the first system, we can express z directly in terms of x (and use this e.g. to solve the equations for x ) ◮ the result is a linear equation system z = A · x ☞ define matrix multiplication such that A = B · C Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 28 / 71

  33. Matrix algebra in a nutshell Matrix multiplication   c 1 j .    · · ·  a ij b i 1 b in .   .   = · .       .  .    c nj A = B · C ( k × m ) ( k × n ) ( n × m ) B and C must be conformable Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 29 / 71

  34. Matrix algebra in a nutshell Matrix multiplication   c 1 j .    · · ·  a ij b i 1 b in .   .   = · .       .  .    c nj A = B · C ( k × m ) ( k × n ) ( n × m ) B and C must be conformable Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 29 / 71

  35. Matrix algebra in a nutshell Matrix multiplication   c 1 j .     .   .    a ij =  b i 1 · · · b in · .     .  .    c nj A = B · C ( k × m ) ( k × n ) ( n × m ) B and C must be conformable Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 30 / 71

  36. Matrix algebra in a nutshell Matrix multiplication   c 1 j .     .   .    a ij =  b i 1 · · · b in · .     .  .    c nj A = B · C ( k × m ) ( k × n ) ( n × m ) B and C must be conformable ☞ A · x corresponds to matrix multiplication of A with a single-column matrix (containing the vector x ) ◮ convention: vector = column matrix Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 30 / 71

  37. Matrix algebra in a nutshell Matrix multiplication Algebra = vector space + multiplication operation with the following properties: ◮ A ( BC ) = ( AB ) C =: ABC ◮ A ( B + B ′ ) = AB + AB ′ ◮ ( A + A ′ ) B = AB + A ′ B ◮ ( λ A ) B = A ( λ B ) = λ ( AB ) =: λ AB ◮ A · 0 = 0 , 0 · B = 0 ◮ A · I = A , I · B = B where A , B and C are conformable matrices 0 is a zero matrix of arbitrary dimensions I is a square identity matrix of arbitrary dimensions:   1 ... I :=     1 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 31 / 71

  38. Matrix algebra in a nutshell Transposition The transpose A T of a matrix A swaps rows and columns: T   a 1 b 1 � a 1 � a 2 a 3 a 2 b 2 =   b 1 b 2 b 3 a 3 b 3 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 32 / 71

  39. Matrix algebra in a nutshell Transposition The transpose A T of a matrix A swaps rows and columns: T   a 1 b 1 � a 1 � a 2 a 3 a 2 b 2 =   b 1 b 2 b 3 a 3 b 3 Properties of the transpose: ◮ ( A + B ) T = A T + B T ◮ ( λ A ) T = λ ( A T ) =: λ A T ◮ ( A · B ) T = B T · A T [note the different order of A and B !] ◮ rank � A T � = rank ( A ) ◮ I T = I Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 32 / 71

  40. Matrix algebra in a nutshell Transposition The transpose A T of a matrix A swaps rows and columns: T   a 1 b 1 � a 1 � a 2 a 3 a 2 b 2 =   b 1 b 2 b 3 a 3 b 3 Properties of the transpose: ◮ ( A + B ) T = A T + B T ◮ ( λ A ) T = λ ( A T ) =: λ A T ◮ ( A · B ) T = B T · A T [note the different order of A and B !] ◮ rank � A T � = rank ( A ) ◮ I T = I A is called symmetric iff A T = A ◮ symmetric matrices have many special properties that will become important later (e.g. eigenvalues) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 32 / 71

  41. Matrix algebra in a nutshell Vectors and matrices A coordinate vector x ∈ R n can be identified with a n × 1 matrix (i.e. a single-column matrix):   x 1 . � T . � x =  = · · · x 1 x n   .  x n Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 33 / 71

  42. Matrix algebra in a nutshell Vectors and matrices A coordinate vector x ∈ R n can be identified with a n × 1 matrix (i.e. a single-column matrix):   x 1 . � T . � x =  = · · · x 1 x n   .  x n Multiplication of a matrix A containing the vectors a (1) , . . . , a ( k ) with a vector of coefficients λ 1 , . . . , λ k yields a linear combination of a (1) , . . . , a ( k ) :   λ 1 .  = λ 1 a (1) + · · · + λ k a ( k ) . A ·   .  λ k Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 33 / 71

  43. Matrix algebra with R R as a toy DSM laboratory Matrix algebra is a powerful and convenient tool in numerical mathematics ➜ implement DSM with matrix operations Specialised (and highly optimised) libraries are available for various programming languages (C, C++, Perl, Python, . . . ) Some numerical programming environments are even based entirely on matrix algebra (Matlab, Octave, NumPy/Sage) Statistical software packages like R also support matrices Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 34 / 71

  44. Matrix algebra with R R as a toy DSM laboratory Matrix algebra is a powerful and convenient tool in numerical mathematics ➜ implement DSM with matrix operations Specialised (and highly optimised) libraries are available for various programming languages (C, C++, Perl, Python, . . . ) Some numerical programming environments are even based entirely on matrix algebra (Matlab, Octave, NumPy/Sage) Statistical software packages like R also support matrices R as a DSM laboratory for toy models http://www.r-project.org/ Integrates efficient matrix operations with statistical analysis, clustering, machine learning, visualisation, . . . Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 34 / 71

  45. Matrix algebra with R Matrix algebra with R Vectors in R: u1 <- c(3, 0, 2) u2 <- c(0, 2, 2) v <- 1:6 print(v) [1] 1 2 3 4 5 6 Defining matrices: A <- matrix(v, nrow=3) print(A) [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 35 / 71

  46. Matrix algebra with R Matrix algebra in R Matrix of column vectors: B <- cbind(u1, u2) print(B) u1 u2 [1,] 3 0 [2,] 0 2 [3,] 2 2 Matrix of row vectors: C <- rbind(u1, u2) print(C) [,1] [,2] [,3] u1 3 0 2 u2 0 2 2 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 36 / 71

  47. Matrix algebra with R Matrix algebra in R Matrix multiplication: A %*% C [,1] [,2] [,3] [1,] 3 8 10 [2,] 6 10 14 [3,] 9 12 18 NB: * does not perform matrix multiplication Also for multiplication of matrix with vector: C %*% c(1,1,0) [,1] u1 3 u2 2 ☞ result of multiplication is a column vector (i.e. plain vectors are interpreted as column vectors in matrix operations) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 37 / 71

  48. Matrix algebra with R Matrix algebra in R Transpose of matrix: t(A) [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 Transposition of vectors: t(u1) (row vector) [,1] [,2] [,3] [1,] 3 0 2 t(t(u1)) (explicit column vector) [,1] [1,] 3 [2,] 0 [3,] 2 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 38 / 71

  49. Matrix algebra with R Matrix algebra in R Rank of a matrix: qr(A)$rank 2 la.rank <- function (A) qr(A)$rank la.rank(A) Column rank = row rank: la.rank(A) == la.rank(t(A)) [1] TRUE A T · A is symmetric (can you prove this?): t(A) %*% A Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 39 / 71

  50. Matrix algebra and linear maps Linear maps A linear map is a homomorphism between two vector spaces V and W , i.e. a function f : V → W that is compatible with addition and s-multiplication: f ( u + v ) = f ( u ) + f ( v ) 1 f ( λ u ) = λ · f ( u ) 2 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 40 / 71

  51. Matrix algebra and linear maps Linear maps A linear map is a homomorphism between two vector spaces V and W , i.e. a function f : V → W that is compatible with addition and s-multiplication: f ( u + v ) = f ( u ) + f ( v ) 1 f ( λ u ) = λ · f ( u ) 2 Obviously, f is uniquely determined by the images of any basis b (1) , . . . , b ( n ) of V b (1) � b ( n ) � � � f , . . . , f Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 40 / 71

  52. Matrix algebra and linear maps Linear maps A linear map is a homomorphism between two vector spaces V and W , i.e. a function f : V → W that is compatible with addition and s-multiplication: f ( u + v ) = f ( u ) + f ( v ) 1 f ( λ u ) = λ · f ( u ) 2 Obviously, f is uniquely determined by the images of any basis b (1) , . . . , b ( n ) of V b (1) � b ( n ) � � � f , . . . , f Using natural coordinates, a linear map f : R n → R k can therefore be described by the vectors     a 11 a 1 n a 21 a 2 n     e (1) � e ( n ) � � � ≡ E ≡ E f  , . . . , f  .   .  . .     . .    a k 1 a kn Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 40 / 71

  53. Matrix algebra and linear maps Matrix representation of a linear map For a vector u = x 1 e (1) + · · · + x n e ( n ) ∈ R n , we have x 1 e (1) + · · · + x n e ( n ) � � v = f ( u ) = f e (1) � e ( n ) � � � = x 1 · f + · · · + x n · f and hence the natural coordinate vector y of v is given by y j = x 1 · a j 1 + x 2 · a j 2 + · · · + x n · a jn Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 41 / 71

  54. Matrix algebra and linear maps Matrix representation of a linear map For a vector u = x 1 e (1) + · · · + x n e ( n ) ∈ R n , we have x 1 e (1) + · · · + x n e ( n ) � � v = f ( u ) = f e (1) � e ( n ) � � � = x 1 · f + · · · + x n · f and hence the natural coordinate vector y of v is given by y j = x 1 · a j 1 + x 2 · a j 2 + · · · + x n · a jn This corresponds to matrix multiplication       · · · y 1 a 11 a 1 n x 1 . . . . . . . .  =  ·       . . . .     y k a k 1 · · · a kn x n v = f ( u ) ⇐ ⇒ y = A · x ➥ Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 41 / 71

  55. Matrix algebra and linear maps Image & kernel The image of a linear map f : R n → R k is the subspace of all values v ∈ R k that f ( u ) can assume for u ∈ R n : � e ( n ) �� e (1) � � � Im ( f ) := sp f , . . . , f Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 42 / 71

  56. Matrix algebra and linear maps Image & kernel The image of a linear map f : R n → R k is the subspace of all values v ∈ R k that f ( u ) can assume for u ∈ R n : � e ( n ) �� e (1) � � � Im ( f ) := sp f , . . . , f � � The rank of f is defined by rank ( f ) := dim Im ( f ) rank ( f ) = rank ( A ) for the matrix representation A f is surjective (onto) iff Im ( f ) = R k , i.e. rank ( f ) = k Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 42 / 71

  57. Matrix algebra and linear maps Image & kernel The image of a linear map f : R n → R k is the subspace of all values v ∈ R k that f ( u ) can assume for u ∈ R n : � e ( n ) �� e (1) � � � Im ( f ) := sp f , . . . , f � � The rank of f is defined by rank ( f ) := dim Im ( f ) rank ( f ) = rank ( A ) for the matrix representation A f is surjective (onto) iff Im ( f ) = R k , i.e. rank ( f ) = k The kernel of f is the subspace of all x ∈ R n that are mapped to 0 ∈ R k : Ker ( f ) := { x ∈ R n | f ( x ) = 0 } Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 42 / 71

  58. Matrix algebra and linear maps Rank & composition � � � � We have dim Im ( f ) + dim Ker ( f ) = n f is injective iff every v ∈ Im ( f ) has a unique preimage � � v = f ( u ), i.e. iff Ker ( f ) = 0 or rank ( f ) = n Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 43 / 71

  59. Matrix algebra and linear maps Rank & composition � � � � We have dim Im ( f ) + dim Ker ( f ) = n f is injective iff every v ∈ Im ( f ) has a unique preimage � � v = f ( u ), i.e. iff Ker ( f ) = 0 or rank ( f ) = n The composition of linear maps corresponds to matrix multiplication: Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 43 / 71

  60. Matrix algebra and linear maps Rank & composition � � � � We have dim Im ( f ) + dim Ker ( f ) = n f is injective iff every v ∈ Im ( f ) has a unique preimage � � v = f ( u ), i.e. iff Ker ( f ) = 0 or rank ( f ) = n The composition of linear maps corresponds to matrix multiplication: ◮ f : R n → R k given by a k × n matrix A ◮ g : R k → R m given by a m × k matrix B ◮ recall that ( g ◦ f )( u ) := g ( f ( u )) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 43 / 71

  61. Matrix algebra and linear maps Rank & composition � � � � We have dim Im ( f ) + dim Ker ( f ) = n f is injective iff every v ∈ Im ( f ) has a unique preimage � � v = f ( u ), i.e. iff Ker ( f ) = 0 or rank ( f ) = n The composition of linear maps corresponds to matrix multiplication: ◮ f : R n → R k given by a k × n matrix A ◮ g : R k → R m given by a m × k matrix B ◮ recall that ( g ◦ f )( u ) := g ( f ( u )) ➥ the composition g ◦ f : R n → R m is given by the matrix product B · A Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 43 / 71

  62. Matrix algebra and linear maps The inverse matrix A linear map f : R n → R n is called an endomorphism ◮ can be represented by a square matrix A Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 44 / 71

  63. Matrix algebra and linear maps The inverse matrix A linear map f : R n → R n is called an endomorphism ◮ can be represented by a square matrix A f surjective ⇐ ⇒ rank ( f ) = n ⇐ ⇒ f injective e (1) � e ( n ) �� � � � rank ( f ) = rank f , . . . , f = n ⇐ ⇒ rank ( A ) = n ⇐ ⇒ det A � = 0 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 44 / 71

  64. Matrix algebra and linear maps The inverse matrix A linear map f : R n → R n is called an endomorphism ◮ can be represented by a square matrix A f surjective ⇐ ⇒ rank ( f ) = n ⇐ ⇒ f injective e (1) � e ( n ) �� � � � rank ( f ) = rank f , . . . , f = n ⇐ ⇒ rank ( A ) = n ⇐ ⇒ det A � = 0 ➥ f bijective (one-to-one) ⇐ ⇒ det A � = 0 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 44 / 71

  65. Matrix algebra and linear maps The inverse matrix A linear map f : R n → R n is called an endomorphism ◮ can be represented by a square matrix A f surjective ⇐ ⇒ rank ( f ) = n ⇐ ⇒ f injective e (1) � e ( n ) �� � � � rank ( f ) = rank f , . . . , f = n ⇐ ⇒ rank ( A ) = n ⇐ ⇒ det A � = 0 ➥ f bijective (one-to-one) ⇐ ⇒ det A � = 0 If f is bijective, there exists an inverse function f − 1 : R n → R n , which is also a linear map and satisfies f − 1 ( f ( u )) = u and f ( f − 1 ( v )) = v f − 1 is given by the inverse matrix A − 1 of A , which must satisfy A − 1 · A = A · A − 1 = I Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 44 / 71

  66. Matrix algebra Solving equation systems Linear equation systems Recall that a linear system of equations can be written in compact matrix notation: a 11 x 1 + a 12 x 2 + · · · + a 1 n x n = b 1 a 21 x 1 + a 22 x 2 + · · · + a 2 n x n = b 2 . . . a k 1 x 1 + a k 2 x 2 + · · · + a kn x n = b k Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 45 / 71

  67. Matrix algebra Solving equation systems Linear equation systems Recall that a linear system of equations can be written in compact matrix notation:   x 1     a 11 . . . a 1 n b 1 x 2 . . .   . . .  ·  =    .    . . . .      .  a k 1 . . . a kn b k x n Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 45 / 71

  68. Matrix algebra Solving equation systems Linear equation systems Recall that a linear system of equations can be written in compact matrix notation: A · x = b Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 45 / 71

  69. Matrix algebra Solving equation systems Linear equation systems Recall that a linear system of equations can be written in compact matrix notation: A · x = b Obviously, A describes a linear map f : R n → R k , and the linear system of equations can be written f ( x ) = b Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 45 / 71

  70. Matrix algebra Solving equation systems Linear equation systems Recall that a linear system of equations can be written in compact matrix notation: A · x = b Obviously, A describes a linear map f : R n → R k , and the linear system of equations can be written f ( x ) = b This linear system can be solved iff b ∈ Im ( f ), i.e. iff b is a linear combination of the column vectors of A Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 45 / 71

  71. Matrix algebra Solving equation systems Linear equation systems Recall that a linear system of equations can be written in compact matrix notation: A · x = b Obviously, A describes a linear map f : R n → R k , and the linear system of equations can be written f ( x ) = b This linear system can be solved iff b ∈ Im ( f ), i.e. iff b is a linear combination of the column vectors of A The solution is given by the coefficients x 1 , . . . , x n of this linear combination Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 45 / 71

  72. Matrix algebra Solving equation systems Linear equation systems The linear system has a solution for arbitrary b ∈ R k iff f is surjective, i.e. iff rank ( A ) = k Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 46 / 71

  73. Matrix algebra Solving equation systems Linear equation systems The linear system has a solution for arbitrary b ∈ R k iff f is surjective, i.e. iff rank ( A ) = k Solutions of the linear system are unique iff f is injective, i.e. iff rank ( A ) = n (the column vectors are linearly independent) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 46 / 71

  74. Matrix algebra Solving equation systems Linear equation systems The linear system has a solution for arbitrary b ∈ R k iff f is surjective, i.e. iff rank ( A ) = k Solutions of the linear system are unique iff f is injective, i.e. iff rank ( A ) = n (the column vectors are linearly independent) If k = n (i.e. A is a square matrix), the linear map f is an endomorphism. Consequently, the linear system has a unique solution for arbitrary b iff det A � = 0 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 46 / 71

  75. Matrix algebra Solving equation systems Linear equation systems The linear system has a solution for arbitrary b ∈ R k iff f is surjective, i.e. iff rank ( A ) = k Solutions of the linear system are unique iff f is injective, i.e. iff rank ( A ) = n (the column vectors are linearly independent) If k = n (i.e. A is a square matrix), the linear map f is an endomorphism. Consequently, the linear system has a unique solution for arbitrary b iff det A � = 0 In this case, the solution can be computed with the inverse function f − 1 or the inverse matrix A − 1 : x = f − 1 ( b ) = A − 1 · b ☞ practically, A − 1 is often determined by solving the corresponding linear system of equations Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 46 / 71

  76. Matrix algebra Solving equation systems Linear equation systems Solving equation systems in R: A <- rbind(c(1,3), c(2,-1)) b <- c(5,3) la.rank(A) (test that A is invertible) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 47 / 71

  77. Matrix algebra Solving equation systems Linear equation systems Solving equation systems in R: A <- rbind(c(1,3), c(2,-1)) b <- c(5,3) la.rank(A) (test that A is invertible) A.inv <- solve(A) (inverse matrix A − 1 ) print(round(A.inv, digits=3)) [,1] [,2] [1,] 0.143 0.429 [2,] 0.286 -0.143 Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 47 / 71

  78. Matrix algebra Solving equation systems Linear equation systems Solving equation systems in R: A <- rbind(c(1,3), c(2,-1)) b <- c(5,3) la.rank(A) (test that A is invertible) A.inv <- solve(A) (inverse matrix A − 1 ) print(round(A.inv, digits=3)) [,1] [,2] [1,] 0.143 0.429 [2,] 0.286 -0.143 A.inv %*% b [,1] [1,] 2 [2,] 1 solve(A, b) (recommended: calculate A − 1 · b directly) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 47 / 71

  79. Matrix algebra Coordinate transformation Coordinate transformations We want to transform between coordinates with respect to a basis b (1) , . . . , b ( n ) and standard coordinates in R n x 2 u =(4,5) 6 5 4 3 2 e (2) 1 x 1 b (2) 1 2 3 4 5 6 e (1) b (1) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 48 / 71

  80. Matrix algebra Coordinate transformation Coordinate transformations The basis can be represented by a matrix B whose columns are the standard coordinates of b (1) , . . . , b ( n ) Given a vector u ∈ R n with standard coordinates u ≡ E x and B -coordinates u ≡ B y , we have u = y 1 b (1) + · · · + y n b ( n ) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 49 / 71

  81. Matrix algebra Coordinate transformation Coordinate transformations The basis can be represented by a matrix B whose columns are the standard coordinates of b (1) , . . . , b ( n ) Given a vector u ∈ R n with standard coordinates u ≡ E x and B -coordinates u ≡ B y , we have u = y 1 b (1) + · · · + y n b ( n ) In standard coordinates, this equation corresponds to matrix multiplication: x = B · y ➥ Matrix B transforms B -coordinates into standard coordinates Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 49 / 71

  82. Matrix algebra Coordinate transformation Coordinate transformations To transform from standard coordinates into B -coordinates, i.e. from x to y , we must solve the linear system x = By Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 28 July 2009 50 / 71

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend