46
06/14/22 http:// numericalmethods.eng.usf.edu 1 LU Decomposition Civil Engineering Majors Authors: Autar Kaw http://numericalmethods.eng.u sf.edu Transforming Numerical Methods Education for STEM Undergraduates

LU Decomposition

Embed Size (px)

DESCRIPTION

LU Decomposition. Civil Engineering Majors Authors: Autar Kaw http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates. LU Decomposition http://numericalmethods.eng.usf.edu. LU Decomposition. - PowerPoint PPT Presentation

Citation preview

Page 1: LU Decomposition

04/20/23http://

numericalmethods.eng.usf.edu 1

LU Decomposition

Civil Engineering Majors

Authors: Autar Kaw

http://numericalmethods.eng.usf.eduTransforming Numerical Methods Education for STEM

Undergraduates

Page 2: LU Decomposition

LU Decomposition

http://numericalmethods.eng.usf.edu

Page 3: LU Decomposition

http://numericalmethods.eng.usf.edu

LU DecompositionLU Decomposition is another method to solve a set of

simultaneous linear equations

Which is better, Gauss Elimination or LU Decomposition?

To answer this, a closer look at LU decomposition is needed.

Page 4: LU Decomposition

MethodFor most non-singular matrix [A] that one could conduct Naïve Gauss Elimination forward elimination steps, one can always write it as

[A] = [L][U]

where

[L] = lower triangular matrix

[U] = upper triangular matrix

http://numericalmethods.eng.usf.edu

LU Decomposition

Page 5: LU Decomposition

http://numericalmethods.eng.usf.edu

How does LU Decomposition work?

Page 6: LU Decomposition

http://numericalmethods.eng.usf.edu

LU DecompositionHow can this be used?

Given [A][X] = [C]

1. Decompose [A] into [L] and [U]

2. Solve [L][Z] = [C] for [Z]

3. Solve [U][X] = [Z] for [X]

Page 7: LU Decomposition

http://numericalmethods.eng.usf.edu

When is LU Decomposition better than Gaussian Elimination?

To solve [A][X] = [B]

Table. Time taken by methods

where T = clock cycle time and n = size of the matrix

So both methods are equally efficient.

Gaussian Elimination LU Decomposition

3

412

3

8 23 n

nn

T

3

412

3

8 23 n

nn

T

Page 8: LU Decomposition

http://numericalmethods.eng.usf.edu

To find inverse of [A]

Time taken by Gaussian Elimination Time taken by LU Decomposition

3

412

3

8

||2

34 n

nn

T

CTCTn BSFE

3

2012

3

32

|||

23 n

nn

T

CTnCTnCT BSFSLU

n 10 100 1000 10000

CT|inverse GE / CT|inverse LU 3.28 25.83 250.8 2501

Table 1 Comparing computational times of finding inverse of a matrix using LU decomposition and Gaussian elimination.

Page 9: LU Decomposition

http://numericalmethods.eng.usf.edu

Method: [A] Decompose to [L] and [U]

33

2322

131211

3231

21

00

0

1

01

001

u

uu

uuu

ULA

[U] is the same as the coefficient matrix at the end of the forward elimination step.

[L] is obtained using the multipliers that were used in the forward elimination process

Page 10: LU Decomposition

http://numericalmethods.eng.usf.edu

Finding the [U] matrixUsing the Forward Elimination Procedure of Gauss Elimination

112144

1864

1525

112144

56.18.40

1525

56.212;56.225

64

RowRow

76.48.160

56.18.40

1525

76.513;76.525

144

RowRow

Step 1:

Page 11: LU Decomposition

http://numericalmethods.eng.usf.edu

Finding the [U] Matrix

Step 2:

76.48.160

56.18.40

1525

7.000

56.18.40

1525

5.323;5.38.4

8.16

RowRow

7.000

56.18.40

1525

U

Matrix after Step 1:

Page 12: LU Decomposition

http://numericalmethods.eng.usf.edu

Finding the [L] matrix

Using the multipliers used during the Forward Elimination Procedure

1

01

001

3231

21

56.225

64

11

2121

a

a

76.525

144

11

3131

a

a

From the first step of forward elimination

112144

1864

1525

Page 13: LU Decomposition

http://numericalmethods.eng.usf.edu

Finding the [L] Matrix

15.376.5

0156.2

001

L

From the second step of forward elimination

76.48.160

56.18.40

15255.3

8.4

8.16

22

3232

a

a

Page 14: LU Decomposition

http://numericalmethods.eng.usf.edu

Does [L][U] = [A]?

7.000

56.18.40

1525

15.376.5

0156.2

001

UL ?

Page 15: LU Decomposition

Example: Cylinder Stresses

To find the maximum stresses in a compound cylinder, the following four simultaneous linear equations need to solved.

0

0070

0

108877

1060573102857400

1538405615384056

1046195102857410461951028574

0010230791028574 3

4

3

2

1

57

5757

57

.

.

c

c

c

c

..

....

....

..

Page 16: LU Decomposition

