Вы находитесь на странице: 1из 42

Module 2 - Systems of Linear Algebraic Equations

Module 2
Systems of Linear
Algebraic Equations
Eduardo E. Descalsota, Jr.

Subtopics
2.1 Introduction
2.2 Methods of Solution
2.3 Matrix Inversion Method
2.4 Gauss Elimination Method
2.5 LU Decomposition Methods
2.6 Gauss-Jordan Method
2.7 Jacobis Iteration Method
2.8 Gauss-Seidel Iteration Method

Math 410 - Numerical Methods

Module 2 - Systems of Linear Algebraic Equations

Notations
Algebraic Notation:

Matrix Notation:

or simply Ax = b
where:
coefficients Aij and
constants bj are known
xi represent the unknowns

Augmented Matrix
obtained by adjoining the constant vector b
to the coefficient matrix A

a particularly useful representation of the


equations for computational purposes

Math 410 - Numerical Methods

Module 2 - Systems of Linear Algebraic Equations

Uniqueness of Solution
A system of n linear equations in n unknowns
has a unique solution, provided that:
determinant of the coefficient matrix is
nonsingular, i.e., if |A| 0
rows and columns of a nonsingular matrix
are linearly independent
no row (or column) is a linear combination of
other rows (or columns)

What if the coefficient matrix is


singular?
may have an infinite number of solutions
or, no solutions at all, depending on the
constant vector
Example 1:
2x + y = 3
4x + 2y = 6

x = 1 x = 2 x = 3 x = 0 x = -5
y = 1 y = -1 y = -3 y = 3 y = 13
infinite number of combinations of x and y

Example 2:
2x + y = 3
4x + 2y = 0

Math 410 - Numerical Methods

No Solution:
4x + 2y = 0 is equivalent to 2x + y = 0
hence, any solution that satisfies one
equation cannot satisfy the other one

Module 2 - Systems of Linear Algebraic Equations

2.2
Methods of Solution

Classes of methods for solving


system of linear algebraic equations
direct methods
transforms the original equation into equivalent
equations that can be solved more easily
transformation is carried out by applying certain
operations

indirect or iterative methods


start with a guess of the solution x
then repeatedly refine the solution until a certain
convergence criterion is reached
less efficient than direct methods due to the large
number of operations or iterations required

Math 410 - Numerical Methods

Module 2 - Systems of Linear Algebraic Equations

Direct Methods
1. Matrix Inverse Method
2. Gauss Elimination Method
3. LU Decomposition Methods
4. Gauss-Jordan Method

Indirect or Iterative Methods


1. Jacobis Iteration Method
2. Gauss-Seidel Iteration Method

Math 410 - Numerical Methods

Module 2 - Systems of Linear Algebraic Equations

Advantages and Drawbacks

(1/2)

Direct Method Solution


does not contain any truncation errors
round off errors is introduced due to floatingpoint operations

Advantages and Drawbacks

(2/2)

Iterative Method Solution


more useful to solve a set of ill-conditioned
equations
round off errors (or even arithmetic mistakes) in
one iteration cycle are corrected in subsequent
cycles
contains truncation error
does not always converge to the solution
the initial guess affects only the number of iterations
that are required for convergence

Math 410 - Numerical Methods

Module 2 - Systems of Linear Algebraic Equations

2.3
Matrix Inversion
Method

The Inverse of a Matrix


If A and B are mn matrices such that
AB = BA = I
then B is said to be the inverse of A and is
denoted by:
B = A-1
inverse of a matrix is obtained by dividing
its adjoint matrix by its determinant |A|

Math 410 - Numerical Methods

Module 2 - Systems of Linear Algebraic Equations

Computing the Inverse of a Matrix


A-1 = Aadj /Adet
2x2 matrix:
A= a b
c d
Aadj = d -b
-c a

nxn matrix: (i.e. 3x3)


a11 a12 a13
AI = a21 a22 a23 x
a31 a32 a33

1
0
0

0
1
0

0
0
1

Perform row operations on A such that:

Adet = ad bc
A-1 = Aadj/Adet
A-1 =

1
0

0
1

1
0

a11 a12 a13


a21 a22 a23

a31 a32 a33

a11 a12 a13


a21 a22 a23
a31 a32 a33

Example:

Math 410 - Numerical Methods

Module 2 - Systems of Linear Algebraic Equations

