Skip to main content

Section 2.2 Introduction to Linear Systems

Subsection 2.2.1 How linear systems occur

Linear systems of equations naturally occur in many places in engineering, such as structural analysis, dynamics and electric circuits. Computers have made it possible to quickly and accurately solve larger and larger systems of equations. Not only has this allowed engineers to handle more and more complex problems where linear systems naturally occur, but has also prompted engineers to use linear systems to solve problems where they do not naturally occur such as thermodynamics, internal stress-strain analysis, fluids and chemical processes. It has become standard practice in many areas to analyze a problem by transforming it into a linear systems of equations and then solving those equation by computer. In this way, computers have made linear systems of equations the most frequently used tool in modern engineering.
In Figure 2.2.1 we show a truss with equilateral triangles. In Statics you may use the “method of joints” to write equations for each node of the truss
 1 
See http://en.wikipedia.org/wiki/Truss or http://en.wikibooks.org/wiki/Statics for reference.
. This set of equations is an example of a linear system. Making the approximation \(\sqrt{3}/2 \approx .8660\text{,}\) the equations for this truss are
\begin{equation} \begin{split}.5 \, T_{1} + T_{2}&= R_{1} = f_{1} \\ .866 \, T_{1}&= - R_{2} = -.433 \, f_{1} - .5 \, f_{2} \\ -.5 \, T_{1} + .5 \, T_{3} + T_{4}&= - f_{1} \\ .866 \, T_{1} + .866 \, T_{3}&= 0 \\ -T_{2} - .5 \, T_{3} + .5 \, T_{5} + T_{6}&= 0 \\ .866 \, T_{3} + .866 \, T_{5}&= f_{2} \\ -T_{4} - .5 \, T_{5} + .5 \, T_{7}&=0, \\\end{split}\tag{2.2.1} \end{equation}
where \(T_{i}\) represents the tension in the \(i\)-th member of the truss.

Diagram of an equilateral truss.🔗
Figure 2.2.1. An equilateral truss. Joints or nodes are labeled alphabetically, \(A\text{,}\) \(B\text{,}\) … and Members (edges) are labeled numerically: \(1\text{,}\) \(2\text{,}\) …. The forces \(f_{1}\) and \(f_{2}\) are applied loads and \(R_{1}\text{,}\) \(R_{2}\) and \(R_{3}\) are reaction forces applied by the supports.
You could solve this system by hand with a little time and patience; systematically eliminating variables and substituting. Obviously, it would be a lot better to put the equations on a computer and let the computer solve it. In the next few sections we will learn how to use a computer effectively to solve linear systems. The first key to dealing with linear systems is to realize that they are equivalent to matrices, which contain numbers, not variables.
As we discuss various aspects of matrices, we wish to keep in mind that the matrices that come up in engineering systems are really large. It is not unusual in real engineering to use matrices whose dimensions are in the thousands! It is frequently the case that a method that is fine for a \(2 \times 2\) or \(3 \times 3\) matrix is totally inappropriate for a \(2000 \times 2000\) matrix. We thus want to emphasize methods that work for large matrices.

Subsection 2.2.2 Linear systems are equivalent to matrix equations

The system of linear equations
\begin{equation*} \begin{split}x_{1} - 2 x_{2} + 3 x_{3}&= 4 \\ 2 x_{1} - 5x_{2} + 12 x_{3}&= 15 \\ 2 x_{2} - 10 x_{3}&= -10\end{split} \end{equation*}
is equivalent to the matrix equation
\begin{equation*} \left(\begin{array}{ccc}1 & -2 & 3 \\ 2 & -5 & 12 \\ 0 & 2 & -10\end{array}\right) \left(\begin{array}{c}x_1 \\ x_2 \\ x_3\end{array} \right) = \left(\begin{array}{c}4\\ 15 \\ -10\end{array} \right)\text{,} \end{equation*}
which is equivalent to the augmented matrix
\begin{equation*} \left(\begin{array}{ccc|c}1 & -2 & 3 & 4 \\ 2 & -5 & 12 & 15 \\ 0 & 2 & -10 & -10\end{array}\right)\text{.} \end{equation*}
The advantage of the augmented matrix, is that it contains only numbers, not variables. The reason this is better is because computers are much better in dealing with numbers than variables. To solve this system, the main steps are called Gaussian elimination and back substitution.
The augmented matrix for the equilateral truss equations (2.2.1) is given by
\begin{equation} \left(\begin{array}{ccccccc|c}.5 & 1 & 0 & 0 & 0 & 0 & 0 & f_1 \\ .866 & 0 & 0 & 0 & 0 & 0 & 0 & -.433 f_1 - .5 \, f_2 \\ -.5 & 0 & .5 & 1 & 0 & 0 & 0 & - f_1 \\ .866 & 0 & .866 & 0 & 0 & 0 & 0 & 0 \\ 0 & -1 & - .5 & 0 & .5 & 1 & 0 & 0 \\ 0 & 0 & .866 & 0 & .866 & 0 & 0 & f_2 \\ 0 & 0 & 0 & -1 & - .5 &0 & .5 & 0 \\\end{array}\right)\text{.}\tag{2.2.2} \end{equation}
Notice that a lot of the entries are \(0\text{.}\) Matrices like this, called sparse, are common in applications and there are methods specifically designed to efficiently handle sparse matrices.