Example: Cylinder Stresses

In the compound cylinder, the inner cylinder has an internal radius of a = 5”, and outer radius c = 6.5”, while the outer cylinder has an internal radius of c = 6.5” and outer radius, b=8”. Given E = 30×106 psi, ν = 0.3, and that the hoop

stress in outer cylinder is given by

2432

11

1 rcc

E

find the stress on the inside radius of the outer cylinder. Find the values of c1, c2, c3 and c4 using LU decomposition.

Page 17: LU Decomposition

Example: Cylinder Stresses

Use Forward Elimination Procedure of Gauss Elimination to find [U]

Step 1

57

5757

57

106057.3102857.400

15384.05.615384.05.6

104619.5102857.4104619.5102857.4

00102307.9102857.4

112;11028574

10285747

7

RowRow.

.

57

575

57

106057.3102857.400

15384.05.615384.05.6

104619.5102857.4107688.30

00102307.9102857.4

Page 18: LU Decomposition

Example: Cylinder Stresses

777

105167.113;105167.11028574

56RowRow

.

.

57

575

57

106057.3102857.400

15384.05.629384.00

104619.5102857.4107688.30

00102307.9102857.4

Step 1 cont.

Page 19: LU Decomposition

Example: Cylinder Stresses

014;0102857.4

07

RowRow

57

575

57

106057.3102857.400

15384.05.629384.00

104619.5102857.4107688.30

00102307.9102857.4

Step 1 cont.

This is the matrix after Step 1.

Page 20: LU Decomposition

Example: Cylinder Stresses

Step 2

775

107966.723;107966.71076883

293840RowRow

.

.

57

575

57

106057.3102857.400

57968.0914.2600

104619.5102857.4107688.30

00102307.9102857.4

Page 21: LU Decomposition

Example: Cylinder Stresses

024;0107688.3

05

RowRow

57

575

57

106057.3102857.400

57968.0914.2600

104619.5102857.4107688.30

00102307.9102857.4

Step 2 cont.

This is the matrix after Step 2.

Page 22: LU Decomposition

Example: Cylinder Stresses

Step 3

667

105923.134;105294.191426

1028574RowRow

.

.

5

575

57

106250.5000

57968.0914.2600

104619.5102857.4107688.30

00102307.9102857.4

This is the matrix after Step 3.

Page 23: LU Decomposition

Example: Cylinder Stresses

5

575

57

106250.5000

57968.0914.2600

104619.5102857.4107688.30

