Gaussian Elimination Solution of Simultaneous Equation

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 30

Numerical Methods

Gaussian Elimination

Prepared by:
Engr. Demy F. Gabriel (PECE, MSME)
Tesseract 4-dimensional cube
NUMERICAL METHODS
Gaussian Elimination
Introduction

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.

A linear equation can involve more than two variables. The general linear
equation in n variables is:

a1x1 + a2x2 + ... + anxn = b

In this form, a1, a2, …, an are the coefficients, x1, x2, …, xn are the variables,
and b is the constant. When dealing with three or fewer variables, it is
common to replace x1 with just x, x2 with y, and x3 with z, as appropriate.
NUMERICAL METHODS
Gaussian Elimination
Introduction

In linear algebra, Gaussian elimination is an algorithm for solving systems of linear


equations, finding the rank of a matrix, and calculating the inverse of an invertible
square matrix. The method is named after Carl Friedrich Gauss but it was not invented
by him.

Elementary row operations are used to reduce a matrix to row echelon form. Gauss–
Jordan elimination, an extension of this algorithm, reduces the matrix further to
reduced row echelon form. Gaussian elimination alone is sufficient for many
applications, and is cheaper than the -Jordan version.

The method of Gaussian elimination appears in Chapter Eight, Rectangular Arrays, of


the important Chinese mathematical text Jiuzhang suanshu or The Nine Chapters on
the Mathematical Art. Its use is illustrated in eighteen problems, with two to five
equations. The first reference to the book by this title is dated to 179 CE, but parts of it
were written as early as approximately 150 BCE. It was commented on by Liu Hui in
the 3rd century.
NUMERICAL METHODS
Gaussian Elimination
Gaussian Elimination is considered the workhorse of computational science for the
solution of a system of linear equations. Karl Friedrich Gauss, a great 19 th century
mathematician, suggested this elimination method as a part of his proof of a particular
theorem. Computational scientists use this “proof” as a direct computational method.

Gaussian Elimination is a systematic application of elementary row operations to a


system of linear equations in order to convert the system to upper triangular form. Once
the coefficient matrix is in upper triangular form, we use back substitution to find a
solution.
NUMERICAL METHODS
Gaussian Elimination

One of the most popular techniques for solving simultaneous linear equations of the
form

 A X   C
Consists of 2 steps:

1. Forward Elimination of Unknowns.


2. Back Substitution
NUMERICAL METHODS
Gaussian Elimination
Gaussian Elimination Steps

1. Write the augmented matrix for the system of linear equations.

2. Use elementary row operations on the augmented matrix [A|b] to transform A into
upper triangular form.

If a zero is located on the diagonal, switch the rows until a nonzero is in that
place.
If you are unable to do so, stop; the system has either infinite or no solutions.

3. Use back substitution to find the solution of the problem.


NUMERICAL METHODS
Gaussian Elimination
Problem:

Solve for the values of a, b, c, d and e from the five equation below.

3a + 9b - 6c - 15d + 9e = -6 eq. 1
2a + 3b - 4c - 6d - 3e = 7 eq. 2
3a + 4b + 5c + 3d - 6e = 34 eq. 3
5a - 2b - 5c + 3d + 2e = - 14 eq. 4
-6a + 3b + 2c + 7d + 4e = - 18 eq. 5

Step 1: Re-write the equations in a matrix format

3 9 -6 -15 9 -6
2 3 -4 -6 -3 7
3 4 5 3 -6 34
5 -2 -5 3 2 -14
-6 3 2 7 4 -18
NUMERICAL METHODS
Gaussian Elimination

3 9 -6 -15 9 -6
2 3 -4 -6 -3 7
3 4 5 3 -6 34
5 -2 -5 3 2 -14
-6 3 2 7 4 -18

Table will be used for ease of computation.

a b c d e eq
3 9 -6 -15 9 -6 1
2 3 -4 -6 -3 7 2
3 4 5 3 -6 34 3
5 -2 -5 3 2 -14 4
-6 3 2 7 4 -18 5
NUMERICAL METHODS
Gaussian Elimination
Original Equation (From This)

a b c d e eq
3 9 -6 -15 9 -6 1
2 3 -4 -6 -3 7 2
3 4 5 3 -6 34 3
5 -2 -5 3 2 -14 4
-6 3 2 7 4 -18 5
Convert it
Final/Forward Elimination (To This)

a b c d e eq
1
0 2
0 0 3
0 0 0 4
0 0 0 0 5
Step 2: Re-arrange the matrix to appear 0 in the required.

a b c d e eq
3 9 -6 -15 9 -6 1 Start here
2 3 -4 -6 -3 7 2 Pivot equation = eq1
Target equation = eq2
3 4 5 3 -6 34 3 Pivot element (PE) = 3
5 -2 -5 3 2 -14 4 Target element (TE) = 2
-6 3 2 7 4 -18 5
New value of eq2:
eq1*(TE/PE) – eq2
Make this 0 eq1*(2/3) – eq2

Step 3: Solve for the new values of equation 2

