Section 1.4

Solving Systems of Linear Equations

Introduction

In this section we shall consider systems of linear equations and analyze their solution set.

Systems of linear equations arise in the mathematical modeling of many problems.

> with(linalg): with(linsys);

>

Systems of Linear Equations

Let us begin with some examples of two equations with two unknowns

Example 1: Consider the system of two equations with two unknowns:

> eq1:= x+y =2: eq2:=x -2*y=4: print(eq1); print(eq2);

>

Let us check graphically whether this system has a solution:

> graph(eq1,eq2);

```Warning, the name changecoords has been redefined
```

`   I am working on graphs.....`

>

>

In this example, the system has a unique solution.

Example 2: Consider the system of two equations with two unknowns:

> eq1:= x+ 2*y =2: eq2:=2*x +4*y=4: print(eq1); print(eq2);

>

Let us check graphically whether this system has a solution:

> graph(eq1,eq2);

`   I am working on graphs.....`

>

>

In this example, the system has infinitely many solutions.

Example 3: Consider the system of two equations with two unknowns:

> eq1:= x+2*y =2: eq2:=x+2* y=8: print(eq1); print(eq2);

>

Let us check graphically whether this system has a solution:

> graph(eq1,eq2);

`   I am working on graphs.....`

>

>

In this example, the system has no solution.

The same graphing technique can be applied for a system with three unknowns:

Example 4: Consider the system of three equations with three unknowns:

> eq1:= x+y +z =2: eq2:=x -2*y -z=4: eq3:=x-y-z=1: print(eq1); print(eq2); print(eq3);

>

Let us check graphically whether this system has a solution:

> graph(eq1,eq2,eq3);

`   I am working on graphs...`

>

>

In this example, the system has a unique solution.

Example 5: Consider the system of three equations with three unknowns:

> eq1:= x+y +z =2: eq2:=x +y +z=2: eq3:=x-y-z=1: print(eq1); print(eq2); print(eq3);

>

Let us check graphically whether this system has a solution:

> graph(eq1,eq2,eq3);

`   I am working on graphs...`

>

>

In this example, the system has infinitely many solutions.

Example 6: Consider the system of two equations with three unknowns:

> eq1:= x+y +z =2: eq2:=x +y +z=10: print(eq1); print(eq2);

>

Let us check graphically whether this system has a solution:

> graph(eq1,eq2);

`   I am working on graphs...`

>

>

In this example, the system has no solution.

***************************************************************

The above examples show that one of the following must hold for a system

of linear equations:

. The system has a unique solution

. The system has infinitely many solutions

. The system has no solution

A linear system having no solutions is inconsistent . If it has one or more solutions,

the linear system is said to be consistent.

***************************************************************

In general, a system of m equations in n unknowns variables ( i=1..n ) is of the form :

+ ........ + =

+ ........ + =

+ ........ + =

.............

+ ........ + =

where the 's are the coefficients of the unknown variables and the 's are known quantities.

If the number of equations ( m ) is equal to the number of variables ( n ), the system is a square

system. If all the 's are equal to zero, the system is called a Homogeneous System ;

otherwise, it is called a Nonhomogeneous System .

********************************************************************

Equivalent Systems

Example 7: Consider the following two systems of linear equations

System consists of the equations:

> eq1:= x+y+z=1: eq2:= 2*x +3*y-z=2: eq3:=x +y + 2*z=3:

> print(eq1); print(eq2); print(eq3);

>

System consists of the equations:

> eq11:= x+y+z=1: eq22:= y-3*z = 0: eq33:= z = 2:

> print(eq11); print(eq22); print(eq33);

The solution of the system :

> solveqns({eq1,eq2,eq3},{x,y,z});

`Select one of the following modes`

`     1. Demonstration mode`

`     2. No-Step mode`

2;

>

The solution of the system is:

> solveqns({eq11,eq22,eq33},{x,y,z});

`Select one of the following modes`

`     1. Demonstration mode`

`     2. No-Step mode`

2;

>

Systems and have the same solution. System is easier to solve than system .

Indeed by substituting the value z = 2 into we find y , and then by substituting the

values of z and y into we find x.

***********************************************************************

Systems that have the same solution set are called Equivalent Systems .

***********************************************************************

Elementary Row Operations

1. Will the solution set of a system change upon multiplying one of its equations by

a nonzero scalar?

Example 8: Consider the system consisting of

> eq1:= x+2*y=3: print(eq1);

and the system consisting of the multiple of