Requirements for obtaining a unique


inverse of a matrix
1. The matrix is a square matrix.
2. The determinant of the matrix is not zero
(the matrix is non-singular)
if |A| = 0, then the elements of A-1 approach infinity

The inverse of a matrix is also defined by the


relationship:
A-1A = I

Properties of an Inverted Matrix


1. The inverse of a matrix is unique.
2. The inverse of the product of two matrices is equal to the
product of the inverse of the two matrices in reverse order:
(AB)-1 = B-1A-1
3. The inverse of a triangular matrix is itself a triangular matrix
of the same type.
4. The inverse of a symmetrical matrix is itself a symmetrical
matrix.
5. The negative powers of a non-singular matrix are obtained
by raising the inverse of the matrix of positive powers.
6. The inverse of the transpose of A is equal to the transpose
of the inverse of A:
(AT)-1 = (A-1)T

Math 410 - Numerical Methods

Module 2 - Systems of Linear Algebraic Equations

Example:
Find the inverse of the matrix
1)

2
5

3
1

3)

4
2
1

3
1
1

4)

15
2
1

2)

3
10
2

2
1

1
2

5
1
4
2
1
8

Solving simultaneous linear


algebraic equations
Consider a set of three simultaneous linear
algebraic equations:
a11x1 + a12x2 + a13x3 = b1
a21x1 + a22x2 + a23x3 = b2
a31x1 + a32x2 + a33x3 = b3
can be expressed in the matrix form:
Ax = b
we obtain the solution of x as:
x = A-1b

Math 410 - Numerical Methods

10

Module 2 - Systems of Linear Algebraic Equations

Example: Solve the following simultaneous linear equations:


x + 3y = 5
4x y = 12
Solving by elimination method:
x + 3y = 5
12x 3y = 36
13x
= 41
x = 41/13
From eq. 2:
y = 4x 12
y = 4(41/13) 12
y = 8/13

Solve:

Solving by matrix inversion


method: (MatLab)
A = [1 3; 4 -1]
b = [5
12]
Using the formula:
x = A-1 b
x = inv(A) * b
x =
3.1538
0.6154

x y + 3z = 5
4x + 2y z = 0
x + 3y + z = 5

Math 410 - Numerical Methods

11

Module 2 - Systems of Linear Algebraic Equations

2.4
Gauss Elimination
Method

Gauss Elimination
a popular technique for solving simultaneous
linear algebraic equations (Ax = b)
reduces the coefficient matrix into an upper
triangular matrix (Ux = c)
consists of two parts:
elimination phase
solution phase

Initial Form: Ax = b
Final Form: Ux = c

Math 410 - Numerical Methods

12

Module 2 - Systems of Linear Algebraic Equations

Gauss Elimination Operations


1. Multiplication of one equation by a non-zero
constant.
2. Addition of a multiple of one equation to
another equation.
3. Interchange of two equations.
Ax = b and Ux = c are equivalent if the sequence of
operations produce the new system Ux = c
A is invertible if U is invertible

Gauss Elimination
Process
1. Eliminate x1 from the second
and third equations
assuming a11 0.
2. Eliminate x2 from the third
row assuming a'22 0.
3. Apply back substitution:
x3 from a''33x3 = b''3
x2 from a'22x2 + a'23x3 = b'2
x1 from a11x1 + a12x2 + a13x3 = b1

Math 410 - Numerical Methods

13

Module 2 - Systems of Linear Algebraic Equations

Pivoting
Gauss elimination method fails if any one of
the pivots becomes zero
What if pivot is zero?
Solution: interchange the equation with its lower
equations such that the pivots are not zero

Example:
Solve the following equations
by Gauss elimination method:

2x + 4y 6z = -4
x + 5y + 3z = 10
x + 3y + 2z = 5

To eliminate x from equations 2 & 3:


2x + 4y 6z = -4
2x + 4y 6z = -4
x + 5y + 3z = 10 (-2/1)
-2x 10y 6z = -20
x + 3y + 2z = 5 (-2/1)
-2x 6y 4z = -10
To eliminate y from equation 3:
-6y 12z = -24
-6y 12z = -24
-2y 10z = -14 (6/-2)
6y + 30z = 42

1
2
3

2x + 4y 6z = -4
-6y 12z = -24
-2y 10z = -14
-6y 12z = -24
18z = 18

