DIRECT METHODS FOR SOLVING SYSTEMS OF LINEAR EQUATIONS

34
Presented by: Acosta Creus Mileidy Lorena 2073699 Teacher: Ph.D. Eduardo Carrillo Zambrano Numerical Methods in Petroleum Engineering INDUSTRIAL UNIVERSITY OF SANTANDER 2010

Transcript of DIRECT METHODS FOR SOLVING SYSTEMS OF LINEAR EQUATIONS

Page 1: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

Presented by:

Acosta Creus Mileidy Lorena 2073699

Teacher:

Ph.D. Eduardo Carrillo Zambrano

Numerical Methods in Petroleum Engineering

INDUSTRIAL UNIVERSITY OF SANTANDER

2010

Page 2: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

1. CONVENTIONAL METHODS OF SOLUTION

1.1. Mathematical background

1.2. Solving Small Numbers Of Equations

1.2.1. Graphical method

1.2.2. Cramer’s rule

1.2.3. Elimination of Unknowns

Page 3: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

2. TECHIQUES FOR IMPROVING SOLUTIONS

2.1. Use of more significant figures

2. 2.Pivoting

2.3. Scaling

3. COMPLEMENTARY TECHNIQUES

3.1. Gauss-Jordan

3.2. LU Decomposition

4. BIBLIOGRAPHY

Page 4: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

SCHOOL OF PETROLEUM ENGINEERING

mnmjmm

inijii

nj

nj

aaaa

aaaa

aaaa

aaaa

A

......

::::

......

::::

......

......

21

21

222221

111211

An matrix A of mxn is a

rectangular array of mn numbers

arranged in m rows and n

columns. The component or

element ij of A, denoted by aij is

the number that appears in the

row i and column j of A.

Page 5: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

SCHOOL OF PETROLEUM ENGINEERING

TYPE DESCRIPTION EXAMPLE

SQUARE

Matrix A (mxn) where the

number of rows equals the

number of columns, ie m = n.

TRANSPOSE

To A = (aij) a matrix of m x n.

The transpose is obtained by

exchanging the rows by the

columns of A.

SYMMETRIC

It’s a square matrix that is

equal to its transpose

1 2 32 3

4 0 5 B1 5

3 1 2

A

1 2 4 61 2 4 6

2 7 3 5 2 7 3 5

4 3 8 0 4 3 8 06 5 0 4

6 5 0 4

tB B

Page 6: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

SCHOOL OF PETROLEUM ENGINEERING

TYPE DESCRIPTION EXAMPLE

UPPER AND

LOWER

TRIANGULAR

Triangular matrix is a special

kind of square matrix whose

elements above or below its

main diagonal are zero

Uppper Lower

AUGMENTED

It’s obtained by combining two

matrices.

BANDED

It has all the elements equal to

zero, with the exception of a

band centered on the main

diagonal

11 12

21 22 23

32 33 34

43 44

a a

a a a

A

a a a

a a

Page 7: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

SCHOOL OF PETROLEUM ENGINEERING

TYPE DESCRIPTION EXAMPLE

DIAGONAL

It’s a square matrix where all the

elements outside the main

diagonal are zero

IDENTITY

It’s a diagonal matrix where all

elements on the main diagonal

are equal to 1

11

22

33

44

0 0 0

0 0 0

0 0 0

0 0 0

a

a

A

a

a

1 0 0 0

0 1 0 0

0 0 1 0

0 0 0 1

A

Page 8: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

SCHOOL OF PETROLEUM ENGINEERING

The following are several methods

that are appropriate for solving

small (n ≤3) sets of simultaneous

equations and that don’t require a

computer.

These are:

• Graphical method

• Determinants and Cramer’s rule

• Elimination of Unknowns

Page 9: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

3

2

5

SCHOOL OF PETROLEUM ENGINEERING

A graphical solution is obtainable for

two equations by plotting them on

Cartesian coordinates with one axis

corresponding to x1 and the other to

x2, because each equation is a straight

line.

a11x

1 + a

12x

2 = b

1

a21

x1 + a

22x

2 = b

2

Despejando x2

Page 10: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

3

2

5

SCHOOL OF PETROLEUM ENGINEERING

Beyond three equations, graphical methods break down and,

consequently, have little practical value for solving

simultaneous equations. There are three cases that can pose

problems when solving sets of linear equations:

x1

x2

x1

x2

x1

x2

a) No solution b) Infinite solutions c) ill-conditioned system

