Lecture Note 2 Spring 20
Lecture Note 2 Spring 20
Lecture Note 2 Spring 20
Equivalent Systems: Two systems of equations are called equivalent if and only if they have
the same solution set.
Gaussian Elimination: The process which eliminates an unknown from succeeding equations
using elementary operations is known as Gaussian elimination.
The equation which is used to eliminate an unknown from the succeeding equations is known
as the pivotal equation. The coefficient of the eliminated variable in a pivotal equation is
known as the pivot. If the pivot is zero, it cannot be used to eliminate the variable from the
other equations. However, we can continue the elimination process by interchanging the
equation with a nonzero pivot.
A systematic procedure for solving a linear system is to reduce a system that is easier to solve.
One such system is the echelon form. The back substitution is then used to solve the system
in reverse order.
A systematic procedure for solving a linear system is to reduce a system that is easier to solve.
One such system is the upper triangular form. The back substitution is then used to solve the
system in reverse order.
Computers and calculators use fixed number of digits in its calculation and we may need to
round the numbers. This introduces error in the calculations. Also, when two nearly equal
numbers are subtracted, the accuracy in the calculation is lost. Consider the following example
to study the difficulty faced in the elimination method.
Page 1 of Lecture 2
Spring 2019-20
Example 2.1 :
The linear system
0.003 x+71 .08 y=71.11
4.23 x−8.16 y=34.14
has the exact solution x=10 and y=1 .
Solve the above system using four-digit arithmetic i.e. keeping 4 s.f. at each value by
(a) Gaussian elimination without changing the order.
(b) Gaussian elimination by interchanging the order of the equations.
Solution
Using four-digit arithmetic the system can be written as
0 .003000 x+71.08 y=71.11 (E1)
4.230 x−8.160 y=34.14 (E2)
This example shows that the order in which we treat the equations for elimination
affects the accuracy in the elimination process.
Page 2 of Lecture 2
Spring 2019-20
Page 3 of Lecture 2
Spring 2019-20
Iterative method for linear system is similar as the method of fixed-point iteration for an
equation in one variable. To solve a linear system by iteration, we solve each equation for one
of the variables, in turn, in terms of the other variables. Starting from an approximation to the
solution, if convergent, derive a new sequence of approximations. Repeat the calculations till
the required accuracy is obtained.
An iterative method converges, for any choice of the first approximation, if every equation
satisfies the condition that the magnitude of the coefficient of solving variable is greater than
the sum of the absolute values of the coefficients of the other variables. A system satisfying
this condition is called diagonally dominant. A linear system can always be reduced to
diagonally dominant by elementary operations.
In this method, a fixed set of values is used to calculate all the variables and then repeated for
the next iteration with the values obtained previously. The iterative formulas of the above
1
system are x n+1= ( 21−3 y n +2 z n )
10
−1
y n+ 1= ( 24−x n+ z n )
10
1
z n+1= ( 10−x n−2 y n )
10
Gauss-Seidel iterative method is more efficient than Jacobi’s iterative method and explained
through an example.
Page 4 of Lecture 2
Spring 2019-20
In this method, the values of each variable is calculated using the most recent approximations
to the values of the other variables. The Gauss-Seidel iterative formulas of the above system
1
are x n+1= ( 21−3 y n +2 z n )
10
−1
y n+ 1= ( 24−x n+1 + z n )
10
1
z n+1= ( 10−x n+1 −2 y n +1 )
10
If initial values are not supplied we can start with initial values
x 0=0 , y 0=0 , z 0=0.
and perform the iterations until required accuracy is achieved.
Solution:
a. Eq(2) 8 x−3 y +2 z=16 , ⌊ 8 ⌋ ≥ ⌊−3 ⌋+ ⌊ 2 ⌋
Eq(1)-Eq(2) −2 x+ 8 y+ z =−9 , ⌊ 8 ⌋ ≥ ⌊−2 ⌋ + ⌊ 1 ⌋
Eq(2)-Eq(3) −2 x+ 4 y +10 z=1 , ⌊ 10 ⌋ ≥ ⌊−2 ⌋ + ⌊ 4 ⌋
1
b. Gauss-Seidel formula x n+1= [ 16+3 y n−2 z n ]
8
1
y n+ 1=[−9+2 x n+1−z n ]
8
1
z n+1= [1+2 x n+1−4 y n +1 ]
10
1
When n=0, we have x 1= [ 16+3 (−1 ) −2 ( 1 ) ] =1.375
8
1
y 1= [− 9+2 (1.375 )−1 ] =−0.906
8
1
z 1= [ 1+2 (1.375 )−4 (−0.906 ) ]=0.737
10
1
For n=1, we have x ❑2= [ 16+3 (−0.906 )−2 ( 0.737 ) ] =1.476
8
1
y 2= [− 9+2 (1.476 )−−0.906 ] =−0.848
8
1
z 2= [ 1+2 (1.476 )−4 (−0.848 ) ]=0.734
10
Solution to 2 d.p. is x=1.48 , y=−0.85, z=0.73 .
Page 5 of Lecture 2
Spring 2019-20
d. >> x(1)=1.5;
>> y(1)=-1;
>> z(1)=1;
>> iter(1)=0;
>> for n=1:4
iter(n+1)=n;
x(n+1)=(16+3*y(n)-2*z(n))/8;
y(n+1)=(-9+2*x(n+1)-z(n))/8;
z(n+1)=(1+2*x(n+1)-4*y(n+1))/10;
end
>> Solution = [iter',x',y',z']
Solution =
0 1.5000 -1.0000 1.0000
1.0000 1.3750 -0.9063 0.7375
2.0000 1.4758 -0.8482 0.7345
3.0000 1.4983 -0.8422 0.7366
4.0000 1.5000 -0.8421 0.7368
Exercise-2
Page 6 of Lecture 2
Spring 2019-20
.
v. Write MATLAB codes to iterate the above formula four times.
4. Determine the loop currents I 1 , I 2∧I 3 of the given circuit by solving the linear system
using Gaussian elimination with pivoting.
For loop 1: I 1−I 2 + I 3=0
For loop 3: 2 I 2 + 4 I 3 =8
7. Tracy, Danielle and Sherri bought snacks for a birthday party. They each bought the items
shown in the following table at the local convenience store:
Page 7 of Lecture 2
Spring 2019-20
iv. Compute two iterations to estimate the roots to 2 d.p using the following initial values
x 0=0.2 , y 0=1.25∧z0 =165..
v. Justify your result by direct substitution in the original equations.
vi. Write MATLAB codes to iterate the above formula four times.
8. Jesse, Maria and Charles went to the local craft store to purchase supplies for making
decorations for the upcoming dance at the high school. Jesse purchased three sheets of craft
paper, four boxes of markers and five glue sticks. His bill, before taxes was $24.40. Maria
spent $30.40 when she bought six sheets of craft paper, five boxes of markers and two glue
sticks. Charles, purchases totaled $13.40 when he bought three sheets of craft paper, two
boxes of markers and one glue stick. Determine the unit cost of each item.
i. Construct the system of linear equation from the above problem.
ii. Solve the system of linear equation using Gaussian elimination with partial pivoting.
iii. Write MATLAB codes to solve by left division (backslash) operator.
9. Cory, Josh and Dan went shopping for Halloween treats. Cory bought 3 chocolate
pumpkins, 4 masks and 8 candy witches. He spent $36.65. Josh bought 5 chocolate pumpkins,
3 masks and 10 candy witches. He spent $37.50. Dan bought 4 chocolate pumpkins, 5 masks
and 6 candy witches. He spent $43.45.
10. A local computer company sells three types of laptop computers to three nearby
stores. The number of laptops ordered by each store and the amount owing to the
company for the order is shown in the following table:
Store Laptop A Laptop B Laptop C Amount
Owing($)
Wal-Mart 10 8 6 21 200
Sears 7 9 5 18 700
Target 8 4 3 13 000
12 Cory, Josh and Dan went shopping for Halloween treats. Cory bought 3 chocolate
. pumpkins, 4 masks and 8 candy witches. He spent $36.65. Josh bought 5 chocolate
pumpkins,3 masks and 10 candy witches. He spent $37.50. Dan bought 4
chocolate pumpkins, 5 masks and 6 candy witches. He spent $43.45. and
algebraically.
13. The following system of equations was generated by applying the mesh current law in the
circuit shown in the adjacent figure.
35 ( I 1−I 2 ) + 40 ( I 1 −I 3 ) =20 35 Ω I2
30 Ω
20 V 2Ω
35 ( I 2−I 1 ) +30 I 2+ 2 ( I 2−I 3 )=0 I1
40 ( I 3−I 1 ) +2 ( I 3 −I 2 ) + 45 I 3=0 40 Ω I3 45 Ω
iii. Compute one iterations to estimate the solutions to 2 d.p. with x 0=1.4 , y 0=1.2,
¿ z 0=0.2 .
Page 9 of Lecture 2
Spring 2019-20
Page 10 of Lecture 2