> eq2:=3*x+6*y=9: print(eq2);

Check graphically whether the two systems have the same solution set

> graph(eq1,eq2);

`   I am working on graphs.....`

>

>

The above graph implies that the two lines overlap. Thus the two systems have the same

solution set.

Check algebraically

> solveqns(eq1,{x,y});

`Select one of the following modes`

`     1. Demonstration mode`

`     2. No-Step mode`

2;

>

> solveqns(eq2,{x,y});

`Select one of the following modes`

`     1. Demonstration mode`

`     2. No-Step mode`

2;

>

********************************************************************************

I.) Multiplying an equation of a system of linear equations by a nonzero scalar yields an equivalent equation.

********************************************************************************

2. Will the solution set of a system of linear equations change if two equations are interchanged?

Example 9: Consider the system

> eq1:=x+y+3*z=4: eq2:=x-y+z=0: eq3:=x-y-z=10: print(eq1); print(eq2); print(eq3);

>

Interchange equation 2 and equation 3 of to get new system a

> eq11:=x+y+3*z=4: eq22:=x-y-z=10: eq33:=x-y+z=0: print(eq11); print(eq22); print(eq33);

>

Are systems and equivalent?

Check the solution set

> solveqns({eq1,eq2,eq3},{x,y,z});

`Select one of the following modes`

`     1. Demonstration mode`

`     2. No-Step mode`

2;

>

>

> solveqns({eq11,eq22,eq33},{x,y,z});

`Select one of the following modes`

`     1. Demonstration mode`

`     2. No-Step mode`

2;

>

Since they have the same solution, the two systems are equivalent.

*******************************************************************

II.) Interchanging equations of a system of linear equations yields an equivalent system

******************************************************************

3. Will the solution set of a system of linear equations change if we replace any equation

by the sum of that equation and a nonzero multiple of another equation?

Example 10: Consider the system

> eq1:=x-2*y=2: eq2:=x+3*y=1: print(eq1); print(eq2);

>

Obtain new system by multiplying eq1 of by 2 and adding it to eq2

> eq11:=x-2*y=2: eq22:=3*x- y=5: print(eq11); print(eq22);

Check graphically whether both systems have the same solution set

The graph of the system is

> graph(eq1,eq2);

`   I am working on graphs.....`

>

>

The graph of the system is

> graph(eq11,eq22);

`   I am working on graphs.....`

>

>

What do you conclude from the graphs of the two systems?

The graphs indicate that the two system have the same unique solution. What does this imply

**************************************************************************

III.) Replacing an equation by adding it to a multiple of another equation of a system of

linear equations yields an equivalent system.

**************************************************************************

Examples 8-10 show that the following operations yield equivalent systems

of linear equations:

. I.) multiply one equation by a nonzero constant.

. II.) interchange two equations.

. III.) add a multiple of one equation to another equation.

These three operations are called: elementary row operations.

********************************************************************

Matrix Representation of Linear Systems

Example 11: Consider the system of equations

> eq1:=2*x-3*y+z-w=0: eq2:=x-y+z-5*w=0: eq3:=x-y+z-w=9: eq4:=x+6*y-9*z+w=21:

> print(eq1); print(eq2); print(eq3); print(eq4);

>

The coefficient matrix associated with this system is

> AUG:=matrix([[2,-3,1,-1],[1,-1,1,-5],
[1,-1,1,-1],[1,6,-9,1]]);

The augmented matrix associated with this system is

> AUG:=matrix([[2,-3,1,-1,0],[1,-1,1,-5,0],
[1,-1,1,-1,9],[1,6,-9,1,21]]);

>

Example 12: Consider the system of equations

> eq1:=2*x-3*y+z=0: eq2:=7*x+11*y-9*z=2:

> print(eq1); print(eq2);

>

The augmented matrix associated with this system is the 2x4 matrix:

> AUG:=matrix([[2,-3,1,0],[7,11,-9,2]]);

>

We can also establish the following association : for every augmented matrix , one can write

the system of linear equations.

Example 13: Consider the augmented matrix

> A:=matrix([[2,3,5,1],[1,0,2,5],[2,4,0,0]]);

>

The set of equations associated with this matrix is

> eq1:=2*x+3*y+5*z=1: eq2:=x+2*z=5: eq3:=2*x+4*y=0:

> print(eq1); print(eq2); print(eq3);

>

Example 14: Consider the augmented matrix:

> A:=matrix([[2,3,5,1,0],[-1,8,2,5,0],[2,4,9,-7,0]]);

