LU method 1) factor (decompose) A into L and U 2) given b, determine d 3) using Ux=d and...

30
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
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    213
  • download

    0

Transcript of LU method 1) factor (decompose) A into L and U 2) given b, determine d 3) using Ux=d and...

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

1

4

2 3

5

a b g d

F14

F23F12

F24

F45

FH

F35F25

FV2FV1

Assume weight of 100 is localized at node 2

0

0

0

0

0

0

0

100

0

0

coscos

sinsin

coscos

sinsin

cos

sin

coscos

sinsin

cos

sin

453525

3525

452414

2414

3523

352

25242312

2524

1412

141

FFF

FF

FFF

FF

FF

FF

FFFF

FF

FFF

FF

V

H

V

0

0

0

0

0

0

0

100

0

0

1coscos

sinsin

1coscos

sinsin

cos1

sin1

coscos11

sinsin

cos11

sin1

45

35

25

24

23

14

12

2

1

F

F

F

F

F

F

F

F

F

F

V

H

V

Matrix inverse

Square matrix A

Inverse of A is A-1

IAA 1

How do we get inverse?

One way is through LU decomposition and backsubstitution

Solve Ax=b with , sequentually

1

0

0

,

0

1

0

,

0

0

1

bbb

Put together x’s to get inverse

Example:

333

321

234

A

12.475.0

0125.

001

0L

1200

5.225.10

234

U

To get inverse, solve using different b’s

0

0

1

12.475.0

0125.

001

0

3

2

1

d

d

d

bLd

8.102.475.0

25.0025.0

1

3321

221

1

dddd

ddd

d

8.1

25.0

1

1200

5.225.10

234

3

2

1

x

x

x

dUx

25.01234

1.025.05.225.1

15.08.112

1321

232

33

xxxx

xxx

xx

15.0

1.0

25.0

x

Now

0

1

0

12.475.0

0125.

001

0

3

2

1

d

d

d

bLd

2.4

1

0

d

2.4

1

0

1200

5.225.10

234

3

2

1

x

x

x

dUx

35.0

1.0

25.0

x

Finally

1

0

0

12.475.0

0125.

001

0

3

2

1

d

d

d

bLd

1

0

0

d

1

0

0

1200

5.225.10

234

3

2

1

x

x

x

dUx

12/1

6/1

12/1

x

So the inverse is

0833.035.015.0

1667.01.01.0

0833.025.025.0321

1 xxxA

Check

1

1

1

0833.035.015.0

1667.01.01.0

0833.025.025.0

333

321

234

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-1A 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

i j

ijaA 2

Condition number comes from matrix norm

1 AAACond

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

bAinvx *)(

Special matrices

Banded matrices

Tridiagonal matrices

nn

nnn

nnn

ba

cba

cba

cba

cba

cb

T

111

222

333

222

11

Tridiagonal matrices important for time evolution of systems

E.g traffic flow

30 nodes (stoplights)

Traffic at node xi at next time (xi,t+1) depends on

1) # of cars at xi at time t (xi,t) 2) # of cars at xi-1 at time t (xi-1,t) 3) # of cars at xi+1 at time t (xi+1,t)

Some linear relationship

1,,1,,1 titiitiitii xxcxbxa

or

1,

,1

,

,1

ti

ti

ti

ti

iii x

x

x

x

cba

1,30

1.2

1,1

,30

.2

,1

3030

292929

282828

333

222

11

*

t

t

t

t

t

t

x

x

x

x

x

x

ba

cba

cba

cba

cba

cb

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

rTx

nnnn

nnn

nnn

r

r

r

x

x

x

ba

cba

cba

cba

cba

cb

2

1

2

1

111

222

333

222

11

*

Basically sets up an LU decomposition

three parts

1) decomposition

2) forward substitution

3) backward substitution

1) decompositionloop from rows 2 to n

ai = ai/bi-1

bi = bi-ai*ci-1

end loop

2) forward substitutionloop from 2 to n

ri = ri - ai*ri-1

end loop

3) back substitutionxn = rn/bn

loop from n-1 to 1xi = (ri-ci*xi+1)/bi

end loop

Example

16

55

13

49

9

21

543

311

1214

25

5

4

3

2

1

x

x

x

x

x

First decompose T

loop from rows 2 to 5ai = ai/bi-1

bi = bi-ai*ci-1

end loop

21

543

311

1214

25

0515.11*0515.01

0515.0)4.19/(1

5/2 192*)5/4(21

5/4

3

3

2

2

b

a

b

a

0968.32194.0

55588.48529.2

30515.10515.0

14.198.0

25

forward substitutionloop from 2 to n

ri = ri - ai*ri-1

end loop

16

55

13

49

9

r

0968.32194.0

55588.48529.2

30515.10515.0

14.198.0

25

T

1546.158.41*0515.013

8.419*8.049

3

2

r

r

5806.18

7647.11

1546.15

8.41

9

r

back substitutionxn = rn/bn

loop from n-1 to 1xi = (ri-ci*xi+1)/bi

end loop

0968.32194.0

55588.48529.2

30515.10515.0

14.198.0

25

T

5806.18

7647.11

1546.15

8.41

9

r

15/)2*29(

24.19/)3*18.41(

30515.1/)4*)3(1546.15(

45588.4/)6*)5(7647.11(

60968.3/5806.18

1

2

3

4

5

x

x

x

x

x

6

4

3

2

1

x