Page 11: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

3

2

5

SCHOOL OF PETROLEUM ENGINEERING

EXAMPLE:

Let x1 be the abscissa. Solve both

equations for x2:

3x1 + 2x

2 = 18

- x1 + 2x

2 = 2

𝑥2 = −3

2𝑥1 + 9

𝑥2 =1

2𝑥1 + 1

Solve:

X1=4 ; X

2=3

With the graphical method

to solve:

Page 12: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

3

2

5

SCHOOL OF PETROLEUM ENGINEERING

Each unknown in a system of linear

algebraic equations may be expressed as a

fraction of two determinants with

denominator D and with the numerator

obtained from D by replacing the column

of coefficients of the unknown in question

by the constants b1,

b2,…,

b

n.

For example,

FUENTE:

http://auladeblanca.blogspot.com

Gabriel Cramer

Page 13: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

3

2

5

SCHOOL OF PETROLEUM ENGINEERING

With Cramer’s rule to solve:

0.3x1 + 0.52x

2 + x

3= -0.01

0.5x1 + x

2 + 1.9x

3= 0.67

0.1x1 + 0.3x

2 + 0.5x

3= -0.44

Solution

D=

0.3 0.52 10.5 1 1.90.1 0.3 0.5

EX

AM

PLE

To write the determinant D: 1

Page 14: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

3

2

5

SCHOOL OF PETROLEUM ENGINEERING

A1=

1 1.90.3 0.5

=1(0.5)-1.9(0.3)=-0.07

A1=

0.5 1.90.1 0.5

=0.5(0.5)-1.9(0.1)=0.06

A1=

0.5 10.1 0.3

=0.5(0.3)-1(0.1)=0.05

To solve the minors: 2 Evaluating the determinant 3

D=0.3(-0.07)-0.52(0.06)+1(0.05)

D=-0.0022

These can be used to

evaluate the determinant,

so:

Page 15: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

3

2

5

SCHOOL OF PETROLEUM ENGINEERING

x1=

−0.01 0.52 10.67 1 1.9

−0.44 0.3 0.5−0.0022

=

0.03278

−0.0022=-14.9

x2=

0.3 −0.01 10.5 0.67 1.90.1 −0.44 0.5

−0.0022=

0.0649

−0.0022=-29.5

x3=

0.3 0.52 −0.010.5 1 0.670.1 0.3 −0.445

−0.0022=

−0.04356

−0.0022=19.8

Employing Cramer’s rule: 4

«For more than three

equations, Cramer´s rule

becomes impractcal

because, as the number of

equatioms increases, the

determinants are time

consuming to evaluate by

hand»

Page 16: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

3

2

5

SCHOOL OF PETROLEUM ENGINEERING

The basic strategy is to multiply the equations by constants so

that one of the unknowns will be eliminated when the two

equations are combined.

The result is a single equation that can be solved for the

remaining unknown.

a11x

1 + a

12x

2 = b

1 a

21a

11x

1 + a

21a

12x

2 = b

1a

21

a21

x1 + a

22x

2 = b

2 a

21a

11x

1 + a

22a

11x

2 = b

1a

11

Page 17: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

3

2

5

SCHOOL OF PETROLEUM ENGINEERING

EXAMPLE:

3x1 + 2x

2 = 18

- x1 + 2x

2 = 2

𝑥1 =2 18 −2(2)

3 2 −2(−1)=4 𝑥2 =

3 2 −18(−1)

3 2 −2(−1)=3

With elimination of unknownse:

Using the last equations:

These values are equals to graphical methods.

Page 18: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

2.1. Use of more

significant figures

• To use more significant

figures in the

computation.

2.2. Pivoting

• Problems occur

when a pivot

element is nearly or

is equal to zero.

• Partial pivoting

(Rows are switched)

• Complete partial

(Columns and rows

are exchanged)

2.3. Scaling

• It has utility in

minimizing round-off

those cases where

some of the equations

in a system have much

larger coefficients than

others.

Page 19: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

Page 20: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

Gaussian elimination is an algorithm of linear algebra to

determine the solutions of a system of linear equations, matrices

and inverse found.

To convert linear equation system to banded matrix 1

mnmnmm

nn

nn

bxaxaxa

bxaxaxa

bxaxaxa

.....

.....

.....

2211

22222121

11213112

mmnmm

n

n

b

b

b

aaa

aaa

aaa

2

1

21

22221

11211

.......

........

........

........_ n21 xxx

