Introduction to Matrices and Vectors Sebastian van Delden USC Upstate
Introduction m rows n columns m n matrix element in ith row, jth column When m = n, A is called a square matrix. Also written as A= a ij Definition: A matrix is a rectangular array of numbers.
Matrix Equality Definition: Let A and B be two matrices. These matrices are the same, that is, A = B if they have the same number of rows and columns, and every element at each position in A equals the element at corresponding position in B. * This is not trivial if elements are real numbers subject to digital approximation.
The Transpose of a Matrix Note that (X T ) T = X
5 Matrix Addition, Subtraction Let A = a ij , B = b ij be m n matrices. Then: –– A + B = a ij + b ij , and A – B = a ij – b ij
Properties of Matrix Addition Commutative:A + B = B + A Associative:A + (B + C) = (A + B) + C
Inventories Makealot, Inc. manufactures widgets, nerfs, smores, and flots. It supplies three different warehouses (#1,#2,#3). Opening inventory: Sales:Closing inventory: – = w n s f #1 #2 #3
Scalar Multiplication Associative:c 1 (c 2 A) = (c 1 c 2 )A Distributive:(c 1 + c 2 ) A = c 1 A + c 2 A
Matrix Multiplication Let A be an m k matrix, and B be a k n matrix. Then their product is: AB=[c ij ]
Matrix Multiplication Let A be an m k matrix, and B be a k n matrix. Then their product is: AB=[c ij ] cbababa
Matching Dimensions To multiply two matrices, the dimensions must match: 2 3 3 4 have to be equal 2 4 matrix 232334342424 8 dot products
Multiplicative Properties Note even if AB is defined, BA might not be. Example: If A is 3 4, B is 4 6, then AB is a 3 6 matrix, but BA is not defined. Even if both AB and BA are defined, they may not have the same dimensions. Even if they do, the result might not be equal. However, provided that the dimensions match, (AB)C = A(BC)
Chained Matrix Multiplication
Example
Ways of Parenthesizing a product of n matrices Let T(n) be the number of essentially distinct ways of parenthesizing a product of n matrices. The values of T(n) are known as Catalan numbers. Here are few values of T(n): n … 10 … 15 T(n) … 4862 … It can be shown that T(n) = Ω(2 2n /n 2 )
Identity Matrix The identity matrix is a square matrix with all 1’s along the diagonal and 0’s elsewhere. Example: For an m n matrix A, I m A = A I n ( m m) (m n) = (m n) (n n)
Inverse Matrix Let A and B be n n matrices. If AB=BA=I n then B is called the inverse of A, denoted B=A -1. Not all square matrices are invertible.
Symmetric Matrix If matrix A is such that A = A T then it is called a symmetric matrix. For example: Note also that I n is symmetric. Note, for A to be symmetric, is has to be square. Note also that I n is trivially symmetric.
Vectors An m element column vectorA q element row vector Transpose the column Transpose the row
Vectors A 1xN or Nx1 matrix 1xN is called a row vector Nx1 is called a column vector N is the dimension of the vector Vectors can be drawn as arrows and so have a direction and a magnitude. Magnitude:
Drawing Vectors x y a = (8,5) 8 5
Unit Vectors Magnitude is 1 A normalized vector is a unit vector that has be obtained by divided each dimension of a vector by its magnitude. It has the same direction as the original vector. Important because something direction is all that is important – magnitude is not needed… x a = (8,5) 8 5 y|a| = sqrt( ) =~ 9.4 Normalized a, a’ = (8/9.4, 5/9.4) = (.85,.53) a’ = (.85,.53)
Geometry of Vectors x y (a, b) a b If m is magnitude: a = m. cos, b = m. sin For unit vectors: a = cos, b = sin = tan -1 (b/a)
Addition - preserves direction and magnitude. - application: robot position translations - tip to tail method: x y v u u + v
Subtraction - application: can represent robot position error vector - u – v, a vector originating in v and ending in u x y v u u - v
Multiplication with a scalar - can change magnitude and direction (if multiplied with a negative number. x y v u ½ v -u
Cross Product Produces a vector perpendicular (normal) to the plane created by the 2 vectors. u x v v u
Cross product Direction is determined by the right hand rule Put hand on first vector (left side of x) and curl fingers towards second vector. Magnitude of u x v is |u|. |v|. sin(theta) where theta is the angle between u and v So, cross product produces a vector
Dot product Length of the projection of one vector onto a another. u. v Dot product is |u|. |v|. cos(theta) where theta is the angle between u and v So, dot product produces a scalar Note: is u and v and unit vectors, the dot product is simply: cos(theta) u v cos (theta) theta
Dot and cross products Dot product from unit vectors: As angle approaches 0, dot product approaches 1 As angle approaches 90, dot product approaches 0 Cross product from unit vectors: As angle approaches 0, dot product approaches 0 As angle approaches 90, dot product approaches 1
Finally…. Perpendicular vectors (dot product = 0) are called orthogonal vectors. Orthogonal unit vectors are called orthonormal vectors. Think: what do you need to represent a 3D coordinate system…? Three orthonormal vectors: X, Y, and Z….