LU method 1) factor (decompose) A into L and U 2) given b, determine d 3) using Ux=d and backsubstitution, solve for x Advantage: Once you have L and U, can use many different b’s
a bg d F 14 F 23 F 12 F 24 F 45 FHFH F 35 F 25 F V2 F V1
Assume weight of 100 is localized at node 2
Matrix inverse Square matrix A Inverse of A is A -1
How do we get inverse? One way is through LU decomposition and backsubstitution Solve Ax=b with, sequentually Put together x’s to get inverse
Example:
To get inverse, solve using different b’s
Now
Finally
So the inverse is Check
Matrix inverse is useful for determining condition number (ill conditioned) of matrix 1) Normalize rows of matrix to 1. If elements of A -1 are >> 1, probably ill conditioned 2) if A -1 A is not close to I, probably ill conditioned 3) if (A -1 ) -1 is not A, probably ill conditioned
A little more technical Norms - a way to measure “size” or “length” of a quantity for matrices, use matrix norm
Condition number comes from matrix norm If cond[A] is much bigger than 1, ill conditioned
Matrix inverse is time consuming to calculate A number of methods to avoid it I.e Gauss elimination instead of
Special matrices Banded matrices Tridiagonal matrices
Tridiagonal matrices important for time evolution of systems E.g traffic flow 30 nodes (stoplights) Traffic at node x i at next time (x i,t+1 ) depends on 1) # of cars at x i at time t (x i,t ) 2) # of cars at x i-1 at time t (x i-1,t ) 3) # of cars at x i+1 at time t (x i+1,t )
Some linear relationship or
Put all 30 equations together Solve to get # of cars, and repeat to see how traffic responds to boundary conditions
Thomas algorithm to solve tridiagonal matrices
Basically sets up an LU decomposition three parts 1) decomposition 2) forward substitution 3) backward substitution
1) decomposition loop from rows 2 to n a i = a i /b i-1 b i = b i -a i *c i-1 end loop 2) forward substitution loop from 2 to n r i = r i - a i *r i-1 end loop
3) back substitution x n = r n /b n loop from n-1 to 1 x i = (r i -c i *x i+1 )/b i end loop
Example First decompose T
loop from rows 2 to 5 a i = a i /b i-1 b i = b i -a i *c i-1 end loop
forward substitution loop from 2 to n r i = r i - a i *r i-1 end loop
back substitution x n = r n /b n loop from n-1 to 1 x i = (r i -c i *x i+1 )/b i end loop