Using back substitution:


18z = 18

z=1

-6y 12z = -24

y = (24 12z)/6

2x + 4y 6z = -4

x = 3z 2y 2

Math 410 - Numerical Methods

y=2
x = 3(1)2(2)2
x = -3
y = (4 2(1))

14

Module 2 - Systems of Linear Algebraic Equations

Problem 1:
Use the method of Gaussian elimination to
solve the following system of linear equations:
x1 + x2 + x3 x4 = 2
4x1 + 4x2 + x3 + x4 = 11
x1 x2 x3 + 2x4 = 0
2x1 + x2 + 2x3 2x4 = 2

Problem 2:
Using the Gaussian elimination method, solve
the system of equations [A] {x} = {b} where

Math 410 - Numerical Methods

15

Module 2 - Systems of Linear Algebraic Equations

2.5
LU Decomposition
Methods
Doolittles Method
Choleskis Method
Crouts Method

LU Decomposition
aka LU Factorization
process of computing L and U for a given A
expressed as a product of a lower triangular matrix
L and an upper triangular matrix U
A = LU

General LU Process:
Ax = b
LUx = b

Math 410 - Numerical Methods

Ux = y

Ly = b

16

Module 2 - Systems of Linear Algebraic Equations

Constraints
LU decomposition is not unique unless certain
constraints are placed on L or U

LU advantage over Gauss:


once A is decomposed, Ax = b can be solved
for as many constant vectors b

Doolittles Decomposition
Method

(1/2)

transforms Ax = b to LUx = b to Ux = y
Consider a 3x3 matrix A:
and assume that there exist triangular matrices:

A = LU such that after multiplication:

Math 410 - Numerical Methods

17

Module 2 - Systems of Linear Algebraic Equations

Doolittles Decomposition Method


(2/2)
applying Gauss elimination:
1st pass: choosing the first row as the pivot row
and applying the elementary operations
row 2 row 2 L21 row 1 (eliminates A21)
row 3 row 3 L31 row 1 (eliminates A31)

2nd pass: choosing the second row as pivotal row


row 3 row 3 L32 row 2 (eliminates A32)

Example:
Use Doolittles decomposition method
to solve the equations Ax = b, where
DECOMPOSITION PHASE
1st pass:
1 4 1
pivot: row1
0 2 -2
row2 row2 1 row1
0 -9 0
(eliminates A21)
row3 row3 2 row1
(eliminates A31)
A = A replacing the eliminated
1 4 1
terms with multipliers
0 2 -2
2nd pass:
0 0 -9
pivot: row2
row3 row3 (4.5) row2
(eliminates A32)

1
A = 1
2

4 1
2 -2
-9 0

1 4 1
A = 1 2 -2
2 -4.5 -9

replacing eliminated term

Math 410 - Numerical Methods

18

Module 2 - Systems of Linear Algebraic Equations

SOLUTION PHASE

Forward substitution: Ly = b
y1
=7
y1 + y2
= 13
2y1 4.5y2 + y3 = 5
Solving for y2:
y2 = 13 y1 = 13 7
y2 = 6
Solving for y3:
y3 = 5 2y1 + 4.5y2
y3 = 5 2(7) + 4.5(6)
y3 = 18

Backward substitution: Ux= y


x1 + 4x2 + x3 = 7
2x2 2x3 = 6
-9x3 = 18
x3 = -2
Solving for x2:
2x2 = 6 + 2x3 = 6 + 2(-2)
x2 = 2/2 = 1
Solving for x1:
x1 = 7 4x2 x3 = 7 4(1) + 2
x1 = 5

Problem:
Solve AX = B with Doolittles decomposition
and compute |A|, where

Math 410 - Numerical Methods

19

Module 2 - Systems of Linear Algebraic Equations

Crouts Decomposition Method


A = LU

or

From the equation, we get:


l11 = a11
u12 = a12/l11
l21 = a21
l22 = a22 l21u12
l31 = a31
l32 = a32 l31u12

u13 = a13/l11
u23 = (a23 l21u13) / l22
l33 = a33 l31u13 l32u23

Example: Solve the following set of equations by Crouts method:


2x + y + 4z =12
8x 3y + 2z =20
4x + 11y z =33

A=LU

l11 = 2
l21 = 8
l31 = 4

