Download engineering 212 98a

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Chapter 11
Matrix Inverse
and Condition
Matrix Inverse
How do we get inverse [A] 1?
One way is through LU decomposition and backsubstitution
Solve [A]{xi} = {bi} with
1 
0 
 
b

 1   ,
0 
0
0 
1 
 
b

 2   ,
0 
0
0 
0 
 
b

 3   ,
1 
0
0 
0 
 
b

 4  
0 
1 
Sequentially!
Put together x’s to get [A]-1 ={x1,x2,x3,x4}
Matrix Inverse
[A] [A] 1 = [ I ]
Use LU factorization to find [X] = [A]1
LU X   I 

 LY   I 
 

 U X   Y 
LU decomposition:
[A] = [L][U]
Forward substitution: [L][Y] = [ I ]
Back substitution:
[U][X] = [Y]
Matrix Inverse
Forward Substitution [L][Y] = [ I ]
 l 11
l
 21
 l 31

 l 41
 l 11
l
 21
 l 31

 l 41
0
l 22
l 32
l 42
0
l 22
l 32
l 42
0   y 11  1
0
0   y 21  0 
    ;
l 33
0   y 31  0 

l 43 l 44   y 41  0 
 l 11
l
 21
 l 31

 l 41
0   y 13  0 
0
0   y 23  0 
    ;
l 33
0   y 33   1
   
l 43 l 44   y 43  0 
 l 11
l
 21
 l 31

 l 41
0
0
0
l 22
l 32
l 42
0
l 22
l 32
l 42
0   y 12  0 
0
0   y 22  1
  
l 33
0   y 32  0 

l 43 l 44   y 42  0 
0
0   y 14  0 
0
0   y 24  0 
  
l 33
0   y 34  0 
   
l 43 l 44   y 44  1
0
Matrix Inverse
back Substitution [U][X] = [ Y ]
 u11 u12 u13
 0 u
u 23
22

 0
0 u 33

0
0
 0
u14   x 11   y 11 
u 24   x 21   y 21 
    ;
u 34   x 31   y 31 

u44   x 41   y 41 
 u11 u12 u13 u14   x 12   y 12 
 0 u
 x   y 
u
u
 22 
22
23
24   22 


   
 0
0 u 33 u 34   x 32   y 32 

   
0
0
0
u
44   x 42 

 y 42 
 u11 u12 u13
 0 u
u 23
22

 0
0 u 33

0
0
 0
u14   x 13   y 13 
u 24   x 23   y 23 
    ;

u 34  x 33   y 33 
   
u44   x 43   y 43 
 u11 u12 u13
 0 u
u 23
22

 0
0 u 33

0
0
 0
 A
1
u14   x 14   y 14 
u 24   x 24   y 24 
  

u 34  x 34   y 34 
   
u44   x 44   y 44 
 x1 , x2  , x3 , x4 