Page 21: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

Go to the leftmost nonzero column 2

mmnmm

n

n

b

b

b

aaa

aaa

aaa

2

1

21

22221

11211

.......

........

........

........_ n21 xxx

If the first line has a zero in this column, swap it with another

that does not have

3

0,,0 1211 aa

mmnmm

n

n

b

b

b

aaa

aaa

aaa

2

1

12

22122

11112

.......

........

........

Page 22: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

Get zeros below the pivot, adding appropriate multiples of row

than the row below it

4

12 1 1

11 12 1 1

11 11 11

21 22 2 2

21 22 2 2

11

1 2

1 2

................

........ 1........( )

.......

.......

n

n

n

n

m m mn m

m m mn m

a a b

a a a b

a a a

a a a b Fa a a b

a

a a a b

a a a b

Page 23: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

Repeat the operations with of the other rows to obtain

the higher triangular matrix

3

1.......0........0

...1....0....0

........1...0

........1

3

213

11312

n

n

n

a

aa

aaa

Starting with the last line is not zero, move up to get

the identity matrix.

3

1.......0........0

0...1....0....0

........1...0

.........1

)(*)1(

1.......0........0

...1....0....0

........1...0

........1

223

11312

33

213

11312

n

n

nn

n

n

aa

aaa

aFnnFa

aa

aaa

Page 24: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

Solution of the system of equations 3

bn

b

b

b

xn

x

x

x

3

2

1

.......0........0

0...3....0....0

0....0....2...0

0...0....0...1 1 1

2 2

n n

x b

x b

x b

Page 25: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

EX

AM

PLE

322

1123

82

zyx

zyx

zyx

To find the unknowns of the linear equation system

using the method Gauss-Jordan

3212

11213

8112

1

2

F

3212

11213

42/12/11

Page 26: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

EX

AM

PLE

3212

11213

42/12/11

312

3 21

FF

FF

5120

12/12/10

42/12/11

2*2F

5120

2110

42/12/11

Page 27: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

EX

AM

PLE

3212

11213

42/12/11

312

3 21

FF

FF

5120

12/12/10

42/12/11

2*2F

5120

2110

42/12/11

Page 28: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

EX

AM

PLE

2 1

2 3

(1/ 2)

2

F F

F F

1100

2110

3101

5120

2110

42/12/11

1*3

13

23

F

FF

FF

1100

3010

2001

Page 29: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

The primary appeal of LU decomposition is that the time-

consuming elimination step can be formulated so that it involves

only operations on the matrix of coefficients (A), Thus it is well

suited for those situations where many right-hand-side vectors

(B) must be evaluated for a single value of (A).

The linear equation system can be rearranged to give 1

[A][x]=[B]

Page 30: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

To express the linear equation system as an upper

triangular system

3

[L][D]=[B]

Assume that there is a lower diagonal matrix with 1’s

on the diagonal

2

[U][x]=[D]

𝑈 =

𝑢11 𝑢12 𝑢13

0 𝑢22 𝑢23

0 0 𝑢∗

𝑥1

𝑥2

𝑥3

=

𝑑1

𝑑2

𝑑3

L=1 0 0

𝑙12 1 0𝑙13 𝑙23 1

Page 31: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

a) Decomposition

[A] [X]= [B]

[U] [L]

[L] [D]= [B]

[U] [X]= [D]

[X]

b) Forwards

c) Backward

Substitutio

n

Sum

mary o

f steps

[ D ]

Page 32: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

EX

AM

PLE

Consider solving the system of equations by LU decomposition

1 2 3

1 2 3

1 2 3

2 3 4 6

4 5 10 16

4 8 2 2

x x x

x x x

x x x

Solution

2 3 4

4 5 10

4 8 2

A

1 0 0 2 3 4

2 1 0 y U= 0 1 2

2 2 1 0 0 6

L

Page 33: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS

1

2

3

2 3 4 6

0 1 2 4

0 0 6 2

x

x

x

3

3

2

3 2

1

0.333

4 23.333

1

6 4 37.333

2

x

xx

x xx

3

3

2

3 2

1

0.333

4 23.333

1

6 4 37.333

2

x

xx

x xx

7.333

3.333

0.333

x

Ux=y

So,

Finally, the solution to the linear system is given:

Page 34: DIRECT  METHODS  FOR SOLVING  SYSTEMS OF LINEAR EQUATIONS

ESCUELA DE INGENIERÍA DE PETRÓLEOS