l11u12 = 1
u12 = 1/2
l22 + l21u12 = -3
l22 = -3 8(1/2)
l22 = -7
l32 + l31u12 = 11
l32 = 11 4(1/2)
l32 = 9

Math 410 - Numerical Methods

l11u13 = 4
u13 = 4/2 = 2
l21u13 + l22u23 = 2
u23 = (2 8(2))/-7
u23 = 2
l31u13+ l32u23+ l33= -1
l33 = -1 4(2) 9(2)
l33 = -27

20

Module 2 - Systems of Linear Algebraic Equations

Ly=B (forward substitution):


2y1 = 12
y1 = 6
Solving for y2:
8y1 7y2 = 20
y2 = [20 8(6)] / -7
y2 = 4
Solving for y3:
4y1 + 9y2 27y3 = 33
y3 = [33 4(6) 9(4)] / -27
y3 = 1

Ux=y (backward substitution):


z=1
Solving for y:
y + 2z = 4
y = 4 2z
y = 4 2(1)
y=2
Solving for x:
x + ()y + 2z = 6
x = 6 ()y 2z
x = 6 ()2 2(1)
x=3

Alternative Crouts Solution


(Column Operations)

2
8
4

1/2 2
0 0
-7 -14
9 -9

2
8
4

2
0 00
-7 -14
0
9 -27
-10

Math 410 - Numerical Methods

Ly = b: forward subst.:
2y1 = 12
y1 = 6
8y1 7y2 = 20
-7y2 = 20 8(6)
y2 = -28/-7 = 4
4y1 + 9y2 27y3 = 33
-27y3 = 33 4(6) 9(4)
y3 = -27/-27 = 1

Ux = y: backward subst:
z = y3 = 1
y + 2z = y2
y = 4 2(1)
y=2
x + y + 2z = y1
x = 6 (2) 2(1)
x=3

21

Module 2 - Systems of Linear Algebraic Equations

Problem:
Solve the following set of equations by using the Crouts
method:
2x1 + x2 + x3 = 7
x1 + 2x2 + x3 = 8
x1 + x2 + 2x3 = 9

Choleskys Decomposition
A = LLT where U=LT
not a particularly popular means of solving
simultaneous equations
but invaluable in certain other applications
(e.g., in the transformation of eigenvalue problems)

Limitations:
requires A to be symmetric since the matrix product LLT
is symmetric
involves taking square roots of certain combinations of
the elements of A
square roots of negative numbers can be avoided only if A is
positive definite

Math 410 - Numerical Methods

22

Module 2 - Systems of Linear Algebraic Equations

Looking at Choleskys A = LLT


Consider a 3x3 matrix:

Multiplying matrices on the right hand side:

Equating the matrices A = LLT, we obtain six equations:

Example:
Compute Choleskys
decomposition of the matrix
Note that A is symmetric, so Choleskis applicable:
Equating the given matrix A to LLT:

Equating the elements yields:

Math 410 - Numerical Methods

23

Module 2 - Systems of Linear Algebraic Equations

Problem:
Solve the equations Ax = b by Choleskys
decomposition method, where:
1)

2)

Problem:
Given the LU decomposition A = LU, determine A and |A|.

Math 410 - Numerical Methods

24

Module 2 - Systems of Linear Algebraic Equations

2.6
Gauss-Jordan
Method

Gauss-Jordan Method
extension of the Gauss elimination method
Ax = b is reduced to a diagonal set Ix = b'
where:
I = a unit matrix
Ix = b' equivalent to x = b' where b'

solution vector

implements the same series of operations as


implemented by Gauss elimination process
main difference is that it applies row operations
below as well as above the main diagonal
all off-diagonal elements are reduced to zero
all main diagonal elements become 1

Math 410 - Numerical Methods

25

Module 2 - Systems of Linear Algebraic Equations

Example:
Solve the following equations
by Gauss-Jordan method.
1 3 2 17
A|b = 1 2 3 16
2 -1 4 13
1 3 2 17
1 2 3 16
2 -1 4 13
Eliminating x in 2 & 3:
1 3 2 17
0 -1 1 -1
0 -7 0 -21

x + 3y + 2z =17
x + 2y + 3z =16
2x y + 4z =13

Normalize 2:
1 3 2 17
0 1 -1 1
0 -7 0 -21
Eliminating y in 1 & 3:
1 0 5 14
0 1 -1 1
0 0 -7 -14

