Matrix Arithmetic. (Multidimensional Math) Institute for Advanced Analytics. Shaina Race, PhD

Similar documents
Chapter 2. Matrix Arithmetic. Chapter 2

Elementary maths for GMT

Image Registration Lecture 2: Vectors and Matrices

Matrix operations Linear Algebra with Computer Science Application

7.6 The Inverse of a Square Matrix

Matrix Algebra. Learning Objectives. Size of Matrix

Linear Algebra V = T = ( 4 3 ).

M. Matrices and Linear Algebra

We could express the left side as a sum of vectors and obtain the Vector Form of a Linear System: a 12 a x n. a m2

Knowledge Discovery and Data Mining 1 (VO) ( )

Review of Basic Concepts in Linear Algebra

Section 12.4 Algebra of Matrices

ICS 6N Computational Linear Algebra Matrix Algebra

[ Here 21 is the dot product of (3, 1, 2, 5) with (2, 3, 1, 2), and 31 is the dot product of

MATRICES. a m,1 a m,n A =

3.4 Elementary Matrices and Matrix Inverse

LS.1 Review of Linear Algebra

Chapter 2 Notes, Linear Algebra 5e Lay

MATH 2331 Linear Algebra. Section 2.1 Matrix Operations. Definition: A : m n, B : n p. Example: Compute AB, if possible.

18.02 Multivariable Calculus Fall 2007

Matrix Algebra. Matrix Algebra. Chapter 8 - S&B

A FIRST COURSE IN LINEAR ALGEBRA. An Open Text by Ken Kuttler. Matrix Arithmetic

Math 240 Calculus III

Basic Linear Algebra in MATLAB

A primer on matrices

Multiplying matrices by diagonal matrices is faster than usual matrix multiplication.

Basic Concepts in Linear Algebra

MAT 1332: CALCULUS FOR LIFE SCIENCES. Contents. 1. Review: Linear Algebra II Vectors and matrices Definition. 1.2.

Two matrices of the same size are added by adding their corresponding entries =.

Name Solutions Linear Algebra; Test 3. Throughout the test simplify all answers except where stated otherwise.

MATRICES AND MATRIX OPERATIONS

Linear Algebra. The analysis of many models in the social sciences reduces to the study of systems of equations.

Matrix Arithmetic. a 11 a. A + B = + a m1 a mn. + b. a 11 + b 11 a 1n + b 1n = a m1. b m1 b mn. and scalar multiplication for matrices via.

Math 360 Linear Algebra Fall Class Notes. a a a a a a. a a a

Chapter 3: Theory Review: Solutions Math 308 F Spring 2015

Math 3191 Applied Linear Algebra

Math Linear Algebra Final Exam Review Sheet

Lecture 3: Matrix and Matrix Operations

MAC Module 2 Systems of Linear Equations and Matrices II. Learning Objectives. Upon completing this module, you should be able to :

Matrix & Linear Algebra

Linear Algebra review Powers of a diagonalizable matrix Spectral decomposition

1111: Linear Algebra I

Lectures on Linear Algebra for IT

n n matrices The system of m linear equations in n variables x 1, x 2,..., x n can be written as a matrix equation by Ax = b, or in full

Introduction to Matrix Algebra

1 Matrices and matrix algebra

Linear Algebra Review. Fei-Fei Li

Linear Algebra. Min Yan

Matrices. Chapter Definitions and Notations

7.5 Operations with Matrices. Copyright Cengage Learning. All rights reserved.

Matrices and Linear Algebra

DM559 Linear and Integer Programming. Lecture 3 Matrix Operations. Marco Chiarandini

Think about systems of linear equations, their solutions, and how they might be represented with matrices.

v = ( 2)

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 1 x 2. x n 8 (4) 3 4 2

3 Fields, Elementary Matrices and Calculating Inverses

MATH2210 Notebook 2 Spring 2018

CSL361 Problem set 4: Basic linear algebra

A primer on matrices

x + 2y + 3z = 8 x + 3y = 7 x + 2z = 3

Math Bootcamp An p-dimensional vector is p numbers put together. Written as. x 1 x =. x p

Linear Algebra. Linear Equations and Matrices. Copyright 2005, W.R. Winfrey

A matrix is a rectangular array of. objects arranged in rows and columns. The objects are called the entries. is called the size of the matrix, and

Review of matrices. Let m, n IN. A rectangle of numbers written like A =

Elementary Linear Algebra

Chapter 4 - MATRIX ALGEBRA. ... a 2j... a 2n. a i1 a i2... a ij... a in

Things we can already do with matrices. Unit II - Matrix arithmetic. Defining the matrix product. Things that fail in matrix arithmetic

A matrix is a rectangular array of. objects arranged in rows and columns. The objects are called the entries. is called the size of the matrix, and

MATH.2720 Introduction to Programming with MATLAB Vector and Matrix Algebra

Chapter 2. Ma 322 Fall Ma 322. Sept 23-27

a11 a A = : a 21 a 22

Matrix Arithmetic. j=1

What is A + B? What is A B? What is AB? What is BA? What is A 2? and B = QUESTION 2. What is the reduced row echelon matrix of A =

Matrix Operations: Determinant

Linear Algebra Review. Fei-Fei Li

10. Linear Systems of ODEs, Matrix multiplication, superposition principle (parts of sections )

Introduction to Determinants

Linear Algebra Homework and Study Guide

POLI270 - Linear Algebra

Linear Algebra Practice Problems

Matrix Multiplication

Arrays: Vectors and Matrices

Linear Algebra and Matrix Inversion

Chapter 5. Linear Algebra. A linear (algebraic) equation in. unknowns, x 1, x 2,..., x n, is. an equation of the form

Matrices. 1 a a2 1 b b 2 1 c c π

7 Matrix Operations. 7.0 Matrix Multiplication + 3 = 3 = 4

Matrix Algebra 2.1 MATRIX OPERATIONS Pearson Education, Inc.

ME751 Advanced Computational Multibody Dynamics

Roberto s Notes on Linear Algebra Chapter 4: Matrix Algebra Section 4. Matrix products

Matrices Gaussian elimination Determinants. Graphics 2009/2010, period 1. Lecture 4: matrices

Foundations of Computer Vision

Numerical Analysis Lecture Notes

Linear Algebra (Review) Volker Tresp 2017

Matrix Operations. Linear Combination Vector Algebra Angle Between Vectors Projections and Reflections Equality of matrices, Augmented Matrix

Inverses and Elementary Matrices

Kevin James. MTHSC 3110 Section 2.2 Inverses of Matrices

Linear Algebra: Lecture Notes. Dr Rachel Quinlan School of Mathematics, Statistics and Applied Mathematics NUI Galway

Linear Algebra Review

Elementary Row Operations on Matrices

Next topics: Solving systems of linear equations

Transcription:

Matrix Arithmetic Multidimensional Math) Shaina Race, PhD Institute for Advanced Analytics.

