lu factorization

6
Numerical Methods Applied to Mechatronics Dr. Jorge A. Olórtegui Yume, Ph.D. Lecture No 9 Mechatronics Engineering School Nacional University of Trujillo LU    FACTORIZATION LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D. 2 LU    FACTORIZATION Recall: In Gauss elimination method the  forwardelimination step of comprises the bulk of the computational effort. 3 2 1 3 2 1 33 32 31 23 22 21 13 12 11 b b b x x x a a a a a a a a a b x A Example: For the system PROBLEM:  repeated be to needs process different a for process in the modified b b LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D. 3 LU    FACTORIZATION To avoid the PROBLEM let´s do some matrix manipulation 3 2 1 3 2 1 33 23 22 13 12 11 0 0 0 d d d x x x u u u u u u 0 b x A b x A can modify this eqn. to give: d x U where: triangular Upper : U Assume an lower triangular matrix exists such that b x A d x U L 1 0 1 0 0 1 32 31 21 l l l L where: triangular Lower : L LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D. 4 LU    FACTORIZATION b x A d L x U L Then: b d L A U L 3 2 1 3 2 1 33 32 31 23 22 21 13 12 11 3 2 1 32 31 21 3 2 1 33 23 22 13 12 11 32 31 21 1 0 1 0 0 1 0 0 0 1 0 1 0 0 1 b b b x x x a a a a a a a a a d d d l l l x x x u u u u u u l l l b x A d x U L 3 2 1 3 2 1 32 31 21 1 0 1 0 0 1 b b b d d d l l l 33 32 31 23 22 21 13 12 11 33 23 22 13 12 11 32 31 21 0 0 0 1 0 1 0 0 1 a a a a a a a a a u u u u u u l l l In explicit form

Upload: jorge-olortegui-yume

Post on 05-Dec-2015

74 views

Category:

Documents


0 download

DESCRIPTION

Num Methods 2

TRANSCRIPT

Page 1: Lu Factorization

Numerical Methods Applied to MechatronicsDr. Jorge A. Olórtegui Yume, Ph.D.

Lecture No 9 

Mechatronics Engineering SchoolNacional University of Trujillo

LU    FACTORIZATION

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.2

LU    FACTORIZATIONRecall: In Gauss elimination method the  forward‐elimination step of comprises the bulk of the computational effort.

3

2

1

3

2

1

333231

232221

131211

bbb

xxx

aaaaaaaaa

bxA

Example: For the system

PROBLEM: 

repeated be toneeds process

different afor process in the modified

bb

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.3

LU    FACTORIZATIONTo avoid the PROBLEM let´s do some matrix manipulation

3

2

1

3

2

1

33

2322

131211

000

ddd

xxx

uuuuuu

0 bxAbxAcan modify this eqn. to give:

dxU where: triangularUpper

:U

Assume an lowertriangular matrix exists such that bxAdxUL

101001

3231

21

lllL

where:

triangularLower

:L

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.4

LU    FACTORIZATION

bxAdLxUL

Then: bdL

AUL

3

2

1

3

2

1

333231

232221

131211

3

2

1

3231

21

3

2

1

33

2322

131211

3231

21

101001

000

101001

bbb

xxx

aaaaaaaaa

ddd

lll

xxx

uuuuuu

lll

bxAdxUL

3

2

1

3

2

1

3231

21

101001

bbb

ddd

lll

333231

232221

131211

33

2322

131211

3231

21

000

101001

aaaaaaaaa

uuuuuu

lll

In explicit form

Page 2: Lu Factorization

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.5

LU    FACTORIZATION• LU factorization methods separate the time‐consuming elimination of the matrix [A] from the manipulations of the right‐hand‐side [b].

• Once [A] has been factored (or decomposed), multiple right‐hand‐side vectors [b] can be evaluated in an efficient manner. 

bdL

AUL

dxU

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.6

LU    FACTORIZATION• LU factorization involves 2 steps:

– Decompose  [A] matrix into a product of [L] and [U].  

– Substitution to solve for {x}– Forward (“Find d”)

– Backward (“Find x”)

• Gauss elimination can be implemented using LU factorization

AUL

bdL

dxU

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.7

LU    FACTORIZATION

• To solve [A]{x}={b}, first decompose [A] to get [L][U]{x}={b}

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

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

• In MATLAB:[L, U] = lu(A)d = L\bx = U\d

Using MATLAB

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.8

LU    FACTORIZATIONExample: Solve the following system using LU decomposition in MATLAB. 

Page 3: Lu Factorization

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.9

LU    FACTORIZATIONExample:

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.10

LU    FACTORIZATIONCholesky Factorization

• One of the most popular techniques to solve symmetric systems. 

• Based on [A]= [U]T[U]

• The rest of the process is similar to LU decomposition and Gauss elimination, except only one matrix, [U], needs to be stored.

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.11

LU    FACTORIZATIONCholesky FactorizationHomework: Write a general purpose Matlab program forChloesky factorzation methdod

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.12

LU    FACTORIZATIONExample:

LU FACTORIZATION

Page 4: Lu Factorization

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.13

LU    FACTORIZATION

• MATLAB can perform a Cholesky factorization with the built‐in chol command:

U = chol(A)

Using MATLAB

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.14

LU    FACTORIZATION

• It examines the system to see which method will most efficiently solve the problem. 

• Includes trying:• banded solvers• back and forward substitutions• Cholesky factorization for symmetric systems.• If these do not work and the system is square, Gauss elimination with partial pivoting is used.

MATLAB left division operator (“\”)

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.15

LU    FACTORIZATIONTHE EIGENVALUE PROBLEM

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.16

LU    FACTORIZATIONTHE EIGENVALUE PROBLEM

Page 5: Lu Factorization

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.17

LU    FACTORIZATIONExample: A box weighing 13 Mg contains a piece of equipmentand is held by three cranes whose cables are connected at ring D as shown. Determine thetensions in cables DA, DB, DC

1.‐ By hand2.‐ Numerically(Note: Solve with LU factorization using Gauss Partialpivoting and verify with “lu” and “/”)

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.18

LU    FACTORIZATIONSolución

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.19

LU    FACTORIZATIONExample: Perform the analysis of the vibrational properties for thefree, undamped 3 degree of freedom system. That is:1.‐ determine the equations of motion, natural frequencies, normal mode shapes and response by hand2.‐Write a matlab program to calculate the natural frequencies3.‐Write a matlab program to calculate the mode shapes4.‐ Verify using “eig” matlab function

m= 1 kgk= 100 N/m

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.20

LU    FACTORIZATIONExample: Determine the current in each branch of the circuit shown

For the data in the next slide

Page 6: Lu Factorization

LU Factorization Dr. Jorge A. Olortegui Yume, Ph.D.21

LU    FACTORIZATIONSolution:

k(Index)

Ek(Volts)

rk()

Rk()

1 12 0.1 252 10 0.5 403 ‐ ‐ 164 12 0.5 205 24 0.2 96 ‐ ‐ 47 ‐ ‐ 20