You are on page 1of 16

MATH1853 Maths I

System of Linear Equations


Dr. Ngai WONG
Fall 2018
You MUST attend lectures
• Reasons:
1. (disclosed during lecture)
2. (disclosed during lecture)
3. (disclosed during lecture)
4. (disclosed during lecture)
5. Notes + self-study gives you a pass, but
for high marks you need the human touch, i.e.,
lectures.
1
Crash slide on data structures
• Scalar, vector, matrix, and beyond?

• Addition, multiplication of
{scalar,vector,matrix}×{scalar,vector,matrix}
• Examples:
2
System of linear equations
• A simple example:  x − 2 x = −1
⇒ x1 = 3, x2 = 2
1 2

− x1 + 3 x2 =
3

• Physical meaning: Solution is


the intersection point of two
lines
• Other possibilities: No solution
or infinitely many solutions

3
• Example of three equations, three unknown  x1 − 2 x2 + x3 =0 (1)

systems:  2 x2 − 8 x3 =
8 (2)
−4 x + 5 x + 9 x = −9
• Each equation is a plane  1 2 3
(3)
• The solution is the intersection of three
planes
• But how to solve it? Elimination procedure 4 x1 − 8 x2 + 4 x3 =
0
– Step 1: 4´(1)+(3), we obtain eq. (4) −4 x1 + 5 x2 + 9 x3 =
−9
− 3 x2 + 13 x3 =
−9 (4)
3 x2 − 12 x3 =
12
– Step 2: 1.5´(2)+(4), we obtain −3 x + 13 x =−9
2 3

x3 = 3

– Step 3: Putting x3=3 into (2) to get x2=16


– Step 4: Putting x3=3, x2=16 into (1) to get
x1=29

4
• The above example shows the system of linear equations has one
solution
• But as in two equations, two unknowns case, there can be no
solution or multiple solutions
• Example: Determine the solution of
=
2 x1 − 3 x2 + 2 x3 1 (1) =  2 x1 − 3 x2 + 2 x3 1 (1)
 −5/ 2×(1) + (3) 
 =x2 − 4 x3 8 (2)  → =x2 − 4 x3 8 (2)
5x − 8x + 7 x = −(1/ 2) x + 2 x = −3 / 2
 1 2 3 1 (3)  2 3 (4)
 2 x1 − 3 x2 + 2 x3 =1 (1)
1/ 2×(2) + (4) 
→  x2 − 4 x3 =8 (2)
0 x + 0 x + 0 x =
 1 2 3 5/ 2 (5)

– There is no value of x1, x2 and x3 that will satisfy the last equation ⇒ no
solution

• Remark:
– A system of linear equations is said to be inconsistent if it has no
solution
– Conversely, a system of equations is called consistent if there is at
least one solution

5
• General system of linear equations:
a11 x1 + a12 x2 +  + a1n xn = b1
a x + a x +  + a x =
 21 1 22 2 b2

2n n

 
am1 x1 + am 2 x2 +  + amn xn = bm

• bi and coefficients aij are real or complex numbers, usually known in


advance
• We need to solve for x1,…,xn
• In general, it is not necessary to have the number of equations equal
the number of unknowns (although our two previous examples have
m=n)
• Note that= 4 x1 − 5 x2 x1 x2 and
= x2 + 6 2 x1 are not linear equations
• Question 1: how can we solve the system of linear equations if m
and n are large?
• Question 2: how do we know if the system has one solution, no
solution or multiple solutions?
6
Gaussian Elimination
• The above two examples on three equations, three unknowns
system of equations give us a rough idea on how to solve for a
general system of linear equations
• In particular, the following operations (called elementary row
operations) will not change the solution of the system of equations:
– Interchange two rows
– Multiply all entries in a row by a nonzero constant
– Replace one row by the sum of itself and a multiple of another row
• In Gaussian elimination, we use the elementary row operations to
reduce the system of linear equations into a “triangular” form
• For the example on p.4, we can write the operations as
 x1 − =
2 x2 + x3 0  x1 − =
2 x2 + x3 0  x1 − =
2 x2 + x3 0
  
 2 x2 − 8 x3 =8 