TABLE OF CONTENTS Element-wise Operations Linear Combinations of Matrices and Vectors. Vector Multiplication Inner products and Matrix-Vector Multiplication Matrix Multiplication Inner product and linear combination viewpoint Vector Multiplication The Outer Product

Matrix Addition/Subtraction Two matrices/vectors can be added/subtracted if and only if they have the same size Then simply add/subtract corresponding elements

Matrix Addition/Subtraction + + + + A + ij B ij = + A + B) ij + + + +!## "## $!## " $!## "## $ ## A B A+B + + + + + A + B) ij = A ij + B ij Element-wise)

Example: Matrix Addition/Subtraction

Scalar Multiplication α! ## "## $ = α α α α αααα αααα α αα!## "## $ M αm αm) ij = αm ij Element-wise)

Geometric Look Vector addition and scalar multiplication

Points < > Vectors Vectors have both direction and magnitude a a = 1 2 Direction arrow points from origin to the coordinate point Magnitude is the length of that arrow #pythagoras

Scalar Multiplication Geometrically) a 2a -0.5a

Vector Addition Geometrically) b a a b a+b addition is still commutative

Example: Centering the data x 2 x 1 Average/Mean Centroid) x 1, x 2 )

Example: Centering the data x 2 x 1

Example: Centering the data x 2 x 1 New mean is the origin 0,0)

Linear Combinations

Linear Combinations A linear combination of vectors is a just weighted sum: α 1 v 1 + α 2 v 2 + + α p v p Scalar Coefficients i Vectors v i