00102307.9102857.4

][U

Page 24: LU Decomposition

Example: Cylinder Stresses

Use the multipliers from Forward Elimination to find [L]

From the 1st step of forward elimination

1

01

001

0001

434241

3231

21

0102857.4

0

105167.1102857.4

5.6

1102857.4

102857.4

711

4141

77

11

3131

7

7

11

2121

a

a

a

a

a

a

57

5757

57

106057.3102857.400

15384.05.615384.05.6

104619.5102857.4104619.5102857.4

00102307.9102857.4

Page 25: LU Decomposition

Example: Cylinder Stresses

From the 2nd step of forward elimination

1

01

001

0001

434241

3231

21

0107688.3

0

107966.7107688.3

29384.0

522

4242

75

22

3232

a

a

a

a

57

575

57

106057.3102857.400

15384.05.629384.00

104619.5102857.4107688.30

00102307.9102857.4

Page 26: LU Decomposition

Example: Cylinder Stresses

From the 3rd step of forward elimination

1

01

001

0001

434241

3231

21

67

33

4343 105294.1

914.26

102857.4

a

a

57

575

57

106057.3102857.400

57968.0914.2600

104619.5102857.4107688.30

00102307.9102857.4

Page 27: LU Decomposition

Example: Cylinder Stresses

1105924.100

01107966.7105167.1

0011

0001

6

77L

Page 28: LU Decomposition

Example: Cylinder Stresses

Does [L][U] = [A]?

?

106250.5000

57968.0914.2600

104619.5102857.4107688.30

00102307.9102857.4

1105924.100

01107966.7105167.1

0011

0001

5

575

57

6

77

UL

Page 29: LU Decomposition

0zz105924.1

007.0zz1079662.7z1051667.1

0zz

10887.7z

436

327

17

21

31

Example: Cylinder Stresses

Set [L][Z] = [C]

0

007.0

0

10887.7

1105924.100

01107966.7105167.1

0011

0001 3

4

3

2

1

6

77

z

z

z

z

Solve for [Z]

Page 30: LU Decomposition

Example: Cylinder Stresses

Solve for [Z] 3

1 108877 .z

3

3

12

108877

108877

.

.

zz

2

3737

27

17

3

1019531

108877107966710887710516710070

107966710516710070

.

.....

z.z..z

Page 31: LU Decomposition

Example: Cylinder Stresses

Solving for [Z] cont.

19034

10195311059241

1059241

26

36

4

..

z.z

19034

101953.1

10887.7

10887.7

z

z

z

z

Z2

3

3

4

3

2

1

Page 32: LU Decomposition

Example: Cylinder Stresses

Set [U][C] = [Z]

19034

1019531

108877

108877

1062505000

5796809142600

1046195102857410768830

0010230791028574

2

3

3

4

3

2

1

5

575

57

.

.

.

c

c

c

c

.

..

...

..

190341062505

101953157968091426

108877104619510285741076683

1088770010230791028574

45

243

34

53

72

5

3432

51

7

c.

.c.c.

.c.c.c.

.ccc.c.

The four equations become:

Page 33: LU Decomposition

Example: Cylinder Stresses

Solve for [C]

2

54

1038373

1062505

19034

.

.c

4

22

42

42

3

108469.2

914.26

103837.357968.0101953.1

914.26

57968.0101953.1

91426

5796801019531

c

.

c..c

Page 34: LU Decomposition

Example: Cylinder Stresses

3

5

25473

54

53

73

2

1026154

1076883

1038373104619510846921028574108877

1076883

10461951028574108877

.

.

.....

.

c.c..c

5

7

353

7432

53

1

1022449

1028574

10261541023079108877

1028574

001023079108877

.

.

...

.

c-cc..c

Solve for [C] cont.

Page 35: LU Decomposition

Example: Cylinder Stresses

Solution:

The solution vector is

2

4

3

5

4

3

2

1

1038373

1084692

1026154

1022449

.

.

.

.

c

c

c

c

The stress on the inside radius of the outer cylinder is then given by

psi30683

5.6

3.01103837.33.01108469.2

3.01

1030

11

1

224

2

6

2432

rcc

E

Page 36: LU Decomposition

http://numericalmethods.eng.usf.edu

Finding the inverse of a square matrix

The inverse [B] of a square matrix [A] is defined as

[A][B] = [I] = [B][A]

Page 37: LU Decomposition

http://numericalmethods.eng.usf.edu

Finding the inverse of a square matrixHow can LU Decomposition be used to find the inverse?

Assume the first column of [B] to be [b11 b12 … bn1]T

Using this and the definition of matrix multiplication

First column of [B] Second column of [B]

0

0

1

1

21

11

nb

b

b

A

0

1

0

2

22

12

nb

b

b

A

The remaining columns in [B] can be found in the same manner

Page 38: LU Decomposition

http://numericalmethods.eng.usf.edu

Example: Inverse of a MatrixFind the inverse of a square matrix [A]

112144

1864

1525

A

7000

561840

1525

153765

01562

001

.

..

..

.ULA

Using the decomposition procedure, the [L] and [U] matrices are found to be

Page 39: LU Decomposition

http://numericalmethods.eng.usf.edu

Example: Inverse of a MatrixSolving for the each column of [B] requires two steps

1)Solve [L] [Z] = [C] for [Z]

2)Solve [U] [X] = [Z] for [X]

Step 1:

0

0

1

15.376.5

0156.2

001

3

2

1

z

z

z

CZL

This generates the equations:

05.376.5

056.2

1

321

21

1

zzz

zz

z

Page 40: LU Decomposition

http://numericalmethods.eng.usf.edu

Example: Inverse of a MatrixSolving for [Z]

23

5625317650

537650

562

15620

5620

1

213

12

1

.

...

z.z.z

.

.

z. z

z

23

562

1

3

2

1

.

.

z

z

z

Z

Page 41: LU Decomposition

http://numericalmethods.eng.usf.edu

Example: Inverse of a Matrix

Solving [U][X] = [Z] for [X]

3.2

2.56

1

7.000

56.18.40

1525

31

21

11

b

b

b

2.37.0

56.256.18.4

1525

31

3121

312111

b

bb

bbb

Page 42: LU Decomposition

http://numericalmethods.eng.usf.edu

Example: Inverse of a MatrixUsing Backward Substitution

04762.0

25

571.49524.05125

51

9524.08.4

571.4560.156.28.4

560.156.2

571.47.0

2.3

312111

3121

31

bbb

bb

b So the first column of the inverse of [A] is:

571.4

9524.0

04762.0

31

21

11

b

b

b

Page 43: LU Decomposition

http://numericalmethods.eng.usf.edu

Example: Inverse of a MatrixRepeating for the second and third columns of the inverse

Second Column Third Column

0

1

0

112144

1864

1525

32

22

12

b

b

b

000.5

417.1

08333.0

32

22

12

b

b

b

1

0

0

112144

1864

1525

33

23

13

b

b

b

429.1

4643.0

03571.0

33

23

13

b

b

b

Page 44: LU Decomposition

http://numericalmethods.eng.usf.edu

Example: Inverse of a Matrix

The inverse of [A] is

429.1000.5571.4

4643.0417.19524.0

03571.008333.004762.01A

To check your work do the following operation

[A][A]-1 = [I] = [A]-1[A]

Page 45: LU Decomposition

Additional ResourcesFor all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit http://numericalmethods.eng.usf.edu/topics/lu_decomposition.html

Page 46: LU Decomposition

THE END

http://numericalmethods.eng.usf.edu