a b c d e eq
Since this is already 0,
3 9 -6 -15 9 -6 1
swap it with any equation
0 3 0 -4 9 -11 2 that needs this column to
3 4 5 3 -6 34 3 be 0
5 -2 -5 3 2 -14 4
-6 3 2 7 4 -18 5
a b c d e eq
3 9 -6 -15 9 -6 1
0 3 0 -4 9 -11 2 Swap this equation with
eq 4 or eq 5
3 4 5 3 -6 34 3
5 -2 -5 3 2 -14 4
-6 3 2 7 4 -18 5

Step 4: Swap equation 2 with equation 5 (or 4).

a b c d e eq
3 9 -6 -15 9 -6 1
-6 3 2 7 4 -18 5 Rename equation 5 and 2
3 4 5 3 -6 34 3
5 -2 -5 3 2 -14 4
0 3 0 -4 9 -11 2
Step 5: Make the target element 0.
a b c d e eq
3 9 -6 -15 9 -6 1 Start here
-6 3 2 7 4 -18 2 Pivot equation = eq1
Target equation = eq2
3 4 5 3 -6 34 3 Pivot element (PE) = 3
5 -2 -5 3 2 -14 4 Target element (TE) = -6
0 3 0 -4 9 -11 5
New value of eq2:
eq1*(TE/PE) – eq2
eq1*(-6/3) – eq2
Make this 0

Step 6: Solve for the new values of equation 2


a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
3 4 5 3 -6 34 3
5 -2 -5 3 2 -14 4
0 3 0 -4 9 -11 5
Step 7: Make the target element 0.
a b c d e eq
3 9 -6 -15 9 -6 1 Start here
0 -21 10 23 -22 30 2 Pivot equation = eq1
Target equation = eq3
3 4 5 3 -6 34 3 Pivot element (PE) = 3
5 -2 -5 3 2 -14 4 Target element (TE) = 3
0 3 0 -4 9 -11 5
New value of eq3:
eq1*(TE/PE) – eq3
eq1*(3/3) – eq3
Make this 0

Step 8: Solve for the new values of equation 3


a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 5 -11 -18 15 -40 3
5 -2 -5 3 2 -14 4
0 3 0 -4 9 -11 5
Step 9: Make the target element 0.
a b c d e eq
3 9 -6 -15 9 -6 1 Start here
0 -21 10 23 -22 30 2 Pivot equation = eq1
Target equation = eq4
0 5 -11 -18 15 -40 3 Pivot element (PE) = 3
5 -2 -5 3 2 -14 4 Target element (TE) = 5
0 3 0 -4 9 -11 5
New value of eq4:
eq1*(TE/PE) – eq4
eq1*(5/3) – eq4
Make this 0

Step 10: Solve for the new values of equation 4


a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 5 -11 -18 15 -40 3
0 17 -5 -28 13 4 4
0 3 0 -4 9 -11 5
Step 11: Make the target element of column 2 equal to 0.
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2 Start here
Pivot equation = eq2
0 5 -11 -18 15 -40 3
Target equation = eq3
0 17 -5 -28 13 4 4 Pivot element (PE) = -21
0 3 0 -4 9 -11 5 Target element (TE) = 5

New value of eq3:


eq2*(TE/PE) – eq3
Make this 0
eq2*(5/-21) – eq3
Step 12: Solve for the new values of equation 3
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 17 -5 -28 13 4 4
0 3 0 -4 9 -11 5
Step 13: Make the target element of column 2 equal to 0.
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2 Start here
Pivot equation = eq2
0 0 8.619 12.52 -9.76 32.86 3
Target equation = eq4
0 17 -5 -28 13 4 4 Pivot element (PE) = -21
0 3 0 -4 9 -11 5 Target element (TE) = 17

New value of eq4:


eq2*(TE/PE) – eq4
Make this 0
eq2*(17/-21) – eq4
Step 14: Solve for the new values of equation 4
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 0 -3.095 9.381 4.81 -28.3 4
0 3 0 -4 9 -11 5
Step 15: Make the target element of column 2 equal to 0.
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2 Start here
Pivot equation = eq2
0 0 8.619 12.52 -9.76 32.86 3
Target equation = eq5
0 0 -3.095 9.381 4.81 -28.3 4 Pivot element (PE) = -21
0 3 0 -4 9 -11 5 Target element (TE) = 3

New value of eq5:


eq2*(TE/PE) – eq5
Make this 0
eq2*(3/-21) – eq5
Step 16: Solve for the new values of equation 5
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 0 -3.095 9.381 4.81 -28.3 4
0 0 -1.429 0.714 -5.86 6.714 5
Step 17: Make the target element of column 3 equal to 0.
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3 Start here
Pivot equation = eq3
0 0 -3.095 9.381 4.81 -28.3 4
Target equation = eq4
0 0 -1.429 0.714 -5.86 6.714 5 Pivot element (PE) = 8.619.
Target element (TE) = -3.09

Make this 0 New value of eq4:


eq3*(TE/PE) – eq4
Step 18: Solve for the new values of equation 5 eq3*(-3.095/8.169) – eq4