1
2
3

Normalize 3:
1 0 5 14
0 1 -1 1
0 0 1 2
Eliminating z in 1 & 2:
1 0 0 4
0 1 0 3
0 0 1 2
x
y

=4
=3
z =2

Gauss-Jordan Process

Math 410 - Numerical Methods

26

Module 2 - Systems of Linear Algebraic Equations

Problems:
Solve the following system of equations using
the Gauss-Jordan method.
1) x 2y = -4
5y + z = -9
4x 3z = -10
2) 2x1 + x2 3x3 = 11
4x1 2x2 + 3x3 = 8
-2x1 + 2x2 x3 = -6

Problem:
Solve the following system of equations
2x + 6y + z = 7
x + 2y z = -1
5x + 7y 4z = 9
using:
(a) Gaussian elimination and
(b) Gauss-Jordan elimination

Math 410 - Numerical Methods

27

Module 2 - Systems of Linear Algebraic Equations

2.7
Jacobis Iteration
Method

Iterative (or Indirect) Methods


start with an initial guess of the solution x
then repeatedly improve the solution until
the change in x becomes negligible
Known methods:
Jacobi
Gauss-Seidel

Math 410 - Numerical Methods

28

Module 2 - Systems of Linear Algebraic Equations

Pros and Cons of Iterative Methods


feasible to store only the nonzero elements of the
coefficient matrix, making it possible to deal with
very large matrices that are sparse
are self-correcting, meaning that round-off errors
(or even arithmetic mistakes) in one iterative cycle
are corrected in subsequent cycles
slower than their direct counterparts since the
required number of iterations can be very large
do not always converge to the solution
convergence is guaranteed only if the coefficient
matrix is diagonally dominant

Jacobi Iteration
Consider the equation:
3x + 1 = 0
which can be cast into
an iterative scheme as:
2x = -x 1

x=

x +1
2

w/c can be expressed


as:

1
1
x k +1 = x k
2
2

Math 410 - Numerical Methods

Iterations:
x1 = -2-1 2-1x0
where x0 is the initial guess
x2 = -2-1 2-1x1
x3 = -2-1 2-1x2
Will it always converge?
another iterative scheme
x = -2x 1
xk+1 = -2xk 1
Will this converge?

29

Module 2 - Systems of Linear Algebraic Equations

Jacobis Iteration Method


aka the method of simultaneous displacements
Consider the system of
linear equations:

We can solve the


unknowns using:

Assume that a11, a22, and


a33 are the largest
coefficients so that:

Approximations and Iterations


Let the initial approximations be x10, x20, and x30 respectively
Iteration 1:
Iteration 2:

iteration process is continued until the values of x1, x2 and x3


are found to a pre-assigned degree of accuracy
it is a general practice to assume x10 = x20 = x30 = 0

Math 410 - Numerical Methods

30

Module 2 - Systems of Linear Algebraic Equations

Example:
Solve the following equations
by Jacobis method.

15x + 3y 2z = 85
2x + 10y + z = 51
x 2y + 8z = 5

------------------------------------------------------------------

xk+1 = (b1 a12yk a13zk)/a11


yk+1 = (b2 a21xk a23zk)/a22
zk+1 = (b3 a31xk a32yk)/a33
Let: x0 = y0 = z0= 0
x1 = b1/a11 = 85/15 = 17/3
y1 = b2/a22 = 51/10
z1 = b3/a33 = 5/8

x3 = [85 3(3.904) + 2(1.192)]/15

= 5.045
y3 = [51 2(4.73) 1(1.192)]/10

= 4.035
z3 = [5 1(4.73) + 2(3.904)]/8

= 1.010
------------------------------------------------------------------

------------------------------------------------------------------

x2 = [85 3(51/10) (-2)(5/8)]/15

= 4.73

x4 = [85 3(4.035) + 2(1.010)]/15

= 4.994
y4 = [51 2(5.045) 1(1.010)]/10

y2 = [51 2(17/3) 5/8]/10

= 3.99

= 3.904

z4 = [5 1(5.045) + 2(4.035)]/8

z2 = [5 17/3 (-2)(51/10)]/8

= 1.003

= 1.192

Continuing the whole process of iteration:


x
5.667

y
5.100

z
0.625

4.730
5.045
4.994

3.904
4.035
3.990