Elementary Linear Combinations The simplest linear combination might involve columns of the identity matrix elementary vectors): Picture this linear combination as a breakdown into parts where the parts give directions along the 3 coordinate axes.

Linear Combinations Geometrically) -3b a a-3b

Linear Combinations Geometrically) axis 3) axis 1) axis 2)

Example: Linear Combination of Matrices

TABLE OF CONTENTS Element-wise Operations Linear Combinations of Matrices and Vectors. Vector Multiplication Inner products and Matrix-Vector Multiplication Matrix Multiplication Inner product and linear combination viewpoint Vector Multiplication The Outer Product

Notation: Column vs. Row Vectors Throughout this course, unless otherwise specified, all vectors are assumed to be columns. Simplifies notation because if x is a column vector: then we can automatically assume that x T is a row vector: x = x 1 x 2! x n x T = x 1 x 2 x n )

Vector Inner Product The vector inner product is the multiplication of a row vector times a column vector. It is known across broader sciences as the dot product. The result of this product is a scalar. =

Inner Product row x column)!## "## $ a T! ## "## $ b 1 2 3 4 5 6 = a T b = n a i b i i=1

Inner Product row x column) 1 2 3 4 5 6 * * * * * * + + + + + = a and b must have the same number of elements.

Examples: Inner Product

Examples: Inner Product

Check your Understanding

Check your Understanding SOLUTION

Matrix-Vector Multiplication Inner Product View I-P View)

Matrix-Vector Multiplication I-P view) 1 2 3

Matrix-Vector Multiplication I-P view) 1 2 3 Sizes must match up!

Matrix-Vector Multiplication I-P view) 1 2 3

Matrix-Vector Multiplication I-P view) 1 2 3

Matrix-Vector Multiplication I-P view) =

Example: Matrix-Vector Products

Matrix-Vector Multiplication Linear Combination View L-C View)

Matrix-Vector Multiplication L-C view) 1 2 3

Matrix-Vector Multiplication L-C view) 1 2 + 3 + =

Example: Linear Combination View 2 1 5 3 4 1 3 2

Example: Linear Combination View = 2 1 5 3 + 2 3 4 1

TABLE OF CONTENTS Element-wise Operations Linear Combinations of Matrices and Vectors. Vector Multiplication Inner products and Matrix-Vector Multiplication Matrix Multiplication Inner product and linear combination viewpoint Vector Multiplication The Outer Product

Matrix-Matrix Multiplication Matrix multiplication is NOT commutative. AB BA Matrix multiplication is only defined for dimensioncompatible matrices

Matrix-Matrix Multiplication I-P View) If A and B are dimension compatible, then we compute the product AB by multiplying every row of A by every column of B inner products). The i,j) th entry of the product AB is the i th row of A multiplied by the j th column of B

Matrix-Matrix Multiplication I-P View) A and B are dimension compatible for the product AB if the number of columns in A is! ## " $ equal to the number of rows in B 0 A S 1 2 3 ##! " 6 5 4 9 8 7 ##!## " $ = 0 A S S 1 2 3 6 5 4 9 8 7 3 4 7 ## ## $ A B AB) 4 x 3 3 x 4 4 x 4

1 2 3 6 5 4 9 8 7 0 A S = 1 2 3 6 5 4 9 8 7 0 A S 3 4 7 S AB) ij = A i! B! j A 2! AB) 23 B!3 Matrix-Matrix Multiplication I-P View)

Example: Matrix-Matrix Multiplication

Check Your Understanding

Check your Understanding SOLUTION

Check Your Understanding

Check your Understanding SOLUTION

NOT Commutative Very important to remember that Matrix multiplication is NOT commutative! As we see in previous exercise, common to be able to compute product AB when the reverse product, BA, is not even defined. Even when both products are possible, almost never the case that AB = BA.

Diagonal Scaling Multiplication by a diagonal matrix

Multiplication by a diagonal matrix The net effect is that the rows of A are scaled by the corresponding diagonal element of D

Multiplication by a diagonal matrix Rather than computing DA, what if we instead put the diagonal matrix on the right hand side and compute AD? AD = Exercise)