→  2 x2 − 8 x3 =8  →  2 x2 − 8 x3 =8
−4 x + 5 x + 9 x = −9  −3 x + 13 x = −9  x3 =
 1 2 3  2 3  3

7
• Another more commonly used shorthand notation when applying
Gaussian elimination is to write the system of equations in an
augmented matrix form
• For the previous example, therefore, we can also write
1 -2 1 0  1 -2 1 0  1 -2 1 0 
     
 0 2 -8 8  
→  0 2 -8 8  
→  0 2 -8 8 
 -4 5 9 −9   0 -3 13 −9   0 0 1 3
     
• Concept of pivot goes here!
• The “triangular” form is more apparent in this notation. In addition to
“triangular” form, sometimes, we will get a “step-like” pattern that
moves down and to the right, e.g.,

 represents nonzero value, * may have any value (including zero)


• Formally, this is called an echelon form (triangular form is a special
case of echelon form) 8
• Example: In electric circuit analysis, you often come across system
of linear equations. For example, in order to analyze the circuit
shown below, we need to solve (you don’t really need to know how
to get the equations from the circuit)
 5v1 + v2 − v3 − 2v4 =
60 (1)
4 + 2 − 5 − 16 =
 v1 v2 v3 v4 0 (2)

 v1 − v2 =
20 (3)
 3v1 − v3 − 2v4 =
0 (4)

– We use Gaussian elimination (written in the augmented matrix form):


0 20  -5 × 1st row + 2rd row 1
st nd
5 1 -1 -2 60  1 -1 0 -1 0 0 20 
  move row 3   -4 × 1 row + 3 row   move row 4
4 2 -5 -16 0 
→ 
to the top 5 1 -1 -2 60  -3 × 1st row + 4th row  0
 →
6 -1 -2 -40  to row 2
 →
1 -1 0 0 20  4 2 -5 -16 0  0 6 -5 -16 -80 
     
3 0 -1 -2 0  3 0 -1 -2 0  0 3 -1 -2 -60 
1 -1 0 0 20  1 -1 0 0 20  1 -1 0 0 20 
  -2 × 2nd row + 3th row    
nd rd

0 3 -1 -2 -60  -2 × 2 row + 4 row  0


 →
3 -1 -2 -60  3 × 3rd row + 4th row  0
 →
3 -1 -2 -60 
0 6 -1 -2 -40  0 0 1 2 80  0 0 1 2 80 
     
0 6 -5 -16 -80  0 0 -3 -12 40  0 0 0 -6 280 

These steps are NOT the unique combo! 9


– The last matrix is in echelon form v1 − v2 + 0v3 + 0v4 =
20

 3v2 − v3 − 2v4 =−60
– If we put the matrix back to equations, we have 
 v3 + 2v4 =
80
 −6v4 =
280
– The last equation above would give v4=-46.66
– Then substitute v4=-46.66 into the third equation, we have v3=173.33
– Putting v4=-46.66 and v3=173.33 into the second equation gives v2=6.667
– Finally, putting v4, v3 and v2 into the first equation, we have v1=26.66
• The last four steps are called backward substitution
• Example: Find the solution of the system of equations with the
following augmented matrix representation:
0 -3 -6 4 9 1 4 5 -9 -7  1 4 5 -9 -7 
  interchange   row 1 + row 2  
 -1 -2 -1 3 1  row 4 and row 1  -1
 →
-2 -1 3 1  2 × row 1+ row 3  0 2 4 -6 -6 
→
 -2 -3 0 3 -1   -2 -3 0 3 -1   0 5 10 -15 -15 
     
1 4 5 -9 -7  0 -3 -6 4 9   0 -3 -6 4 9 
1 4 5 -9 -7  1 4 5 -9 -7 

−5 / 2× row 2 + row 3 interchange  
0 2 4 -6 -6  row 4 with row 3  0 2 4 -6 -6 
3/2 × row 2+ row 4

→  →
0 0 0 0 0   0 0 0 -5 0 
   
 0 0 0 -5 0   0 0 0 0 0 
10
– Now, we perform backward substitution, by writing out explicitly the
equations  x + 4 x + 5 x − 9 x =
−7
1 2 3 4

 2 x2 + 4 x3 − 6 x4 =