Subsection 2.2.3 Triangular matrices and back substitution

Consider a linear system whose augmented matrix happens to be
\begin{equation} \left(\begin{array}{ccc|c}1 & -2 & 3 & 4 \\ 0 & -1 & 6 & 7 \\ 0 & 0 & 2 & 4\end{array}\right)\text{.}\tag{2.2.3} \end{equation}
Recall that each row represents an equation and each column a variable. The last row represents the equation \(2 x_{3} = 4\text{.}\) The equation is easily solved, i.e. \(x_{3} = 2\text{.}\) The second row represents the equation \(- x_{2} + 6 x_{3} = 7\text{,}\) but since we know \(x_{3} = 2\text{,}\) this simplifies to: \(- x_{2} + 12 = 7\text{.}\) This is easily solved, giving \(x_{2} = 5\text{.}\) Finally, since we know \(x_{2}\) and \(x_{3}\text{,}\) the first row simplifies to: \(x_{1} - 10 + 6 = 4\text{.}\) Thus we have \(x_{1} = 8\) and so we know the whole solution vector: \(\xb = \langle 8 , 5, 2 \rangle\text{.}\) The process we just did is called back substitution, which is both efficient and easily programmed. The property that made it possible to solve the system so easily is that \(A\) in this case is upper triangular. In the next section we show an efficient way to transform an augmented matrix into an upper triangular matrix.

Subsection 2.2.4 Gaussian Elimination

Consider the matrix
\begin{equation*} A = \left(\begin{array}{ccc|c}1 & -2 & 3 & 4 \\ 2 & -5 & 12 & 15 \\ 0 & 2 & -10 & -10\end{array}\right)\text{.} \end{equation*}
The first step of Gaussian elimination is to get rid of the 2 in the (2,1) position by subtracting \(2\) times the first row from the second row, i.e. (new 2nd = old 2nd - (2) 1st). We can do this because it is essentially the same as adding equations, which is a valid algebraic operation. This leads to
\begin{equation*} \left(\begin{array}{ccc|c}1 & -2 & 3 & 4 \\ 0 & -1 & 6 & 7 \\ 0 & 2 & -10 & -10\end{array}\right)\text{.} \end{equation*}
There is already a zero in the lower left corner, so we don’t need to eliminate anything there. To eliminate the third row, second column, we need to subtract \(-2\) times the second row from the third row, (new 3rd = old 3rd - (-2) 2nd), to obtain
\begin{equation*} \left(\begin{array}{ccc|c}1 & -2 & 3 & 4 \\ 0 & -1 & 6 & 7 \\ 0 & 0 & 2 & 4\end{array}\right)\text{.} \end{equation*}
This is now just exactly the matrix in equation (2.2.3), which we can now solve by back substitution.

Subsection 2.2.5 MATLAB’s matrix solve command

In MATLAB the standard way to solve a system \(A \xb = \bb\) is by the command
>> x = A \ b
This syntax is meant to suggest dividing by \(A\) from the left as in
\begin{equation*} A \xb = \bb \quad \Leftrightarrow\quad A\backslash A \xb = A\backslash \bb \quad \Leftrightarrow\quad \xb = A\backslash \bb \text{.} \end{equation*}
Such division is not meaningful mathematically, but it helps for remembering the syntax.
This command carries out Gaussian elimination and back substitution. We can do the above computations as follows:
>> A = [1 -2 3 ; 2 -5 12 ; 0 2 -10] b = [4 15 -10]' x = A  b
Next, use the MATLAB commands above to solve \(A \xb = \bb\) when the augmented matrix for the system is
\begin{equation*} \left(\begin{array}{ccc|c}1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \\ 9 & 10 & 11 & 12\end{array}\right)\text{,} \end{equation*}
by entering
>> x1 = A  b
Check the result by entering
>> A*x1 - b
You will see that the resulting answer satisfies the equation exactly. Next try solving using the inverse of \(A\text{:}\)
>> x2 = inv(A)*b
This answer can be seen to be inaccurate by checking
>> A*x2 - b
Thus we see one of the reasons why the inverse is never used for actual computations, only for theory.

Exercises 2.2.6 Exercises

1.

Set \(f_{1} = 1000N\) and \(f_{2} = 5000N\) in the equations (2.2.1) for the equailateral truss. Input the coefficient matrix \(A\) and the right hand side vector \(b\) in (2.2.2) into MATLAB. Solve the system using the command \ to find the tension in each member of the truss. Save the matrix \(A\) as A_equil_truss and keep it for later use. (Enter save A_equil_truss A.) Print out and turn in \(A\text{,}\) \(\bb\) and the solution \(\xb\text{.}\)

2.

Write each system of equations as an augmented matrix. By hand, find the solutions using Gaussian elimination and back substitution (i.e. the exact algorithm in this section). Check your solutions using MATLAB.
  1. \begin{equation*} \begin{split}x_{1} + x_{2}&= 2 \\ 4 x_{1} + 5 x_{2}&= 10\end{split} \end{equation*}
  2. \begin{equation*} \begin{split}x_{1} + 2 x_{2} + 3 x_{3}&= -1 \\ 4 x_{1} + 7 x_{2} + 14 x_{3}&= 3 \\ x_{1} + 4 x_{2} + 4 x_{3}&= 1\end{split} \end{equation*}