review of linear algebra -...

27
Review of Linear Algebra Dr. Gerhard Roth COMP 4900D Winter 2012

Upload: others

Post on 15-Oct-2019

13 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Review of Linear Algebra

Dr. Gerhard Roth

COMP 4900D

Winter 2012

Page 2: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Linear Equations

A system of linear equations, e.g.

1114

242

21

21

xx

xx

can be written in matrix form:

1

2

114

42

2

1

x

x

or in general:

bAx

Page 3: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Vectors

nx

x

x

x2

1

5

3

2

xe.g.

The length or the norm of a vector is

22

2

2

1 nxxxx

38532 222 xe.g.

Page 4: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Vector Arithmetic

22

11

2

1

2

1

vu

vu

v

v

u

uvu

22

11

2

1

2

1

vu

vu

v

v

u

uvu

Vector addition

Vector subtraction

Multiplication by scalar

2

1

2

1

u

u

u

uu

Page 5: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Dot Product (inner product)

5

3

2

a

2

3

4

b

925)3(342

2

3

4

532

baba T

nn

T bababababa 2211

Page 6: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Matrix

A matrix is an m×n array of numbers.

ij

mnmm

n

n

a

aaa

aaa

aaa

A

21

22221

11211

Example:

111070

9314

4532

A

Page 7: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Matrix Arithmetic

Matrix addition

nmijijnmnm baBA

Matrix multiplication

pmpnnm CBA

n

k

kjikij bac1

Matrix transpose

ji

T aA

TTTBABA TTT

ABAB

Page 8: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Multiplication not commutative

BAAB

Matrix multiplication is not commutative

Example:

1119

2917

51

26

13

52

1017

3218

13

52

51

26

Page 9: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Symmetric Matrix

We say matrix A is symmetric if

AAT

Example:

54

42A

A symmetric matrix has to be a square matrix

Page 10: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Inverse of matrix

If A is a square matrix, the inverse of A, written A-1 satisfies:

IAA 1 IAA 1

Where I, the identity matrix, is a diagonal matrix with all 1’s

on the diagonal.

10

012I

100

010

001

3I

Page 11: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Trace of Matrix

The trace of a matrix:

n

i

iiaATr1

)(

Page 12: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Orthogonal Matrix

A matrix A is orthogonal if

IAAT 1 AATor

Example:

cossin

sincosA

Page 13: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Matrix Transformation (and projections)

A matrix-vector multiplication transforms one vector to another

11 mnnm bxA

26

16

41

7

3

24

13

52

Example:

Page 14: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Coordinate Rotation

y

x

y

x

r

r

r

r

cossin

sincos

'

'

Page 15: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Vectors and Points

Two points in a Cartesian coordinate system define a vector

P(x1,y1)

Q(x2,y2)

x

y v

12

12

yy

xxv

P(x1,y1)

Q(x2,y2)

x

y v

A point can also be represented as a vector, defined by the point

and the origin (0,0).

PQv

1

1

1

1

0

0

y

x

y

xP

2

2

2

2

0

0

y

x

y

xQ

or vPQ

Note: point and vector are different; vectors do not have positions

Page 16: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Least Squares

When m>n for an m-by-n matrix A, bAx has no solution.

In this case, we look for an approximate solution.

We look for vector such that x

2bAx

is as small as possible.

This is called the least squares solution.

Page 17: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Least Squares

Least squares solution of linear system of equations

bAx

bAAxA TT

AAT is square and symmetric

bAAAx TT 1)(

Normal equation:

2bxA

The Least Square solution

makes minimal.

Page 18: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Least Square Fitting of a Line

x

y

mm ydxc

ydxc

ydxc

22

11

mm y

y

y

d

c

x

x

x

2

1

2

1

1

1

1

The best solution c, d is the one that minimizes:

.)()( 22

11

22

mm dxcydxcyAxyE

Line equations:

yAx

Page 19: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Least Square Fitting - Example

x

y

P1=(-1,1), P2=(1,1), P3=(2,3)

Problem: find the line that best fit these three points:

Solution:

32

1

1

dc

dc

dc

3

1

1

21

11

11

d

c

bAAxA TT

6

5

62

23

d

c

or

is

The solution is and best line is 74

79 , dc yx 7

479

Page 20: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Homogeneous System

• m linear equations with n unknowns Ax = 0

• Assume that m >= n-1 and rank(A) = n-1

• Trivial solution is x = 0 but there are more

• If we have a given solution x, s.t. Ax = 0 then

c * x is also a solution since A(c* x) = 0

• Need to add a constraint on x, • Usually make x a unit vector

• Can prove that the solution of Ax = 0

satisfying this constraint is the eigenvector

corresponding to the only zero eigenvalue of

that matrix

1 x xT

AAT

Page 21: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Homogeneous System

• This solution can be computed using the

eigenvector or SVD routine • Find the zero eigenvalue (or the eigenvalue almost zero)

• Then the associated eigenvector is the solution x

• And any scalar times x is also a solution

Page 22: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Linear Independence

• A set of vectors is linear dependant if one of

the vectors can be expressed as a linear

combination of the other vectors.

• A set of vectors is linearly independent if

none of the vectors can be expressed as a

linear combination of the other vectors.

nnkkkkk vvvvv 111111

Page 23: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Eigenvalue and Eigenvector

We say that x is an eigenvector of a square matrix A if

xAx

is called eigenvalue and is called eigenvector.

The transformation defined by A changes only the

magnitude of the vector x

Example:

x

1

15

5

5

1

1

41

23

1

22

2

4

1

2

41

23and

5 and 2 are eigenvalues, and

1

1

1

2and are eigenvectors.

Page 24: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Properties of Eigen Vectors

• If 1, 2,…, q are distinct eigenvalues of a

matrix, then the corresponding eigenvectors

e1,e2,…,eq are linearly independent.

• A real, symmetric matrix has real eigenvalues

with eigenvectors that can be chosen to be

orthonormal.

Page 25: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

SVD: Singular Value Decomposition

TUDVA

An mn matrix A can be decomposed into:

U is mm, V is nn, both of them have orthogonal columns:

IUU T

D is an mn diagonal matrix.

IVV T

Example:

10

01

00

30

02

100

010

001

00

30

02

Page 26: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Singular Value Decomposition

•Any m by n matrix A can be written as product of three

matrices A = UDVT

•The columns of the m by m matrix U are mutually

orthogonal unit vectors, as are the columns of the n by

n matrix V

•The m by n matrix D is diagonal, and the diagonal

elements, are called the singular values

•It is the case that

•A matrix is non-singular if and only all of the singular

values are not zero

•The condition number of the matrix is

•If the condition number is large, then then matrix is

almost singular and is called ill-conditioned

021 n

i

n

1

Page 27: Review of Linear Algebra - people.scs.carleton.capeople.scs.carleton.ca/~roth/comp4900d-12/notes/lect2_linear_algebra...Vector subtraction Multiplication by scalar ... Matrix Arithmetic

Singular Value Decomposition

•The rank of a square matrix is the number of linearly

independent rows or columns

•For a square matrix (m = n) the number of non-zero

singular values equals the rank of the matrix

•If A is a square, non-singular matrix, it’s inverse can be

written as where

• The squares of the non zero singular values are the

non-zero eigenvalues of both the n by n matrix

and of the m by m matrix

•The columns of U are the eigenvectors of

•The columns of V are the eigenvectors of

TUVDA 11 TUDVA

AAT

TAATAA

AAT