Matrix-Matrix Multiplication As a Collection of Linear Combinations L-C View)

Matrix-Matrix Multiplication L-C View) Just a collection of matrix-vector products linear combinations) with different coefficients. Each linear combination involves the same set of vectors the green columns) with different coefficients the purple columns).

Matrix-Matrix Multiplication L-C View) 0 A S 1 2 3 6 5 4 9 8 7 = 0 A S S 1 2 3 6 5 4 9 8 7 3 4 7

Matrix-Matrix Multiplication L-C View) 1 2 3 6 5 4 9 8 7 = 1 2 3 6 5 4 9 8 7 3 4 7 0 A S = 0 A S S

Matrix-Matrix Multiplication L-C View) 1 2 3 6 5 4 9 8 7 0 A S = = 1 2 3 6 5 4 9 8 7 0 A S 3 4 7 S + + i=1 n a 11

Matrix-Matrix Multiplication L-C View) 6 5 + 4 0 A S 1 2 3 9 8 7 = = + 0 A S S 6 5 4 4 1 2 3 3 9 8 7 7

Matrix-Matrix Multiplication L-C View) 9 8 + 7 0 A S 1 2 3 6 5 4 = = + 0 A S S 9 8 7 7 1 2 3 6 5 4 3 4

Matrix-Matrix Multiplication L-C View) Just a collection of matrix-vector products linear combinations) with different coefficients. Each linear combination involves the same set of vectors the green columns) with different coefficients the purple columns). This has important implications!

TABLE OF CONTENTS Element-wise Operations Linear Combinations of Matrices and Vectors. Vector Multiplication Inner products and Matrix-Vector Multiplication Matrix Multiplication Inner product and linear combination viewpoint Vector Multiplication The Outer Product

Vector Outer Product The vector outer product is the multiplication of a column vector times a row vector. For any column/row this product is possible The result of this product is a matrix! 1xn) = mx1) mxn)

Outer Product column x row)! ## "## $ b 1 2 3 4 5!## "## $ a T =!## "## $ ba T

Outer Product column x row)! ## "## $ b!## "## $ a T =!## "## $ ba T

Outer Product column x row)! ## "## $ b!## "## $ a T =!## "## $ ba T

Example: Outer Product

Outer Product has rank 1 From the previous example, you can see that the rows of an outer product are necessarily multiples of each other. =! ## "## $ a T!## "## $ b!## "## $ ba T

Matrix-Matrix Multiplication As a Sum of Outer Products O-P View)

Matrix-Matrix Multiplication O-P View) We can write the product AB as a sum of outer products of columns of A mxn) and rows of B nxp) n AB = A!i B i! i=1 This view decomposes the product AB into the sum of n matrices, each of which has rank 1 discussed later).

Challenge Puzzle Suppose we have 1,000 individuals that have been divided into 5 different groups each year for 20 years. We need to make a 1000x1000 matrix C where C ij = # times person i grouped with person j The data currently has 1000 rows and 5x20 = 100 binary columns indicating whether each individual was a member of each group ylgk: yearlgroupk): y1g1, y1g2, y1g3, y1g4, y1g5, y2g1, y20g5) Can we use what we ve just learned to help us here?

Special Cases of Matrix Multiplication The Identity and the Inverse

The Identity Matrix The identity matrix, I, is to matrices what the number 1 is to scalars. It is the multiplicative identity. I 4 = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 For any matrix or vector) A, multiplying A by the appropriately sized) identity matrix on either side does not change A: AI = IA = A

The Matrix Inverse For certain square matrices, A, an inverse matrix written A -1, exists such that: A MATRIX MUST BE SQUARE TO HAVE AN INVERSE. NOT ALL SQUARE MATRICES HAVE AN INVERSE Only full-rank, square matrices are invertible. more on this later) For now, understand that the inverse matrix serves like the multiplicative inverse in scalar algebra: Multiplying a matrix by its inverse if it exists) yields the multiplicative identity, I

The Matrix Inverse A square matrix which has an inverse is equivalently called: Non-singular Invertible Full Rank

Don t Cancel That!!

Cancellation implies inversion Canceling numbers in scalar algebra: Canceling matrices in linear algebra: Inverses can help solve an equation WHEN THEY EXIST!