a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 0 0 -13.9 -1.3 16.49 4
0 0 -1.429 0.714 -5.86 6.714 5
Step 19: Make the target element of column 3 equal to 0.
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3 Start here
Pivot equation = eq3
0 0 0 -13.9 -1.3 16.49 4
Target equation = eq5
0 0 -1.429 0.714 -5.86 6.714 5 Pivot element (PE) = 8.619.
Target element (TE) = -1.42

Make this 0 New value of eq5:


eq3*(TE/PE) – eq5
Step 20: Solve for the new values of equation 5 eq3*(-1.4295/8.169) – eq5

a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 0 0 -13.9 -1.3 16.49 4
0 0 0 -2.79 7.475 -12.2 5
Step 21: Make the target element of column 4 equal to 0.
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 0 0 -13.9 -1.3 16.49 4 Start here
Pivot equation = eq4
0 0 0 -2.79 7.475 -12.2 5
Target equation = eq5
Pivot element (PE) = -13.9..
Target element (TE) = -2.79
Make this 0
New value of eq5:
Step 22: Solve for the new values of equation 5 eq4*(TE/PE) – eq5
a b c d e eq eq3*(-13.9/-2.79) – eq5
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 0 0 -13.9 -1.3 16.49 4
0 0 0 0 -7.74 15.47 5
Step 21: Make the target element of column 4 equal to 0.
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 0 0 -13.9 -1.3 16.49 4
0 0 0 0 -7.74 15.47 5 Start solving the variable
here

This is the coefficient of variable e


Step 22: Back Substitution, solving for e:

The matrix above shows that:

– 7.74e = 15.47

Manipulating the equation gives:

e=–2
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 0 0 -13.9 -1.3 16.49 4
0 0 0 0 -7.74 15.47 5

Step 23: Back Substitution, solving for d:

Substitute e = – 2 in equation 4

-13.9d – 1.3e = 16.49

d=–1

Step 24: Back Substitution, solving for c:

Substitute e = – 2 and d = – 1 in equation 3

8.619c +12.52(-1) -9.76(-2) = 32.86

c=3
a b c d e eq
3 9 -6 -15 9 -6 1
0 -21 10 23 -22 30 2
0 0 8.619 12.52 -9.76 32.86 3
0 0 0 -13.9 -1.3 16.49 4
0 0 0 0 -7.74 15.47 5

Step 25: Back Substitution, solving for b:

Substitute e = – 2, d = – 1 and c = 3 in equation 2

-21b + 10(3) +23(-1) – 22(-2) = 30

b=1

Step 26: Back Substitution, solving for b:

Substitute e = – 2, d = – 1, c = 3 and b=1 in equation 1

3a + 9(1) -6(3) -15(-1) +9(-2) = -6

a=2
Step 27: Summarize the answer:

a=2
b=1
c=3
d = -1
e = -2
NUMERICAL METHODS
Gaussian Elimination
Problem no. 2:

Solve for the values of a, b, c, d and e from the five equation below.

3b +2d - 8e = 10 eq. 1
4a + d + 2e = 9 eq. 2
-2c + 6d – 4e = 21 eq. 3
-2a + 6c + 2e = -9 eq. 4
a - 3b + 4c - 8d + 2e = - 27 eq. 5

Step 1: Re-write the equations in a matrix format

0 3 0 2 -8 10
4 0 0 1 2 9
0 0 -2 6 -4 21
-2 0 6 0 2 -9
1 -3 4 -8 2 -27
NUMERICAL METHODS
Gaussian Elimination

0 3 0 2 -8 10
4 0 0 1 2 9
0 0 -2 6 -4 21
-2 0 6 0 2 -9
1 -3 4 -8 2 -27

Table will be used for ease of computation.

a b c d e eq
0 3 0 2 -8 10 1
4 0 0 1 2 9 2
0 0 -2 6 -4 21 3
-2 0 6 0 2 -9 4
1 -3 4 -8 2 -27 5
NUMERICAL METHODS
Gaussian Elimination
a b c d e eq
0 3 0 2 -8 10 1
4 0 0 1 2 9 2
0 0 -2 6 -4 21 3
-2 0 6 0 2 -9 4
1 -3 4 -8 2 -27 5

Rearrange the equation

A b c d e eq
1 -3 4 -8 2 -27 5
0 3 0 2 -8 10 1
0 0 -2 6 -4 21 3
4 0 0 1 2 9 2
-2 0 6 0 2 -9 4
NUMERICAL METHODS
Gaussian Elimination

A b c d e eq
1 -3 4 -8 2 -27 5
0 3 0 2 -8 10 1
0 0 -2 6 -4 21 3
4 0 0 1 2 9 2
-2 0 6 0 2 -9 4

Rename the equation

A b c d e eq
1 -3 4 -8 2 -27 1
0 3 0 2 -8 10 2
0 0 -2 6 -4 21 3
4 0 0 1 2 9 4
-2 0 6 0 2 -9 5
NUMERICAL METHODS
Gaussian Elimination

A b c d e eq
1 -3 4 -8 2 -27 1
0 3 0 2 -8 10 2
0 0 -2 6 -4 21 3
4 0 0 1 2 9 4
-2 0 6 0 2 -9 5

Solve the equation

You might also like