−6

 − 5 x4 =
0
 0=0

– The fourth equation will be satisfied by any choice of x1, x2, x3, x4
– From the third equation, we have x4=0
– Putting x4=0 into the second equation, we obtain x2 = -3-2x3
– Then putting x4=0 and x2 = -3-2x3 into the first equation, we can obtain
x1 = 5+3x3
– We can see that there is no constraint on x3, therefore x3 can be treated
as a free variable
– We have more than one solution and the solution can be written as
 x1= 5 + 3 x3

 x2 =−3 − 2 x3

 x3 is free
 x4 = 0

– Another way is to treat x2 as a free variable and express the solution in


terms of x2
11
Existence and Uniqueness of Solution
• From the above two examples, we see that Gaussian elimination
automatically tells us whether we have unique solution (first
example) or infinitely many solutions (second example)
• On the other hand, on p.5, we have seen one example in which
there is no solution
• In general, during the process of Gaussian elimination, if we obtain
an equation 0=b where b is nonzero, then there is no solution for the
system of equations
• Summary of solving a system of linear equations:
– Write the system of linear equations in an augmented matrix form
– Use elementary row operations to reduce the matrix to an echelon form
– If there is at least one row containing 0=b where b is not zero, then there
is no solution
– Otherwise, the system is consistent
• If there is no free variable, the solution is unique
• If there is at least one free variable, there are infinitely many solutions
12
Applications
• Example: A simple Economy
– Suppose there are three companies (Coal,
Electric, Steel) and their outputs will be
completely consumed by each other
– Let pC, pE and pS be the total dollar values of
coal, electricity and steel being produced
– Find the equilibrium prices that make each
sector’s income match its expenditures
– The Coal’s total expenses are 0.4pE+0.6pS
– The value of coal it produces is pC
– Therefore we have pC= 0.4pE+0.6pS
– Similarly, we can set up linear equations for the
companies of Electric and Steel
– The set of equations to be solved is
 pC − 0.4 pE − 0.6 pS =
0

By Gaussian elimination,
 pC = 0.94 pS
−0.6 pC + 0.9 pE − 0.2 pS =0 the solution is

 −0.4 p − 0.5 p + 0.8 p =  pE = 0.85 pS
 C E S 0  p is free
 S 13
• Example: Balancing chemical equation
– Suppose a chemical reaction exists with equation
( x1 )C3 H8 + ( x2 )O 2 → ( x3 )CO 2 + ( x4 )H 2 O
– We want to determine x1, x2, x3, x4 such that the number of atoms of
each type will be the same on both sides
– For carbon, we have 3x1=x3
– For hydrogen, we have 8x1=2x4
– For oxygen, we have 2x2=2x3+x4
– Putting together, we have a system of linear equations
 3 x1 + 0 ⋅ x2 − x3 + 0 ⋅ x4 = 0 By Gaussian elimination,  x1 = (1/ 4) x4
  x = (5 / 4) x
8 x1 + 0 ⋅ x2 + 0 ⋅ x3 − 2 x4 =0
the solution is
 2 4

 0 ⋅ x + 2x − 2x − x =
 1 2 3 4 0  x3 = (3 / 4) x4
 x4 is free

14
• Example: Traffic flow
– Suppose the vehicles per hour over several
streets are given on the right
– We want to determine the unknowns x1, x2, x3, x4
– We make use of the fact that at each intersection,
the traffic flow in must be equal to the flow out
– At intersection A, we have 300+500 = x1+ x2
– At intersection B, we have x2 + x4 = 300+ x3
– We can also set up equations for intersections C
and D
– Finally, we also have total traffic into the network
must equal total traffic out of the network:
(500+300+100+400)=(300+600+x3)
– Putting all the equations together, we have

 x1 + x2 =
800 = x1 600 − x5
 By Gaussian elimination, 
 x2 − x3 + x4 =
300 the solution is = x2 200 + x5
 
 x4 + x5 =
500  x3 = 400
x + x5 =
600 = x 500 − x5
 1  4
 x3 = 400  x5 is free
15

You might also like