Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Assignment -2:

An extension of the Gauss elimination technique is the Gauss-Jordan method. The advantage of this method is that it can be used to give the inverse of the square matrix A, which can be used to solve a whole series of equations AX=bk, k= 1,2,, using matrix multiplication x = A-1bk The technique differs from Gauss elimination in three ways: (1) An augmented matrix aug A = [A|b|I], with I being a unit diagonal matrix is first formed. (2) The diagonal elements are normalized to unity. (3) Elimination of elements below as well as above the pivot element is carried out on aug A. Thus, after the procedure, one obtains a unit diagonal matrix at the location of A in the matrix aug A (Gauss elimination led to an upper triangular matrix U instead). In the location of b, the solution vector is obtained, and in the location of I one obtains A-1.

Illustrated Example : Solution by Gauss Jordan Elimination

1 1 2 x1 8 1 1 1 x = 2 2 2 2 3 x3 20
The augmented matrix is first formed:

1 1 2 | 8 | 1 0 0 1 1 1 | 2 | 0 1 0 2 2 3 | 20 | 0 0 1 aug A =
The a21 and a31 elements are eliminated ( since a11=1, normalization of the 1st row is not required) by multiplying the 1st rowby -1 and -2 and adding to rows 2 and 3 respectively:

1 1 2 | 8 | 1 0 0 0 2 1 6 | 1 1 0 0 0 1 | 4 | 2 0 1
The second row is now normalized next:

2| 8| 1 0 0 1 1 0 1 1 / 2 | 3 | 1 / 2 1 / 2 0 0 0 1| 4 | 2 0 1

The element a12 is now eliminated by multiplying the second row by 1 and adding it to the 1st row. No operation is required on the third row since its 2nd element is already 0:

1 0 3 / 2 | 5 | 1 / 2 1 / 2 0 0 1 1 / 2 | 3 | 1 / 2 1 / 2 0 0 0 1 | 4 | 2 0 1
The 3rd row is normalized by dividing by -1:

1 0 3 / 2 | 5 | 1 / 2 1 / 2 0 0 1 1 / 2 | 3 | 1 / 2 1 / 2 0 0 0 1| 4| 2 0 1
The 3rd row is multiplied by -3/2 and and added to the first and second row respectively to give:

1 0 0 | 11 | 5 / 2 1 / 2 3 / 2 0 1 0 | 5 | 1 / 2 1 / 2 1 / 2 0 0 1 | 4| 2 0 1

The solution vector and the inverse of A is thus obtained. Note there is no need for backward substitution. Q6. Write a program again in FORTRAN or C to solve the above matrix and to evaluate obtained gives the identity matrix. Q7. Ponder on the algorithm to think why this method gives the A-1.

Iterative Methods : Gauss Seidel, Jacobi, SOR Gauss Seidel Gauss Seidel: In this method, values for all the N variables [xi(1) = 1,2,3,,N] are first assumed. The first equation in Ax = b is rearranged as:

b1 a12 x 2
X1(2) =

(1)

a13 x3 .... a1N x N a11


(1)

(1)

b1 a 21 x1
X2(2) =

( 2)

a 23 x3 .... a 21 x N a 22
(1)

(1)

Observe that the second equation used the most updated value of x to obtain an updated value of x2.This continues through all the N equation to have an updated x(2). Note that the Jacobis algorithm uses the updated values only in the next iteration. The computations are computations are continued until some prescribed error criteria is met for example:

xi
Errori =

(k )

xi
( k 1)

( k 1)

xi

TOL

Q8. Write a Fortran or C program to solve N linear equations via Gauss Seidel and Jacobi method.

i Q9.Upto 25 iterations draw the vs i results (I is the iteration number) for GS and Jacobi method for the following set of equations starting with initial guess of x (1) = [1 2 1]T.

Error

2 1 0 x1 1 1 2 1 x = 2 2 0 1 1 x 3 4
The convergence of Gauss Seidel technique can be speeded up using successive over-relaxation(SOR). Using x(k-1), the entire vector x(k)GS , is first estimated from the Gauss Seidel algorithm and then x(k) is calculated using a weighted average xik = w*xi,GS(k) +(1-w)* xi(k-1) Usually 1<w<2, for w=1, we get ordinary Gauss Seidel results. Q10. Solve the matrix in Q9, with the same guess values but with SOR with w=1.5 and make a comparative study with the GS method to see the convergence with iteration. (Do things via a computer program). The solution of the given set of equations are x = [3 -5 9]T.

You might also like