1.192
1.010
1.003

5.002
5.000
5.000
5.000

4.001
4.000
4.000
4.000

0.998
1.000
1.000
1.000

5.000

4.000

1.000

Math 410 - Numerical Methods

To check:
15x + 3y 2z = 85
2x + 10y + z = 51
x 2y + 8z = 5
15(5)+3(4)2(1) = 85
75 + 12 2 = 85
2(5)+10(4)+1(1) = 85
10 + 40 + 1 = 51
5 2(4) + 8(1) = 85
58+8=5

31

Module 2 - Systems of Linear Algebraic Equations

Problem:
Use the Jacobi iterative scheme to obtain
the solutions of the system of equations
correct to three decimal places.
x + 2y + z = 0
3x + y z = 0
x y + 4z = 3

Problem:
Use Jacobi iterative scheme to obtain the
solution of the system of equations correct to
two decimal places.

Math 410 - Numerical Methods

32

Module 2 - Systems of Linear Algebraic Equations

Generalization of NxN matrix-vector


am1x1 + am2x2 + + ammxm + + amNxN = bm

2.8
Gauss-Seidel
Iteration Method

Math 410 - Numerical Methods

33

Module 2 - Systems of Linear Algebraic Equations

Gauss-Seidel method
aka the method of successive approximations
applicable to predominantly diagonal systems
PDS has large diagonal elements

The absolute value of the diagonal element in


each case is larger than the sum of the absolute
values of the other elements in that row

Gauss-Seidel vs. Jacobi


Each iteration of Jacobi method updates the
whole set of N variables at a time
GS can speed up the convergence by using
all the most recent values of variables for
updating each variable even in the same
iteration

Math 410 - Numerical Methods

34

Module 2 - Systems of Linear Algebraic Equations

Gauss-Seidel generalization formula

Solve the following equations


by Gauss-Seidel method.

8x + 2y 2z = 8
x 8y + 3z = -4
2x + y + 9z = 12

Iteration 2:
x2 = (b1 a12y1 a13z1)/a11
= [8 2(5/8) + 2(1.042)]/8 = 1.104
y2 = (b2 a21x2 a23z1)/a22
= [-4 1(1.104) 3(1.042)]/-8 =1.029
z2 = (b3 a31x2 a32y2)/a33
= [12 2(1.104) 1(1.029)]/9 = 0.974
Let: x0 = y0 = z0 = 0
3:
i Iteration
1
2
3
4
5
6
7
Iteration 1:
(b1 1.104
a12y20.986
a131.004
z2)/a11
x x3 =
1.000
0.999 1.000 1.000
x1 = b1/a11 = 8/8 = 1
=
[8

2(1.029)
+
2(0.974)]/8
= 0.986
y 0.625 1.029 0.988 1.002 0.999 1.000
1.000
y1 = (b2 a21x1)/a22
y
=
(b

a
x

a
z
)/a
21 31.004 230.999
2
22
z 3 1.042 2 0.974
1.000 1.000 1.000
= [-4 1(1)]/-8 = 5/8
= [-4 1(0.986) 3(0.974)]/-8 =0.988
z1 = (b3 a31x1 a32y1)/a33
z3 = (b3 a31x3 a32y3)/a33
= [12 2(1) 1(5/8)]/9 = 1.042 = [12 2(0.986) 1(0.988)]/9 = 1.004

Math 410 - Numerical Methods

35

Module 2 - Systems of Linear Algebraic Equations

Problem: Solve the following equations


by the Gauss-Seidel method.
1) 4x y + z = 12
-x + 4y 2z = -1
x 2y + 4z = 5
2) 2x y + 3z = 4
x + 9y 2z = -8
4x 8y + 11z = 15

Gauss-Seidel Method
The equations Ax = b are in scalar notation

Extracting the term containing xi from the summation


sign yields
Solving for xi, we get:

Math 410 - Numerical Methods

36

Module 2 - Systems of Linear Algebraic Equations

Iterative Scheme
start by choosing the starting vector x
if a good guess is not available, x can be
chosen randomly
recompute each element of x, always using
the latest available values of xj
procedure is repeated until the changes in x
between successive iteration cycles become
sufficiently small

Relaxation
a technique used to improve the convergence of
the Gauss-Seidel method
take the new value of xi as a weighted average of
its previous value and the initial guess

