Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical...

17
Matrix Inverse and Condition Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University Reference: 1. Applied Numerical Methods with MATLAB for Engineers, Chapter 11 & Teaching material

Transcript of Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical...

Page 1: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Matrix Inverse and Condition

Berlin ChenDepartment of Computer Science & Information Engineering

National Taiwan Normal University

Reference:1. Applied Numerical Methods with MATLAB for Engineers, Chapter 11 & Teaching material

Page 2: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Chapter Objectives

• Knowing how to determine the matrix inverse in an efficient manner based on LU factorization

• Understanding how the matrix inverse can be used to assess stimulus-response characteristics of engineering systems

• Understanding the meaning of matrix and vector norms and how they are computed

• Knowing how to use norms to compute the matrix condition number

• Understanding how the magnitude of the condition number can be used to estimate the precision of solutions of linear algebraic equations

NM – Berlin Chen 2

Page 3: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Matrix Inverse (1/4)

• Recall that if a matrix [A] is square, there would be another matrix [A]-1, called the inverse of [A], for which[A][A]-1=[A]-1[A]=[I] ([I]: identity matrix)

• The inverse can be computed in a column by column fashion by generating solutions with unit vectors as the right-hand-side constants:– A three-variable system

NM – Berlin Chen 3

A x1 100

A x2

010

A x3

001

A 1 x1 x2 x3

Page 4: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Matrix Inverse (2/4)

• Recall that LU factorization can be used to efficiently evaluate a system for multiple right-hand-side vectors -thus, it is ideal for evaluating the multiple unit vectors needed to compute the inverse

NM – Berlin Chen 4

1. To solve [A]{x}={b}, first decompose [A] toget [L][U]{x}={b} (let {d}=[U]{x}={d})

2. Set up and solve [L]{d}={b}, where {d} can be found using forward substitution

3. Set up and solve [U]{x}={d}, where {x} can be found using backward substitution

Page 5: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Matrix Inverse (3/4)

NM – Berlin Chen 5

Example 11.1

Page 6: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Matrix Inverse (4/4)

NM – Berlin Chen 6

Example 11.1

Page 7: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Stimulus-Response Computations (1/3)

• Many systems can be modeled as a linear combination of equations, and thus written as a matrix equation:

• The system response can thus be found using the matrix inverse

NM – Berlin Chen 7

Interactions response stimuli

Page 8: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Stimulus-Response Computations (2/3)

• Example: Three Bungee Jumpers

NM – Berlin Chen 8

compute the displacement of each of the jumpers when 

coming to the equilibrium positions

[A]{x} {b}

stimuli/forcing function

interactions response

Page 9: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Stimulus-Response Computations (3/3)• The matrix inverse provides a powerful technique for

understanding the interrelationships of component parts of complicated systems

NM – Berlin Chen 9

][

where

or}{][}{

}{}]{[

133

132

131

122

122

121

113

112

111

1

31

3321

3211

313

31

2321

2211

212

31

1321

1211

111

1

aaaaaaaaa

A

bababax

bababax

bababax

bAx

bxA

Each of its element aij‐1 represents the response of 

a single part of the system to a unit stimulusof any other part of the system.

Element  aij‐1 of the matrix inverse represents, 

for example, the force in member i due to a unit external force at node j.

Page 10: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Ill-Conditioned Systems

• Three direct methods for discerning whether systems are ill-conditioned1. Scale the matrix of coefficients [A] so that the largest element

in each row is 1. Invert the scaled matrix and if there are elements of [A]-1 that are several orders of magnitude greater than one, it is likely that the system is ill-conditioned

2. Multiply the inverse [A]-1 by the original coefficient matrix [A] and assess whether the result is close to the identity matrix [I], If not, it indicates ill-conditioning

3. Invert the inverted matrix and assess whether the result is sufficiently close to the original coefficient matrix. If not, it indicates ill-conditioning

• Can we obtain a single number serving as an indicator of ill‐conditioned systems?

NM – Berlin Chen 10

Page 11: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Vector and Matrix Norms

• A norm is a real-valued function that provides a measure of the size or “length” of multi-component mathematical entities such as vectors and matrices

• Vector norms and matrix norms may be computed differently

NM – Berlin Chen 11

Page 12: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Vector Norms

• For a vector {X} of size n, the p-norm is:

• Important examples of vector p-norms include:

NM – Berlin Chen 12

X p xip

i1

n

1/ p

p 1:sum of the absolute values X 1 xii1

n

p 2 :Euclidian norm (length) X 2 X e xi2

i1

n

p :maximum magnitude X

1inmax xi

Page 13: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Matrix Norms

• Common matrix norms for a matrix [A] include:

• Note: max is the largest eigenvalue of [A]T[A]

NM – Berlin Chen 13

column - sum norm A 1 1 jnmax aij

i1

n

Frobenius norm A f aij2

j1

n

i1

n

row - sum norm A

1inmax aij

j1

n

spectral norm (2 norm) A

2 max 1/2

Page 14: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

Matrix Condition Number

• The matrix condition number Cond[A] is obtained by calculating Cond[A]=||A||·||A-1||

• In can be shown that:

• The relative error of the norm of the computed solution can be as large as the relative error of the norm of the coefficients of [A] multiplied by the condition number

• If the coefficients of [A] are known to t digit precision (rounding errors are on the order of 10-t), the solution [X] may be valid to only t-log10(Cond[A]) digits– If the conditional number is much greater than 1, it is suggested

that the system is prone to being ill-conditionedNM – Berlin Chen 14

XX

Cond A AA

Ralston & Rabinowitz, 1978

}{}]{[ that given bxA

Page 15: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

MATLAB Commands (1/3)

• MATLAB has built-in functions to compute both norms and condition numbers:– norm(X,p)

• Compute the p norm of vector X, where p can be any number, inf, or ‘fro’ (for the Euclidean norm)

– norm(A,p)• Compute a norm of matrix A, where p can be 1, 2, inf, or ‘fro’ (for the Frobenius norm)

– cond(X,p) or cond(A,p)• Calculate the condition number of vector X or matrix A using

the norm specified by p

NM – Berlin Chen 15

Page 16: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

MATLAB Commands (2/3)

NM – Berlin Chen 16

Example 11.4

n

jij

niaA

11max

Page 17: Matrix Inverse and Condition - 國立臺灣師範大學berlin.csie.ntnu.edu.tw/Courses/Numerical Methods/Lectures2012S/NM2012S... · Matrix Inverse and Condition Berlin Chen Department

MATLAB Commands (3/3)

NM – Berlin Chen 17

Example 11.4

2/1max2

A

n

i

n

jijfaA

1 1

2