• Aucun résultat trouvé

Equation Solving

Dans le document Mathematics for Computer Scientists (Page 99-106)

Algebra: Matrices, Vectors etc

9.0.5 Equation Solving

If you were to look at ways people use to solve equations you would be able do deduce some simple rules.

1. Equations can be multipled by a non-zero constant 2. Equations can be interchanged

3. Equations can be added or subtracted to other equations

If equations are manipulated following these rules they may look different butthey have the same solutions as when you started. We can solve equations by writing the coefficients in theaugmented matrix form and manipulating as follows

1. rows of the matrix may be interchanged

2. rows of the matrix may be multiplied by a nonzero constant.

Mathematics for Computer Scientists

100

3. rows can be added (or subtracted ) to (from) other rows

Our aim is to reduce the matrix to what is known asrow echelon form. This means that:

the leading non zero term in each row is a one.

Also the leading 1 in the first row lies to the left of that in the second row and so on. More precisely the leading 1 in any row lies to the left of the leading ones in all the rows below it.

For example

The reason for this will become apparent when we do it.

Lets try it out: We start with the equations 2x+y+2z = 10 x−2y+3z = 2

−x+y+z = 0 in this case the coefficients are

We are allowed to manipulate rows, these are row operations, to try and get to the row echelon form. Thus we have

1. Add row 2 to row 3 to get

3. Subtract row 1 from row 2

101

4. Tidy to get⎝ 1 3 −1 8 0 5 −4 6 0 1 −4 −2

5. Subtract 5 times row 3 from row 2 to get

⎝ 1 3 −1 8 0 0 16 16 0 1 −4 −2

6. Interchange rows 2 and 3

⎝ 1 3 −1 8 0 1 −4 −2 0 0 16 16

7. Tidy

⎝ 1 3 −1 8 0 1 −4 −2

0 0 1 1

This seems more like row echelon .

This last matrix corresponds to the set of equations x+3y−z = 8

y−4z = −2 z = 1 These are much easier to solve! Here

z=1 y=2 x=3.

Mathematics for Computer Scientists

102

It is often nicer to go a bit further and get rid of as much of the upper triangle as possible. Clearly the leading 1 in each row can be used to get zeros in the column above it. The resulting matrix is called reduced row echelon form of the original matrix. Here we get

It does really matter a great deal to us which we use since we are only interested in solutions.

Lets look at another example

6x+3y+6z = 9 x+2y= 16 4x+5y+1z = 18 The augmented form is ⎛

⎝ 6 3 6 9

Some steps have been concatenated!

What can go wrong

In reality nothing much can go wrong but we need to examine a couple of cases where the results we obtain require some thought.

1. Suppose we end up with a row of zeros. This is no problem, except when the number of non-zero rows is less that the number of variables. This just means there is not an unique solution e.g

x+2y−z = 0 x+z = 3 2x+2y = 3

Algebra: Matrices, Vectors etc.

103

Now there is a solution for these equations but it is not the explicit unique type we have been dealing with up to now. If z is known, say z0 then it followsx =3−z0andy= (2z0−3)/2.We have a solution for everyz0value.

Technically there are an infinite number of solutions. It is obvious if you think about it that if you have fewer equations than variables (unknowns) then you will not have a simple solution.

If we have 2 rows all zero then we have to give a value to two variables, if 3 then 3 variables and so on.

2. No Solution

Of course your equations may not have a solution in that they are contra-dictory, for example:

x=1 y=3 x= −2 z=16

We recognize the equations are contradictory ( have no solutions at all ) in the following way. If we have a row of which is all zero except for the very last element then the equations have no solution. For example:

Suppose we have the equations

x−2y−3z = 1

2x+cy+6z = 6

−x+3y +(c−3)z= 0

wherec is some constant. We proceed to row echelon

Mathematics for Computer Scientists

104

Before we go further what happens ifc= −6? The middle row of our matrix corresponds to 0=4 which is nonsense. Thus the original equation set does not have a solution when c= −6

However we will just carry on

⎛ which is clearly nonsense! This means that the original equations had no solution.

You may feel that this is a bit of a sledge hammer to crack a nut, but there is a real purpose to our exercise. If you move away from the trivial cases then the scheme we have outlined above is the best approach. It is also the technique use in the computer programs available for equation solving. In addition the shape of the reduced row echelon form tell us a lot about matrices. Often we have a system of equations where we have some parameters e.g. using our techniques above we can find the range of values, or perhaps the values themselves when solutions are possible.

The row elimination ideas we have outlined are known asGaussian elimination in numerical circles. The algorithms which bear tis name, while very much slicker are based on these simple ideas.

Algebra: Matrices, Vectors etc.

105

Exercises 1. Solve (a)

2x+3y = 7 5x−y = 9

(b)

x+3y+3z = 1 2x+5y+7z = 1

−2x−4y−5z = 1

(c)

v−w−x−y−z = 1 2v−w+3x+4z = 2 2v−2w+2x+y+z = 1 v+x+2y+z = 0

(d)

w+2x−3y−4z = 6 w+3x+y−2z = 4 2w+5x−2y−5z = 10

2. Consider the equations

v−w−x−y−z = 1 2v−w+3x+4z = 2 2v−2w+2x+y+z = 1 v+x+2y+z = c

For what values of c do these equations have a unique solution? Are there any values ofc for which there is no solution?

Mathematics for Computer Scientists

106

Dans le document Mathematics for Computer Scientists (Page 99-106)

Documents relatifs