7 2 Matrix Multiplication
7 2 Matrix Multiplication
Introduction
Engineers often need to solve large systems of linear equations; for example in determining the forces
in a large framework or finding currents in a complicated electrical circuit. The method of Gauss
elimination provides a systematic approach to their solution.
22 HELM (2008):
Workbook 8: Matrix Solution of Equations
®
Task
Solve the equations
2 0 0 x1 8
0 −1 0 x2 = 2 .
0 0 3 x3 −6
Your solution
Answer
[x1 , x2 , x3 ]T = [4, −2, −2]T .
The next easiest system of equations to solve is of the following kind:
3x1 + x2 − x3 = 0
2x2 + x3 = 12
3x3 = 6.
The last equation can be solved immediately to give x3 = 2.
Substituting this value of x3 into the second equation gives
2x2 + 2 = 12 from which 2x2 = 10 so that x2 = 5
Substituting these values of x2 and x3 into the first equation gives
3x1 + 5 − 2 = 0 from which 3x1 = −3 so that x1 = −1
Hence the solution is [x1 , x2 , x3 ]T = [−1, 5, 2]T .
This process of solution is called back-substitution.
In matrix form the system of equations is
3 1 −1 x1 0
0 2 1 x2 = 12 .
0 0 3 x3 6
HELM (2008): 23
Section 8.3: Solution by Gauss Elimination
The matrix of coefficients is said to be upper triangular because all elements below the leading
diagonal are zero. Any system of equations in which the coefficient matrix is triangular (whether
upper or lower) will be particularly easy to solve.
Task
Solve the following system of equations by back-substitution.
2 −1 3 x1 7
0 3 −1 x2 = 5 .
0 0 2 x3 2
Answer
2x1 − x2 + 3x3 = 7
3x2 − x3 = 5
2x3 = 2
Answer
The last equation can be solved immediately to give x3 = 1.
Using this value for x3 , obtain x2 and x1 :
Your solution
x2 = x1 =
Answer
x2 = 2, x1 = 3. Therefore the solution is x1 = 3, x2 = 2 and x3 = 1.
Although we have worked so far with integers this will not always be the case and fractions will enter
the solution process. We must then take care and it is always wise to check that the equations
balance using the calculated solution.
24 HELM (2008):
Workbook 8: Matrix Solution of Equations
®
HELM (2008): 25
Section 8.3: Solution by Gauss Elimination
Stage 2: Triangularisation
The second stage proceeds by first eliminating x1 from the second and third equations using row
operations.
1 3 5 14 1 3 5 14
2 −1 −3 3 R2 − 2 × R1 ⇒ 0 −7 −13 −25
4 5 −1 7 R3 − 4 × R1 0 −7 −21 −49
In the above we have subtracted twice row (equation) 1 from row (equation) 2.
In full these operations would be written, respectively, as
(2x1 − x2 − 3x3 ) − 2(x1 + 3x2 + 5x3 ) = 3 − 2 × 14 or −7x2 − 13x3 = −25
and
(4x1 + 5x2 − x3 ) − 4(x1 + 3x2 + 5x3 ) = 7 − 4 × 14 or −7x2 − 21x3 = −49.
Now since all the elements in rows 2 and 3 are negative we multiply throughout by −1:
1 3 5 14 1 3 5 14
0 −7 −13 −25 R2 × (−1) ⇒ 0 7 13 25
0 −7 −21 −49 R3 × (−1) 0 7 21 49
Finally, we eliminate x2 from the third equation by subtracting equation 2 from equation 3
i.e. R3 − R2:
1 3 5 14 1 3 5 14
0 7 13 25 ⇒ 0 7 13 25
0 7 21 49 R3 − R2 0 0 8 24
The system is now in triangular form.
Stage 3: Back Substitution
Here we solve the equations from bottom to top. At each step of the back substitution process we
encounter equations which only have a single unknown and so can be easily solved.
Task
Now complete the solution to the above system by back-substitution.
Your solution
26 HELM (2008):
Workbook 8: Matrix Solution of Equations
®
Answer
In full the equations are
x1 + 3x2 + 5x3 = 14
7x2 + 13x3 = 25
8x3 = 24
Task
Solve
Write down the augmented matrix for this system and then interchange rows 1 and 3:
Your solution
Answer
Augmented
matrix
2 −3 4 2 R1 ↔ R3 1 −1 3 3
4 1 2 2 ⇒ 4 1 2 2
1 −1 3 3 2 −3 4 2
Now subtract suitable multiples of row 1 from row 2 and from row 3 to eliminate the x1 coefficient
from rows 2 and 3:
Your solution
Answer
1 −1 3 3 1 −1 3 3
4 1 2 2 R2 − 4R1 ⇒ 0 5 −10 −10
2 −3 4 2 R3 − 2R1 0 −1 −2 −4
HELM (2008): 27
Section 8.3: Solution by Gauss Elimination
Now divide row 2 by 5 and add a suitable multiple of the result to row 3:
Your solution
Answer
1 −1 3 3 1 −1 3 3 1 −1 3 3
0 5 −10 −10 R2 ÷ 5 ⇒ 0 1 −2 −2 ⇒ 0 1 −2 −2
0 −1 −2 −4 0 −1 −2 −4 R3 + R2 0 0 −4 −6
Answer
The equations in full are
x1 − x2 + 3x3 = 3
x2 − 2x3 = −2
−4x3 = −6.
You should check these values in the original equations to ensure that the equations balance.
Again we emphasise that we chose a particular set of procedures in Stage 1. This was chosen mainly
to keep the arithmetic simple by delaying the introduction of fractions. Sometimes we are courageous
and take fewer, harder steps.
An important point to note is that when in Stage 2 we wrote R2 − 2R1 against row 2; what we
meant is that row 2 is replaced by the combination (row 2) − 2×(row 1).
In general, the operation
row i − α × row j
means replace row i by the combination
row i − α × row j.
28 HELM (2008):
Workbook 8: Matrix Solution of Equations
®
x1 + x2 − 3x3 = 3
2x1 − 3x2 + 4x3 = −4
x1 − x2 + x3 = −1
Systems of linear equations arise in the modelling of electrical circuits or networks. By breaking
down a complicated system into simple loops, Kirchhoff’s law can be applied. This leads to a set of
linear equations in the unknown quantities (usually currents) which can easily be solved by one of
the methods described in this Workbook.
HELM (2008): 29
Section 8.3: Solution by Gauss Elimination
Engineering Example 3
4v
2Ω 3Ω
i1 i2
5v 6Ω
4Ω
i3
6v
Figure 2
Solution
Loop 1 gives
2(i1 ) + 3(i1 − i2 ) = 5 → 5i1 − 3i2 = 5
Loop 2 gives
6(i2 − i3 ) + 3(i2 − i1 ) = 4 → −3i1 + 9i2 − 6i3 = 4
Loop 3 gives
6(i3 − i2 ) + 4(i3 ) = 6 − 5 → −6i2 + 10i3 = 1
Note that in loop 3, the current generated by the 6v cell is positive and for the 5v cell negative in
the direction of the arrow.
In matrix form
5 −3 0 i1 5
−3 9 −6 i2 = 4
0 −6 10 i3 1
Solving gives
34 19 41
i1 = , i2 = , i3 =
15 9 30
30 HELM (2008):
Workbook 8: Matrix Solution of Equations
®
Engineering Example 4
Velocity of a rocket
The upward velocity of a rocket, measured at 3 different times, is shown in the following table
Time, t Velocity, v
(seconds) (metres/second)
5 106.8
8 177.2
12 279.2
The velocity over the time interval 5 ≤ t ≤ 12 is approximated by a quadratic expression as
v(t) = a1 t2 + a2 t + a3
Find the values of a1 , a2 and a3 .
Solution
Substituting the values from the table into the quadratic equation for v(t) gives:
106.8 = 25a1 + 5a2 + a3 25 5 1 a1 106.8
177.2 = 64a1 + 8a2 + a3 or 64 8 1 a2 = 177.2
279.2 = 144a1 + 12a2 + a3 144 12 1 a3 279.2
Applying one of the methods from this Workbook gives the solution as
a1 = 0.2905 a2 = 19.6905 a3 = 1.0857 to 4 d.p.
As the original values were all experimental observations then the values of the unknowns are all
approximations. The relation v(t) = 0.2905t2 + 19.6905t + 1.0857 can now be used to predict the
approximate position of the rocket for any time within the interval 5 ≤ t ≤ 12.
HELM (2008): 31
Section 8.3: Solution by Gauss Elimination
Exercises
Solve the following using Gauss elimination:
1.
2x1 + x2 − x3 = 0
x1 + x3 = 4
x1 + x2 + x3 = 0
2.
x1 − x2 + x3 = 1
−x1 + x3 = 1
x1 + x2 − x3 = 0
3.
x1 + x2 + x3 = 2
2x1 + 3x2 + 4x3 = 3
x1 − 2x2 − x3 = 1
4.
x1 − 2x2 − 3x3 = −1
3x1 + x2 + x3 = 4
11x1 − x2 − 3x3 = 10
You may need to think carefully about this system.
Answers
8 4
(1) x1 = , x2 = −4, x3 =
3 3
1 3
(2) x1 = , x2 = 1, x3 =
2 2
(3) x1 = 2, x2 = 1, x3 = −1
32 HELM (2008):
Workbook 8: Matrix Solution of Equations