where is called the relaxation factor


<1
interpolation bet. the old xi and initial guess
(or underrelaxation)
>1
extrapolation (or overrelaxation)

Math 410 - Numerical Methods

37

Module 2 - Systems of Linear Algebraic Equations

The essential elements of a GaussSeidel algorithm with relaxation


1. Carry out k iterations with =1 (k=10 is
reasonable). After the kth iteration record x(k).
2. Perform an additional p iterations (p 1) and
record x(k+p) after the last iteration.
3. Perform all subsequent iterations with = opt,
where

Convergence Considerations
Convergence of the iterative schemes is ensured:

if in each row of coefficient matrix A, the


absolute value of the diagonal element is
greater than the sum of the absolute values
of the other elements
sufficient, but not a necessary, condition

using the relaxation technique


which may be helpful in accelerating the
convergence of GaussSeidel iteration

Math 410 - Numerical Methods

38

Module 2 - Systems of Linear Algebraic Equations

MatLab Functions

1/2

x = A\b
returns the solution x of Ax =b
obtained by Gauss elimination

[L,U] = lu(A)
Doolittle s decomposition A = LU

L = chol(A)
Choleski s decomposition A = LLT

B = inv(A)
returns B as the inverse of A

c = cond(A)
returns the condition number of the matrix A

MatLab Functions

2/2

A = spdiags(B,d,n,n)
creates a n n sparse matrix from the columns of matrix
B by placing the columns along the diagonals specified
by d

A = full(S)
converts the sparse matrix S into a full matrix A

S = sparse(A)
converts the full matrix A into a sparse matrix S

x = lsqr(A,b)
conjugate gradient method for solving Ax = b

spy(S)
draws a map of the nonzero elements of S

Math 410 - Numerical Methods

39

Module 2 - Systems of Linear Algebraic Equations

Exercises:
1) Determine the inverse
of the following matrices:
a)

Set 1
2) Solve the following
set of simultaneous
linear equations by the
matrix inverse method.
(a) 2x + 3y z = -10
-x + 4y + 2z = -4
2x 2y + 5z = 35

b)
(b) 10x + 3y + 10z = 5
8x 2y + 9z = 2
8x + y 10z =35

Exercises:
1) Solve using
Gaussian elimination:
a) 2x + y 3z = 11
4x 2y + 3z = 8
-2x + 2y z = -6
b) 6x + 3y + 6z = 30
2x + 3y + 3z = 17
x + 2y + 2z = 11

Math 410 - Numerical Methods

Set 2
2) Solve using GaussJordan method:
a) 4x 3y + 5z = 34
2x y z = 6
x + y + 4z = 15
b) 2x y + z = -1
3x + 3y + 9z = 0
3x + 3y + 5z = 4

40

Module 2 - Systems of Linear Algebraic Equations

Exercises:

Set 3

1) Solve using
Choleskis method:
a) 2x y = 3
-x + 2y z = -3
-y + z = 2

2) Solve using Crouts


method:
a) 3x + 2y + 7z = 4
2x + 3y + z = 5
3x 4y + z = 7

b) x + y + z = 7
3x + 3y + 4z = 23
2x + y + z = 10

b) x + y + z = 9
2x 3y + 4z = 13
3x + y + 5z = 40

Exercises:

Set 4

Solve using Jacobis


iteration method:
a) 2x y + 5z = 15
2x + y + z = 7
x + 3y + z = 10

Solve using GaussSeidel iteration method:


a) 4x 3y + 5z = 34
2x y z = 6
x + y + 4z = 15

b)

b)

20x + y 2z = 17
3x + 20y z = -18
2x 3y + 20z = 25

Math 410 - Numerical Methods

2x y + 5z = 15
2x + y + z = 7
x + 3y + z = 10

41

Module 2 - Systems of Linear Algebraic Equations

Exercises:

Set 5

The electrical network shown can be viewed as


consisting of three loops. Applying Kirchoffs
law (voltage drops = voltage sources) to
each loop yields the following equations for
the loop currents i1, i2 and i3:
5i1 + 15(i1 i3) = 220V
R(i2 i3) + 5i2 + 10i2 = 0
20i3 + R(i3 i2) + 15(i3 i1) = 0
Compute the three loop currents for R = 5, 10
and 20.

Math 410 - Numerical Methods

42

Вам также может понравиться