>

The set of equations associated with this matrix is

> eq1:=2*x+3*y+5*z+w=0: eq2:=-x+8*y +2*z+5*w=0: eq3:=2*x+4*y+9*z-7*w=0:

> print(eq1); print(eq2); print(eq3);

>

It is clear by now that matrix notation is a convenient way to represent a given system

of linear equations.

The linear system Ax=b can also be written as linear combination of the columns

of A set equal to the right hand side b.

> A:=matrix(4,3,[]): x:=matrix(3,1,[x_1,x_2,x_3]): b:=matrix(4,1,[b_1,b_2,b_3,b_4]):

> evalm(A)*evalm(x) = evalm(b);

> x_1*evalm(matrix(4,1,[A_11,A_21,A_31,A_41])) + x_2*evalm(matrix(4,1,[A_12,A_22,A_32,A_42])) + x_3*evalm(matrix(4,1,[A_13,A_23,A_33,A_43])) = evalm(b);

>

Let A be an m x n matrix. The linear system Ax=b is consistent if and only if the vector b is in the span of

the column vectors of A .

Gauss-Reduction

Example 15: Assume we are given the system

>

> eq1:=x1+2*x2-3*x3=4: eq2:=-3*x1-6*x2-5*x3=7: eq3:=-x1+5*x2-11*x3=12:

> print(eq1); print(eq2); print(eq3);

>

The augmented matrix associated with this system is

>

> AUG:=matrix([[1,2,-3,4],[-3,-6,-5,7],[-1,5,-11,12]]);

The idea is to get a system equivalent to the original one yet easier to solve.

We perform elementary row operations on AUG to eliminate from the second

and third equation.

Multiply row 1 by 3 and add to row 2

>

Multiply row 1 by 1 and add to row 3

>

and then eliminate from the third equation of the resulting system.

Interchange row 2 and row 3

>

> AUG3:=swaprow(AUG2,2,3);

Multiply row 2 by 1/7

>

> AUG4:=mulrow(AUG3,2,1/7);

Multiply row 3 by -1/14

>

> AUG5:=mulrow(AUG4,3,-1/14);

The matrix is referred to as the "echelon form" of AUG. The new system associated

with is:

>

> eq1:=x1 + 2*x2 - 3*x3 = 4: eq2:=x2 - 2*x3 = 16/7: eq3:= x3 = -19/14:

> print(eq1); print(eq2); print(eq3);

>

This system is equivalent to the original system since it is obtained by a sequence of

elementary row operations.

To obtain the "echelon form" of the matrix AUG, we perform a sequence of elementary row

operations until we get a form that resembles in this example.

What does the reduced matrix or the new system tell us about the solution of the

original system?

Example 16: Assume we are given the system associated with the following augmented matrix:

>

>

> AUG:=matrix([[1,2,-3,4],[-3,-6,-5,7],[-1,-2,-11,15]]);

Perform a sequence of elementary row operations on the matrix AUG

>

>

>

> AUG3:=mulrow(AUG2,2,-1/14);

>

The matrix is the "echelon form" of AUG. The new system associated with is

>

> eq1:=x1 + 2*x2 - 3*x3 = 4: eq2:=x3 = - 19/14: eq3:= 0 = 0:

> print(eq1); print(eq2); print(eq3);

>

>

The "echelon form" of the matrix AUG indicates that this new system is consistent

and has infinitely many solutions.

Example 17: Assume we are given the system associated with the following augmented matrix:

>

> AUG:=matrix([[1,2,-3,4],[-3,-6,-5,7],[-2,-4,-8,15]]);

>

>

Perform a sequence of elementary row operations on the new matrix AUG:

>

>

>

> AUG3:=mulrow(AUG2,2,-1/14);

>

>

>

The matrix is the "echelon form" of AUG. The new system associated with is:

>

> eq1:=x1 + 2*x2 - 3*x3 = 4: eq2:=x3 = - 19/14: eq3:= 0 = 4:

> print(eq1); print(eq2); print(eq3);

>

The "echelon form" of the matrix AUG indicates that this new system is inconsistent

(note: eq3 is absurd).

*********************************************************************

We have used elementary row operations to reduce a given matrix to its "ECHELON FORM"

to deduce consistency of the system.

Following is a representation of an original system and its reduced form.

Original System Reduced System

x x x x x x x x x x x x x x x x

x x x x x x x x 0 x x x x x x x

x x x x x x x x -------------> 0 0 0 x x x x x

