Special Matrices

18
Special Matrices Banded matrices Solutions to problems that depend on their neighbours eg 1D T i = f(T i-1 ,T i+1 ) 2D T i,j = f(T i-1,j ,T i+1,j ,T i,j -1 ,T i,j +1 ) ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

description

Special Matrices. Banded matrices Solutions to problems that depend on their neighbours eg 1D T i = f(T i-1 ,T i+1 ) 2D T i,j = f(T i-1,j ,T i+1,j ,T i,j -1 ,T i,j +1 ). Tridiagonal Matrices. Tridiagonal Matrix Algorithm. TDMA procedure. Iterative Methods. - PowerPoint PPT Presentation

Transcript of Special Matrices

Page 1: Special Matrices

Special Matrices

Banded matrices

Solutions to problems that depend

on their neighbours

• eg 1D Ti = f(Ti-1,Ti+1)

• 2D Ti,j = f(Ti-1,j,Ti+1,j ,Ti,j -1,Ti,j +1)

~~

~~~

~~~

~~~

~~~

~~

Page 2: Special Matrices

Tridiagonal Matrices

iiiii

ii

iiiiiii

xgx

xx

rxgxfxe

1

1

11

onscontributi and the combine

:idea

:form General

n

n

n

n

nn

nnn

r

r

r

r

r

x

x

x

x

x

fe

gfe

gfe

gfe

gf

1

3

2

1

1

3

2

1

111

333

222

11

n

n

n

n

n

nn

x

x

x

x

x

g

g

g

g

1

3

2

1

1

3

2

1

11

33

22

11

Page 3: Special Matrices

Tridiagonal Matrix Algorithm

1

1

1

1

1

1

11

1

iii

iiiiii

i

i

iiiii

ii

iiiiiii

xgx

rxgxfe

x

x

i-

xgxi

xx

rxgxfxe

form original into substitute

for rearrange

: for

: for

onscontributi and the combine :idea

:form General

n

n

n

n

nn

nnn

r

r

r

r

r

x

x

x

x

x

fe

gfe

gfe

gfe

gf

1

3

2

1

1

3

2

1

111

333

222

11

n

n

n

n

n

nn

x

x

x

x

x

g

g

g

g

1

3

2

1

1

3

2

1

11

33

22

11

Page 4: Special Matrices

TDMA procedure

1111

3322

12111

1

nnnnn

nnn

iiiii

xgx

x

rxgxf

xgx

line last Second

line Last

onSubstituti Back

then... and then and get canly Subsequent

line First

Page 5: Special Matrices

Iterative Methods

• Often much better on sparse matrices than direct solvers• Idea:

– guess {x}– use in an approximation of [A] {x}= {b} to get new values of {x}– repeat until {x} is not changing much

• Pros:– much less effort / faster– less problems with roundoff

Page 6: Special Matrices

Point-Jacobi

• rearrange equation set so that you get series of

xi = fn(other x’s)

• pick order so that using the xi with the largest coefficient in each equation

• guess value for xi, then iterate

6 x1 - 2 x2 + x3 = 11

x1 + 2 x2 - 5 x3 = -1

-2 x1 + 7 x2 + 2 x3 = 5

Page 7: Special Matrices

Jacobi Iteration

• Rearrange

x1 = 1/6 (11 + 2 x2 - x3 )

x2 = 1/7 ( 5 + 2 x1 - 2 x3 )

x3 = 1/5 (1 + x1 + 2 x2 )

• Iterate

x1n+1 = 1/6 (11 + 2 x2

n - x3

n )

x2n+1 = 1/7 ( 5 + 2 x1

n - 2 x3n )

x3n+1 = 1/5 (1 + x1

n + 2 x2n

)

• Guess, plugin, repeatn 0

x1 0

x2 0

x3 0

Page 8: Special Matrices

Importance of diagonal dominance

Simple example

3

2

1

00000

1

)5.0(5.2/1

5.05.2

1

5.0

1

15.2

11

5.05.2

1

2121

12

21

12

21

2

1

21

21

xxxxn

Iterate

xx

xxor

xx

xx

x

x

xx

xx

Page 9: Special Matrices

Convergence

Formally

1

1

1

1

111

1

1

1

11

1

ni

ni

n

j

niiji

ii

n

ijj

niii

niiji

ii

ni

ni

ni

n

ijj

niiji

ii

ni

xx

xaba

xaxaba

xx

x

xaba

x

sides both from Subtract

Page 10: Special Matrices

Stability criteria

equation one least at for

Often

all for

econvergenc Guaranteed

n

ijj

ijii

n

ijj

ijii

aa

iaa

1

1

Page 11: Special Matrices

Convergence criteria

How to judge whether solution is “close enough”

:track

) sequation' each up (add residuals the of average an make or

iteration at

:value) each (aka equation each for residuals use Or

all for :Canale & Chapra

R

nxabR

x

ix

xx

jall

niiji

ni

sni

ni

ni

ai

1

Page 12: Special Matrices

Gauss-Seidal

• In Point-Jacobi technique, we use “old” values of xi throughout each iteration

• but we are calculating “new” values all the way through the procedure

• if we use these “new” values on the RHS’s, this is Gauss-Seidal

Page 13: Special Matrices

Speed-up

219998.19999.020

9998.19998.09795.19898.010

95.195.068.184.04

872.1872.06.168.03

68.168.02.16.02

2.12.01201

00000

1

)5.0(5.2/1

5.0

1

15.2

11

5.05.2

1

2121

12

21

2

1

21

21

.

xxxxn

xx

xx

x

x

xx

xx

Seidal-Gauss Jacobi Iterate

Page 14: Special Matrices

Relaxation

¿ j≠i ¿¿¿n¿ ¿ ¿ Relaxation is just saying don' t do all the change {} # ¿ one iteration¿ the next , just do part of ¿ ¿ ¿ ¿ Chandra & Canale ¿ ¿¿

Page 15: Special Matrices

Under-relaxation and Over-relaxation

xin = xi

n-1 + (xin - xi

n-1)

New value depends on

0 < < 1

> 1

= 1

Page 16: Special Matrices

Engineering examples

Concentrations in a series of connected tanks (steady state)

mass balances1,V1

3, V3

2,V2

Q2in, C2in

Q13, C1Q12, C1 Q21, C2

Q23, C2

Q1in, C1in

Q3out, C3

0

Qc-

Qc-

c

c

c

Q-Q-Q

0Q-Q-Q

0QQ-Q-

0Qc-QcQc- :3 Tank

0Qc-Qc-QcQc :2 Tank

0Qc-QcQc-Qc 1: Tank

2in2in

1in1in

3

2

1

3out2313

232112

211312

2321313out3

2322121212in2in

1312121211in1in

Page 17: Special Matrices

0

0

0

0

0

1000sin0

010100

00100sin

0001cos0

0000coscos

0000sinsin

0cos

0sin

0

0sin

0coscos

0sinsin

FaextV

FcextV

FbextH

FbextV

Fbc

Fac

Fab

c

b

c

cb

cb

c Fbc - Fac

c FcextV-Fac

c FbextH- Fb

b FbextV-Fab

c b - FacFab

c b - FacFaextV-Fab

Engineering examples - Forces on truss

FcextV

a

bc

Fab

Fbc

Fac

FbextV

Fbe

xtH

FaextV Sum of forces at each node = 0 (both vertical & horizontal)

Page 18: Special Matrices

Trusses

Forces on trusses

loads: – dead weight – live (train) weight– wind loads– seismic