Linear and non linear equation

39
computing discrete approximation of solution of linear simultaneous equation JMHM Jayamaha

Transcript of Linear and non linear equation

Page 1: Linear and non linear equation

computing discreteapproximation of solution of linear

simultaneous equation

JMHM Jayamaha

Page 2: Linear and non linear equation

Content

Linear Equations What is Linear Equations Method for solving the system of linear equations

Direct Method Gauss Elimination method

LU Decomposition

Iterative method Jacobi's method

Gauss Seidal method

Page 3: Linear and non linear equation

Linear Equations

Page 4: Linear and non linear equation

What is Linear Equations A linear equation is an algebraic equation in which each term is

either a constant or the product of a constant and (the first power of) a single variable.

Page 5: Linear and non linear equation

Two methods for solving the system of linear equations

Direct Method Solutions are obtained through a finite number of arithmetic

operations Gauss Elimination method

LU Decomposition

Iterative Method: Solutions are obtained through a sequence of successive approximations

which converges to the required solution Jacobi's method

Gauss Seidal method

Page 6: Linear and non linear equation

GAUSS – ELIMINATION METHOD

Page 7: Linear and non linear equation

GAUSS – ELIMINATION METHOD

Consider a system of 3 – equations with 3 – unknowns

)1(

3333232131

2323222121

1313212111

bxaxaxabxaxaxabxaxaxa

Page 8: Linear and non linear equation

Form the augmented matrix from the given equations as

3333231

2232221

1131211

baaabaaabaaa

111

2122 operation row theUse R

aaRR

111

3133 operation row theUse R

aaRR

If a11 0

Page 9: Linear and non linear equation

New augmented matrix will be

'''0'''0

33332

22322

1131211

baabaabaaa

Page 10: Linear and non linear equation

222

3233 '

' operation row theUse RaaRR

New augmented matrix will be

''''00'''0

333

22322

1131211

babaabaaa

If a22’ 0

Page 11: Linear and non linear equation

From the last matrix, the equations can be written as

'''' '''

3333

2323222

1313212111

bxabxaxabxaxaxa

Page 12: Linear and non linear equation

Use back substitution to get the solution as

11

31321211

22

32322

33

33

, '''

, ''''

axaxabx

axabx

abx

Page 13: Linear and non linear equation

Gauss Elimination method Matlab Implementationfunction x = Gauss(A,b); n = length(b); x = zeros(n,1); for k=1:n-1 % forward elimination for i=k+1:n xmult = A(i,k)/A(k,k); for j=k+1:n A(i,j) = A(i,j)-xmult*A(k,j); end b(i) = b(i)-xmult*b(k); end end % back substitution x(n) = b(n)/A(n,n); for i=n-1:-1:1 sum = b(i); for j=i+1:n sum = sum-A(i,j)*x(j); end x(i) = sum/A(i,i); end

Page 14: Linear and non linear equation

LU Decomposition

Page 15: Linear and non linear equation

Matrix A is decomposed into a product of a lower triangular matrix L and an upper triangular matrix U, that is A = LU or

10010

1 0

00

23

1312

333231

2221

11

333231

232221

131211

uuu

lllll

l

aaaaaaaaa

Page 16: Linear and non linear equation

Matrices L and U can be obtained by the following rule

1. Step 1: Obtain l11 = a11, l21 = a21, l31 = a31

11

1313

11

1212 ,Obtain :2 Step .2

aau

aau

3. Step 3: Obtain l22 = a22 – l21u12

13212322

231Obtain :4 Step .4 ulal

u

5. Step 5: Obtain l32 = a32 – l31u12

6. Step 6: Obtain l33 = a33 – l31u13 – l32u23

Page 17: Linear and non linear equation

Once lower and upper triangular matrices are obtained the solution of Ax = b can be obtained using the procedure

Ax = b LUx = b

Let Ux = y then

LUx = b Ly = b

Page 18: Linear and non linear equation

Steps to get the solution of linear equations

3

2

1

3

2

1

333231

2221

11

000

bbb

yyy

lllll

lbLy

232131333

3

121222

211

11

1 and

1 , where

ylylbl

y

ylbl

ylby

By Forward substitution

Page 19: Linear and non linear equation

3

2

1

3

2

1

23

1312

10010

1 Now

bbb

xxx

uuu

bUx

31321211

3232233 , wherexuxuyx

xuyxyx

By Backward substitution

Page 20: Linear and non linear equation

Matlab Implementation for LU Decomposition

Page 21: Linear and non linear equation

Iterative methodsThe Jacobi Method

Page 22: Linear and non linear equation

The Jacobi Method

This method makes two assumptions1. that the system given by has a unique solution2. the coefficient matrix A has no zeros on its main diagonal

Page 23: Linear and non linear equation

To begin the Jacobi method, solve the first equation for x1 the second equation for x2 and so on, as follows.

Then make an initial approximation of the solution,

Page 24: Linear and non linear equation

Algorithm

Page 25: Linear and non linear equation

Example

Page 26: Linear and non linear equation

To begin, write the system in the form

Because you do not know the actual solution, choose

Page 27: Linear and non linear equation

as a convenient initial approximation. So, the first approximation is

Continuing this procedure, you obtain the sequence of approximations shown in Table

Page 28: Linear and non linear equation

Because the last two columns in Table are identical, you can conclude that to three significant digits the solution is

Page 29: Linear and non linear equation

Matlab Implementation for jacobi method

Page 30: Linear and non linear equation

Iterative methodsThe Gauss-Seidel Method

Page 31: Linear and non linear equation

Gauss-Seidel iteration is similar to Jacobi iteration, except that new values for xi are used on the right-hand side of the equations as soon as they become available.

It improves upon the Jacobi method in two respects Convergence is quicker, since you benefit from the newer,

more accurate xi values earlier. Memory requirements are reduced by 50%, since you only need to

keep track of one set of xi values, not two sets.

Page 32: Linear and non linear equation

Algorithm

Page 33: Linear and non linear equation

Example

Page 34: Linear and non linear equation

Step 1: reformat the equations, solving the first one for x1, the second for x2, and the third for x3

Page 35: Linear and non linear equation

Step 2a: Substitute the initial guesses for xi into the right-hand side of the first equation

Step 2b: Substitute the new x1 value with the initial guess for x3 into the second equation

Step 2c: Substitute the new x1 and x2 values into the third equation

Page 36: Linear and non linear equation

Step 3, 4, · · · : Repeat step 2 and watch for the xi values to converge to an exact solution.

Page 37: Linear and non linear equation

Matlab Implementation of Gauss-Seidel Method

Page 38: Linear and non linear equation

Summary

Solution of linear simultaneous are discussed. Two methods

Direct Gauss Elimination method

LU Decomposition

Iterative Jacobi's method

Gauss Seidal method

Page 39: Linear and non linear equation

References https://en.wikipedia.org/wiki/Linear_equation(2016-06-15) http://homel.vsb.cz/~dom033/predmety/parisLA/

02_direct_methods.pdf Numerical computational methods by P.B Patill , U.P Verma http://college.cengage.com/mathematics/larson/elementary_linear/

5e/students/ch08-10/chap_10_2.pdf http://ocw.usu.edu/Civil_and_Environmental_Engineering/

Numerical_Methods_in_Civil_Engineering/NonLinearEquationsMatlab.pdf

http://people.whitman.edu/~hundledr/courses/M467/GaussSeidel.pdf