x x x x x x x x 0 0 0 0 x x x x

x x x x x x x x 0 0 0 0 0 0 0 0

***********************************************************************

The reduced system should have the following properties:

. The leading entry in row i >= 2 is always to the right of the leading entry in previous rows.

. All zero rows must appear at the end of the matrix .

The resulting matrix is a matrix in row echelon form.

In addition, to the above four steps, if

. The first nonzero entry in any row must be 1.

. All entries above and below a leading 1 are zero,

then the resulting matrix is a matrix in reduced row echelon form .

*******************************************************************

The algorithm that yields the row echelon form of a matrix is

The GAUSS ELIMINATION ALGORITHM

The algorithm that yields the reduced row echelon form of a matrix is

The GAUSS - JORDAN ALGORITHM

If either form results in a consistent system of linear equations, then we apply

BACKSUBSTITUTION ALGORITHM

to the reduced form of the augmented matrix to obtain the solution of the original system .

*********************************************************************

Algorithm

Let us go over the Gauss elimination algorithm.

Example 18: Given the matrix:

>

> A:=matrix([[1,2,-1],[2,4,6],[5,7,9]]);

>

> gausselim(A);

`   1. Demonstration mode`

`   2. Interactive mode`

`   3. No Intermediate steps. Just give me the answer`

`<Select from 1; 2; or 3; >`

1;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

>

If the resulting matrix is the augmented matrix of a system of linear equations, is the system consistent or not? If consistent, how many solutions does it have?

Example 19: Given the matrix

>

> A:=matrix([[5,2,-9,7],[2,4,6,11],[15,7,29,45]]);

Obtain the echelon form of the matrix:

>

> gausselim(A);

`   1. Demonstration mode`

`   2. Interactive mode`

`   3. No Intermediate steps. Just give me the answer`

`<Select from 1; 2; or 3; >`

1;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

>

>

>

If the resulting matrix is the augmented matrix of a system of linear equations,

is the system consistent or not? If consistent, how many solutions does it have?

Example 20: Given the matrix

> A:=matrix([[3,1,-9,6],[4,6,1,1],[7,7,-8,7]]);

>

The echelon form of A is obtained by:

>

> gausselim(A);

`   1. Demonstration mode`

`   2. Interactive mode`

`   3. No Intermediate steps. Just give me the answer`

`<Select from 1; 2; or 3; >`

1;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

>

If the resulting matrix is the augmented matrix of a system of linear equations,

is the system consistent or not? If consistent, how many solutions does it have?

The reduced row echelon form of matrix A in Example 20 can be obtained by using

Gauss-Jordan algorithm

>

> rref(A);

`   1. Demonstration mode`

`   2. Interactive mode`

`   3. No Intermediate steps. Just give me the answer`

1;

`     Choose from the following menu`

`     1. To perform the Gauss elimination and obtain `

`        the row echelon form type  rowec; or 1;`

`     2. If you do not want to go through the process `

`        of obtaining the row echelon form type bypass; or 2;`

bypass;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

>

If the resulting matrix is the augmented matrix of a system of linear equations,

is the system consistent or not? If consistent, how many solutions does it have?

Example 21:

>

> A:=matrix([[1,3,5,6,15],[2,3,7,9,11],[4,9,17,21,41]]);

>

First put the matrix in row echelon form. Use the nostep mode of the "gausselim" function

>

> gausselim(A);

`   1. Demonstration mode`

`   2. Interactive mode`

`   3. No Intermediate steps. Just give me the answer`

`<Select from 1; 2; or 3; >`

3;

>

>

The echelon form of the matrix is

>

> A1:=matrix([[1,3,5,6,15],[0,1,1,1,19/3],[0,0,0,0,0]]);

Apply the backsub algorithm:

>

> backsub(A1);

`   1. Demonstration mode`

`   2. Interactive mode`

`   3. No Intermediate steps. Just give me the answer`

1;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

`< type ; and press Enter to continue ?topic for help  exit; to quit >`

;

>

>

Elementary matrix

Any matrix that can be obtained from the identity matrix by means of elementary row operation

is called an elementary matrix.

Muliplication of A on the left by elementary matrix E effects the same elementary row operation

on A that was performed on the identity matrix to obtain E.

> A:=matrix(3,3,[]);

> E := matrix(3,3,[1, 0, 0, 0, 0, 1, 0, 1, 0]);

> multiply(E,A);

>

Exercise

1-15(odd), 21, 23, 25, 29, 41-45, 47, 49, 56