function x
% Function
%
L -->
%
U -->
%
B -->
= LU_Solve_Gen(L, U, B)
to solve the equation L U x = B
Lower triangular matrix (1's on diagonal)
Upper triangular matrix
Right-hand-side matrix
[n n2] = size(L); [m1 m] = size(B);
% Solve L d = B using forward substitution
for j = 1 : m
d(1,j) = B(1,j);
for i = 2 : n
d(i,j) = B(i,j) - L(i, 1:i-1) * d(1:i-1,j);
end
end
% SOlve U x = d using back substitution
for j = 1 : m
x(n,j) = d(n,j) / U(n,n);
for i = n-1 : -1 : 1
x(i,j) = (d(i,j) - U(i,i+1:n) * x(i+1:n,j)) /
U(i,i);
end
end
Example: Matrix Inverse
» A=[-19 20 -6;-12 13 -3;30 -30 12]
» B=eye(3)
A =
B =
-19
-12
30
20
13
-30
-6
-3
12
1
0
0
0
1
0
0
0
1
» [L,U]=LU_factor(A);
» x=LU_solve_gen(L,U,B)
L =
x =
1.0000
0.6316
-1.5789
0
1.0000
4.2857
0
0
1.0000
-10.0000
-8.0000
5.0000
3.0000
2.5000
-1.1667
» inv(A)
U =
-19.0000
0
0
11.0000
9.0000
-5.0000
20.0000
0.3684
0.0000
-6.0000
0.7895
-0.8571
ans =
11.0000
9.0000
-5.0000
MATLAB function
-10.0000
-8.0000
5.0000
3.0000
2.5000
-1.1667
Error Analysis and System Condition
 The matrix inverse provides a means to
discern whether a system is ill-conditioned
1. Normalize rows of matrix [A] to 1. If the
elements of [A]1 are >> 1, the matrix is likely
ill-conditioned
2. If [A]1[A] is not close to [ I ], the matrix is
probably ill-conditioned
3. If ([A]1)1 is not close to [A], the matrix is illconditioned
Vector and Matrix Norms
 Norm: provide a measure of the size or “length” of multicomponent mathematical entities such as vectors and matrices
Euclidean norm of
a vector (3D space)
F   a b c 
F
e
 a2  b2  c 2
 X   x1 x 2 x 3  xn 
X
e

n
2
x
 i
i 1
Matrix Norm
For n  n matrix, the Frobenius norm
Frobenius norm provides a single value to quantify
the size of matrix [A]
Ae 
n
n
2
a
 ij
i 1 j 1
Other alternatives – p norms for vectors

p
   xi 
 i 1

n
X
p
1/ p
p = 2 : Euclidean norm
Vector and Matrix Norms
Vector norms ( p-norms)
p  1,
p  ,
n
X
X
1
  xi
Sum of absolute values
 max x i
Maximum-magnitude or
uniform-vector norm

i 1
1 i  n
Matrix norms
p  1,
p  ,
n
A 1  max  aij
1 j  n
i 1
n
A

 max  aij
1i  n
j 1
Column-sum norm
Row-sum norm
Matrix Condition Number
 Condition number defined in terms of matrix norms
Cond[ A]  A  A
1
1
 Cond[A] is great than or equal to 1
 Matrix A is ill-conditioned if Cond[A] >> 1
X
X
 Cond[ A]
A
A
Relative error of the norm
 If [A] has 107 rounding error and Cond[A] = 105, then the
solution [X] may be valid to only 102
Matrix Condition Evaluation
Hilbert matrix – notoriously ill-conditioned

1
1

2
[ A]   1
3

1

n
1
2
1
3
1
4

1
n1
1
3
1
4
1
5

1
n 2





1 
1

1

n 
2


1
2
 Normalization  1
n1 
3


[ A]  
1 
3
1

n 2 
4







1
n
1


2n  1
n1

1
3
2
4
3
5

n
n 2





Row-sum norm (last row has the largest sum)
A
n
n
n
 1


n1 n 2
2n  1
1 
n 
2 

n1 
3 
n 2 
 
n 

2n  1
Matrix Condition Evaluation
5  5 Hilbert matrix
1
1

[ A]   1

1
 1
1/ 5
2 / 3 2 / 4 2 / 5 2 / 6

3 / 4 3 / 5 3 / 6 3 /7

4 / 5 4 / 6 4 / 7 4 / 8
5 / 6 5 / 7 5 / 8 5 / 9 
1/ 2
1/ 3
1/ 4
[ A]1
25  150
350
 350
126 

  300
2400
 6300
6720  2520 


  1050  9450
26460  29400
11340 



1400
13440

39200
44800

17640


 630  6300
18900  22050
8820 
Condition number
A   1
A 1

5 5 5 5
    3.7282
6 7 8 9
  1400  13440   39200  44800   17640  116480
Cond[ A]  A   A  1

 ( 3.7282 )  ( 116480 )  434260.736
MATLAB Norms and Condition Numbers
>> A=[1 1/2 1/3 1/4 1/5; 1 2/3 2/4 2/5 2/6; 1 3/4 3/5 3/6 3/7;
1 4/5 4/6 4/7 4/8; 1 5/6 5/7 5/8 5/9];
>> Ainv = inv(A)
Ainv =
25
-150
350
-350
126
-300
2400
-6300
6720
-2520
1050
-9450
26460
-29400
11340
-1400
13440
-39200
44800
-17640
630
-6300
18900
-22050
8820
>> norm(A,inf)
ans =
3.7282
>> norm(Ainv,inf)
ans =
1.1648e+005
>> cond(A,inf)
ans =
4.3426e+005
>> norm(X,p)
>> cond(A,'fro')
p-norm
ans =
>> cond(X,p)
2.7944e+005
>> cond(A)
Frobenius norm
>>
Cond(A,’fro’)
ans =
2.7746e+005
Spectral norm
>> cond(A)
CVEN 302-501
Homework No. 7
 Chapter 10
 Prob. 10.4(20), 10.5(20) both using LU decomposition
(hand calculation only, hand partial pivoting if necessary),
Prob. 10.8 a)&b) (20).
 Chapter 11
 Prob. 11.2 (15), 11.3 a) & b) (20) (Hand Calculations)
 Prob. 11.6 (25) (Hand Calculations; Check your solutions
using MATLAB)
 Due Monday 10/13/08 at the beginning of the period
Related documents