Lecture 2.2 Solution of Systems of Linear Equation
Lecture 2.2 Solution of Systems of Linear Equation
Linear Equations
Eyob A.
Linear equations
Eyob A.
LINEAR EQUATION
▪ A system of linear equations has
1. No Solution, Or
2. Exactly One Solution, Or
3. Infinitely Many Solutions.
Eyob A.
Systems of Linear Equations
Numerical methods
Analytical Methods
1. Cramer’s Rule
1. Graphically Method 2. Gaussian Method
3. LU decomposition Method
2. Substitution Method
4. Jacobian Itration
3. Elimination Method 5. Guass Seidel Iteration
Eyob A.
Analytical Solutions To
Systems Of Linear Equation
1. Graphically Method
2. Substitution Method
3. Elimination Method
Eyob A.
• System of equations: A group of two or more equations.
• A system of linear equations consists of two or more linear equations.
x+ y =5 (Equation 1)
3x − 4 y = 8 (Equation 2)
Eyob A.
1. Graphical Method
a. If the lines intersect at a single point, then the
coordinates of that point form the solution.
Eyob A.
1. Graphical Method
x + y = 5 y = 3x + 1 x + 2 y = 4
y = 2x − 4 y = 3x − 2 2 x + 4 y = 8
Eyob A.
2. Substitution Method
• Solve the system of equations using substitution.
4 x + 5 y = 8
x = 1− y
x = 1− y
x = 1− 4 The solution is (−3, 4).
x = −3
Eyob A.
2. Substitution Method
• Solve the system of equations using substitution.
3 x − y = − 4
y = 3x − 5
Eyob A.
3. Elimination Method
Example: Solve the following system of equations using the elimination method.
6x – 3y = –3 and 4x + 5y = –9
Multiply both sides of the first equation by 5 and the second equation by 3.
5(6x – 3y) = 5(–3) 3(4x + 5y) = 3(–9)
30x – 15y = –15 12x + 15y = –27
6x – 3y = –3 and 4x + 5y = –9
Combine the two resulting equations (eliminating the variable y).
30x – 15y = –15
12x + 15y = –27 x = –1 and y = –1
42x = –42
Eyob A.
1. Cramer's Rule
• A method for solving linear simultaneous equations.
Eyob A.
Coefficient Matrices
You can use determinants to solve a system of linear equations.
You use the coefficient matrix of the linear system.
Eyob A.
Considering Cramer’s Rule
Eyob A.
Solve the system:
Cramer’s Rule…Example 1 8x+5y= 2
The coefficient matrix 2x-4y= -10
8 5 8 5
= (−32) − (10) = −42
2 − 4 2 −4
2 5
8 2
2 5 − 10 − 4 − 8 − ( −50) 42
2 − 10 x= = = =
− 10 − 4 y= − 42 − 42 − 42
x= − 42
− 42
8 2
2 − 10 − 80 − 4 − 84
y= = = =2
− 42 − 42 − 42
A x = B
2 −4 5 36 −4 5
where
D = −3 5 7 = −336 D1 = 7 5 7 = −672
2 −4 5 −31 −8
−8 3
A = −3 7
5 3
5
5 3 −8
2 36 5 2 −4 36
D2 = −3 7 7 = 1008 D3 = −3 5 7 = −1344
5 −31 −8 5 3 −31
Eyob A.
Example 2
D1 −672
x1 = = =2
D −336
D2 1008
x2 = = = −3
D −336
D −1344
x3 = 3 = =4
D −336
Eyob A.
Solve the system : 3x - 2y + z = 9
Example 3 x + 2y - 2z = -5
x + y - 4z = -2
9 −2 1 3 9 1 3 −2 9
−5 2 −2 1 −5 −2 1 2 −5
−2 1 −4 −23 1 −2 −4 69 1 1 −2 0
x= = =1 y= = = −3 z= = =0
3 −2 1 −23 3 −2 1 −23 3 −2 1 −23
1 2 −2 1 2 −2 1 2 −2
1 1 −4 1 1 −4 1 1 −4
The solution is
(1, -3, 0)
Eyob A.
2. Gaussian Elimination
Consists of 2 steps
2. Back Substitution
25 5 1 25 5 1
64 8 1 → 0 − 4.8 − 1.56
144 12 1 0 0 0.7
Eyob A.
2. Gaussian Elimination
Eyob A.
2. Gaussian Elimination…Example 1
2x + 4 y − 2z = 2
4x + 9 y − 3z = 8
− 2 x − 3 y + 7 z = 10
Using the first equation to eliminate x from the next two equations
Eyob A.
2. Gaussian Elimination…Example 1
2x + 4 y − 2z = 2
y + z = 4
y + 5 z = 12
Eyob A.
2. Gaussian Elimination…Example 1
Using the second equation to eliminate y from the third equation
2x + 4 y − 2z = 2
y + z = 4
4z = 8
We now have a triangular system which is easily solved using a technique called
Backward-Substitution. 2x + 4 y − 2z = 2
y + z = 4
Eyob A. 4z = 8
Backward Substitution
2x + 4 y − 2z = 2
From the previous work, we have
y + z = 4
And substitute z in the first two equations z = 2
2x + 4 y − 4 = 2
y + 2 = 4
2x + 4 y − 4 = 2 z = 2
We can solve y y = 2
z = 2
And 𝑥 = −1
Eyob A.
3. LU Decomposition
Method
Conduct Naïve Gauss Elimination forward elimination steps [A] = [L][U]
Where,
[L] = lower triangular matrix
[U] = upper triangular matrix
Eyob A.
3. LU Decomposition
Eyob A.
3. LU Decomposition
[U] is the same as the coefficient matrix at the end of the forward elimination step.
[L] is obtained using the multipliers that were used in the forward elimination process
Eyob A.
Finding the [U] Matrix
25 5 1
Matrix after Step 1: 0 − 4.8 − 1.56
0 − 16.8 − 4.76
25 5 1
− 16.8
Step 2: = 3.5; Row3 − Row2(3.5) = 0 − 4.8 − 1.56
− 4.8
0 0 0.7
25 5 1
U = 0 − 4.8 − 1.56
0 0 0.7
Eyob A.
Finding the [L] Matrix
1 0 0
L = 2.56 1 0
5.76 3.5 1
Eyob A.
3. LU Decomposition
25 5 1 x1 106.8
Solve the following set of linear 64 8 1 x = 177.2
equations using LU Decomposition 2
144 12 1 x3 279.2
Using the procedure for finding the [L] and [U] matrices
1 0 0 25 5 1
A = LU = 2.56 1 0 0 − 4.8 − 1.56
5.76 3.5 1 0 0 0.7
Eyob A.
LU Decomposition… Example1
Complete the forward substitution to solve for [Z]
z1 = 106.8
z 2 = 177.2 − 2.56z1
= 177.2 − 2.56(106.8) z1 106.8
= −96.2 Z = z2 = − 96.21
z3 = 279.2 − 5.76z1 − 3.5 z 2 z3 0.735
= 279.2 − 5.76(106.8) − 3.5(− 96.21)
= 0.735
Eyob A.
LU Decomposition… Example1
Set [U][X] = [Z]
25 5 1 x1 106.8
0 − 4.8 − 1.56 x = − 96.21
2
0 0 0.7 x3 0.735
Eyob A.
LU Decomposition… Example1
Substituting in a3 and a2 using the first equation Hence the Solution Vector is:
Eyob A.
3. Jacobi İteration
a11 x1 + a12 x2 + + a1n xn = b1 x10
a21 x1 + a22 x2 + + a2 n xn = b2 0
x2
x =
0
0
an1 x1 + an 2 x2 + + ann xn = bn xn
x11 =
1
(b1 − a12 x20 − − a1n xn0 ) 1 i −1 n
bi − aij x j − aij x j
k +1
a11 x
i = k k
aii j =1 j =i +1
1
x12 = (b2 − a21 x10 − a23 x30 − − a2 n xn0 )
a22
1
x1n = (bn − an1 x10 − an 2 x20 − − ann −1 xn0−1 )
ann
Eyob A.
Jacobi Iteration… Example 1
7 + x20 − x30 7
4 − 1 1 x1 7 0 x =
1
1
= = 1.75
4 − 8 1 x = − 21 4 4
2 x 0 = 0 21
− 2 1 5 x3 15
21 + 4 x 0
+ x 0
= = 2.625
0 x12 = 1 3
8
8
15
15 + 2 x10 − x20 = = 3.0
Diagonally dominant matrix x3 =
1
5
5
7 + x1
− x1
7 + 2.625 − 3
x12 = 2 3
= = 1.65625 7 + 3.875 − 4.225
4 4 x13 = = 1.6625
4
21 + 4 x11 + x31 21 + 4 1.75 + 3
x2 =
2
= = 3.875 21 + 4 1.65625+ 4.225
8 x23 = = 3.98125
8 8
15 + 2 x11 − x12 15 + 2 1.75 − 2.625 15 + 2 1.65625− 3.875
x3 =
2
= = 4.225 x33 = = 2.8875
5 5 5
Matrix is diagonally dominant, Jacobi iterations are converging
Eyob A.
5. Gauss-Seidel iteration
0
an1 x1 + an 2 x2 + + ann xn = bn xn
1
x =
1
1 (b1 − a12 x20 − − a1n xn0 )
a11
1 i −1 n
bi − aij x j − aij x j
k +1 k +1
x12 =
1
(b2 − a21 x11 − a23 x30 − − a2 n xn0 ) x i = k
a22 aii j =1 j =i +1
1
xn =
1
(bn − an1 x11 − an 2 x12 − − ann −1 x1n −1 )
ann
Eyob A.
Gauss-Seidel Iteration… Example
4 − 1 1 x1 7 0
4
− 8 1 x2 = − 21 x 0 = 0 b − Ax 0 = 26.7395
2
7 + x20 − x30 7
x =
1
= = 1.75
1
4 4 b − Ax1 = 3.0414
2
21 + 4 x11 + x30 = 21 + 4 1.75 = 3.5
x2 =
1
8 8 b − Ax1 = 10.0452
15 + 2 x 1
− x 1 15 + 2 1.75 − 3.5 2
x3 =
1 1 2 = = 3.0
5 5
Jacobi iteration
Eyob A.
Gauss-Seidel Iteration… Example
Eyob A.
Errors in Jacobi’s and Gauss-Seidel Iteration
𝑥2 𝑘 − 𝑥2 𝑘−1 OR 𝑥2 𝑘+1 − 𝑥2 𝑘
𝑥3 𝑘 − 𝑥3 𝑘−1 OR 𝑥3 𝑘+1 − 𝑥3 𝑘
You can terminate after the approximation error is less than or equal to preset error
| ∈𝛂 ≤∈𝐬 |
Eyob A.