21
Vectors and Matrices – Lecture 5 Dr Mark Kambites School of Mathematics 21/03/2014 Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 1 / 21

Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

  • Upload
    hatu

  • View
    216

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Vectors and Matrices – Lecture 5

Dr Mark Kambites

School of Mathematics

21/03/2014

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 1 / 21

Page 2: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Example. Solve the system of equations:

2x + y − z = −76x − z = −10−4x + y + 7z = 31

Solution. We express the system as an augmented matrix:

2 1 −1 −76 0 −1 −10−4 1 7 31

.

Note that there are already no non-0 entries to the left of the first rowpivot.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 2 / 21

Page 3: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

2 1 −1 −76 0 −1 −10−4 1 7 31

.

Now we remove the entry in row 2 which is below the row 1 pivot.Adding −3 times row 1 to row 2 (r2 → r2 − 3r1) gives: 2 1 −1 −7

0 −3 2 11−4 1 7 31

.

Next we remove the entry in row 3 below the row 1 pivot.r3 → r3 + 2r1 gives: 2 1 −1 −7

0 −3 2 110 3 5 17

.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 3 / 21

Page 4: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Now ignore row 1 and repeat with remaining rows.2 1 −1 −70 −3 2 110 3 5 17

.

Note there are no pivots left of the row 2 pivot.

Remove the entry in row 3 below the row 2 pivot: r3 → r3 + r2:2 1 −1 −70 −3 2 110 0 7 28

.

Our matrix is now in row echelon form! Convert back to equations:

2x + y − z = −7− 3y + 2z = 11

7z = 28

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 4 / 21

Page 5: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

2x + y − z = −7 [1]− 3y + 2z = 11 [2]

7z = 28 [3]

Now solve by “backtracking”:

equation [3] gives 7z = 28, so z = 4;

substituting into equation [2] gives −3y + 8 = 11, so y = −1;

substituting into equation [1] gives 2x + (−1)− 4 = −7, so x = −1.

So the solution is x = −1, y = −1 and z = 4.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 5 / 21

Page 6: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

A Useful Trick: Extra Swaps

Suppose we have the augmented matrix:12 12 −1 −74 −3 2 118 0 7 28

.

Gaussian elimination tells you to add −13 row 1 to row 2, and then 2

3 row 1to row 3.

This is fine in principle, but we end up with awkward fractions.

The solution is to swap row 1 and row 2 (r1 ↔ r2) first!

This is fine, because the “swap” is an elementary row operation.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 6 / 21

Page 7: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Another Trick: Scaling Rows

Suppose we have: (12

52 −1 −7

34 −3 2 12

).

We can make life much easier by multiplying the top row by 6 to get:

(3 15 −6 −144 −3 2 12

).

Scaling a row is not one of our elementary row operations.

But it still preserves the solution set, so is okay.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 7 / 21

Page 8: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Elimination with No Solutions

Consider:−x + 2y + z = 23x + y − 2z = 10x + 5y = 7

The augmented matrix is−1 2 1 23 1 −2 101 5 0 7

7→−1 2 1 2

0 7 1 160 7 1 9

7→−1 2 1 2

0 7 1 160 0 0 −7

This gives equations −x + 2y + z = 2, 7y + z = 16 and 0 = −7.

These have no solutions. So the original equations have no solutions!

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 8 / 21

Page 9: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Elimination With Redundant Equations

Now consider the (very similar!) system

−x + 2y + z = 23x + y − 2z = 10x + 5y = 14

This time the augmented matrix is:−1 2 1 23 1 −2 101 5 0 14

7→ · · · 7→−1 2 1 2

0 7 1 160 0 0 0

.

Now we get equations −x + 2y + z = 2, 7y + z = 16 and 0 = 0.

The equation 0 = 0 is always satisfied. So we can just ignore it and workwith the others.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 9 / 21

Page 10: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Elimination with More Equations Than Variables

So far we have assumed the same number of equations and variables.

What if there are more equations than variables?

We can still apply Gaussian elimination process, but we will always end upwith a zero row in the augmented matrix.

So either we will be able to throw away equations until we have only asmany equations as variables, or there will turn out to be no solutions.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 10 / 21

Page 11: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Elimination with More Variables than Equations

What if there are more variables than equations?

This could be the case from the start or it could happen because we threwaway some “0 = 0” equations.

We can still apply Gaussian elimination.

But when we “backtrack” we will sometimes meet an equation with morethan one unknown variable.

This means there are infinitely many solutions.

We can describe all the solutions by introducing parameters to replacesome of the variables.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 11 / 21

Page 12: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Example. Solve the system of equations:

x + 2y + 5z = 52x + 4y + 16z = 16

Solution. The augmented matrix is(1 2 5 52 4 16 16

)7→(

1 2 5 50 0 6 6

).

Converting back to equations we have:

x + 2y + 5z = 56z = 6

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 12 / 21

Page 13: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

x + 2y + 5z = 5 [1]6z = 6 [2]

Now backtracking:

Equation [2] gives z = 1;

substituting into [1] we get x + 2y + 5 = 5, which has two unknownvariables!

We introduce a parameter λ to stand for one of them, say λ = y

This gives x + 2λ+ 5 = 5, or x = −2λ.

So the solutions are:

x = −2λ, y = λ, z = 1.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 13 / 21

Page 14: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Homogeneous Systems of Equations

A system of linear equations is homogeneous if theconstant terms are all 0. For example:

x + 7y − 4z = 02x + 4y − z = 03x + y + 2z = 0

Homogeneous systems always have at least one solution: set allvariables to 0!

Otherwise they are just like any other system of equations.They can be solved by Gaussian elimination.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 14 / 21

Page 15: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Example. Solve the system of equations:

x + 7y − 4z = 02x + 4y − z = 03x + y + 2z = 0

Solution. The augmented matrix is1 7 −4 02 4 −1 03 1 2 0

7→1 7 −4 0

0 −10 7 00 −20 14 0

7→1 7 −4 0

0 −10 7 00 0 0 0

Converting back to equations we get:

x + 7y − 4z = 0−10y + 7z = 0

.

plus a “0 = 0” type equation which can be discarded.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 15 / 21

Page 16: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

x + 7y − 4z = 0 [1]−10y + 7z = 0 [2]

.

Now backtracking:

Equation [2] has 2 unknown variables; so introduce a parameterλ = z ;

Now [2] gives y = 710λ.

Now [1] gives x = − 910λ.

So, the solutions are:

x = − 9

10λ, y =

7

10λ, z = λ.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 16 / 21

Page 17: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Geometry of Linear Equations

Consider the equation:3x + 4y = 4.

Each solution consists of an x-value and a y -value.

These give coordinates of a point in 2-dimensional space.

For example, a solution here is x = −4 and y = 4. This gives the point(−4, 4).

The set of solutions to a linear equation with two variables forms a line in2-dimension space.

So each equation corresponds to a line.

Terminology. We say the equation “defines the line” or “is the equationof” the line.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 17 / 21

Page 18: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Now suppose we have a system of equations with variables x and y .

A solution to the system means an x-value and a y -value which solve allthe equations at once.

So a solution corresponds to a point which lies on all the lines.

So the solution set is an intersection of lines.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 18 / 21

Page 19: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

A solution to 2 equations with two variables is the intersection of twolines in 2-space.

Question. What can an intersection of two lines look like?

Usually it is a single point. (This is why 2 equations in 2 variablesusually has a unique solution!)

Alternatively, the lines could be different but parallel. Then theintersection is the empty set. (This is why 2 equations in 2 variablescan sometimes have no solutions!)

Or then again, the two lines could actually be the same. In this casethe intersection is the whole line. (This is why 2 equations in 2variables can sometimes have an infinite family of solutions).

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 19 / 21

Page 20: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

Solutions to equations with 3 variables are points in 3-dimensional space.

3x + 4y + 7z = 4.

The set of all solutions is usually a plane in space. (It could be empty.)

Exercise. What can the intersection of 2 planes in 3-dimensional spacelook like?

How do the possibilities correspond to the possible solution sets of 2equations with 3 variables?

Exercise. Now try to do the same for intersections of 3 planes.

Recall. The intersection of 3 sets is the set of points which lie in all 3.

How do the possible geometric things you get correspond to the possibleforms of solution sets for 3 equations with 3 variables?

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 20 / 21

Page 21: Vectors and Matrices { Lecture 5 - maths.manchester.ac.ukmkambites/teaching/cs/slides5.pdf · 4x + y + 7z = 31 Solution. We express the system as an augmented matrix: 0 @ 2 1 1 7

In yet higher dimensions . . .

. . . the solution set to a linear equation in n variables defines an(n − 1)-dimensional subspace in n-dimensional space.

Such a subspace is called a hyperplane.

So the solution set of k equations with n variables will be an intersectionof k hyperplanes in n-dimensional space.

Dr Mark Kambites (School of Mathematics) COMP11120 21/03/2014 21 / 21