Linear Algebra / Unit 2, Systems of Linear Equations / Topic 2.1
Unit 2. Systems of Linear Equations
A system of linear equations is a set of equations that must all be true at the same time. This topic shows two pictures of a system, the three possible outcomes, and a method called elimination that solves any system.
You need Topics 1.1 and 1.3 for this topic.
Here is a system of two linear equations with two unknowns:
x + 2y = 5 3x − y = 1A solution is a pair of numbers x and y that makes both equations true. For this system the solution is x = 1 and y = 2, because 1 + 4 = 5 and 3 − 2 = 1.
An equation is called linear when each unknown appears only to the first power and the unknowns are not multiplied by each other. The equation x + 2y = 5 is linear. The equations xy = 5 and x² + y = 5 are not linear.
From Topic 1.3, each linear equation in x and y is a line. The first equation is one line, and the second equation is another line. A solution must be on both lines, so the solution is the point where the two lines cross. This is called the row picture, because each row of the system is one line.
Two lines in a plane can meet in three ways, so a system of two equations has three possible outcomes.
| The two lines | Solutions |
|---|---|
| Cross at one point | Exactly one solution |
| Are parallel and different | No solution |
| Are the same line | Infinitely many solutions |
Try it: two lines
Each line passes through its two round handles. Drag the handles to move the lines. The purple ring marks the solution.
A system with exactly two solutions is not possible. Two different lines cannot cross at two points.
The same system can be read in a second way. Collect the coefficients of x into one vector, the coefficients of y into another vector, and the right sides into a third vector:
x 13 + y 2−1 = 51This is a linear combination, as in Topic 1.1. The question is now which coefficients x and y make the combination of the two column vectors equal to the target (5, 1). The answer is the same as before: x = 1 and y = 2.
1 13 + 2 2−1 = 1 + 43 − 2multiply each column by its coefficient, then add1 13 + 2 2−1 = 51the targetThe row picture asks where two lines cross. The column picture asks how to reach a target with two vectors. They are two views of the same system, and both are used in the rest of the course.
The column picture explains the three outcomes in a new way. If the two column vectors point along different lines, their span is the whole plane, so each target can be reached in exactly one way. If the two column vectors point along the same line, a target on that line can be reached in many ways, and a target off that line cannot be reached.
Elimination is a method for solving a system. The idea is to combine the equations so that one unknown disappears. Two operations are allowed, because they do not change the solutions:
Step by step: elimination
Press Next to see one step at a time.
After elimination, always substitute the solution into both of the original equations. This check takes a few seconds and catches most arithmetic errors.
Consider the system x + 2y = 5 and 2x + 4y = 7. Multiplying the first equation by −2 and adding it to the second equation gives 0 = −3. This statement is false, so the system has no solution. The two lines are parallel.
Now consider x + 2y = 5 and 2x + 4y = 10. The same step gives 0 = 0. This statement is true but gives no information, because the second equation is the first equation multiplied by 2. The two equations are the same line, so the system has infinitely many solutions.
Elimination works in the same way with more unknowns. Each equation in x, y, and z is a plane, from Topic 1.3, and a solution is a point on all of the planes.
x + y + z = 6 2x − y + z = 3 x + 2y − z = 2Use the first equation to remove x from the other two equations. The two new equations have only y and z.
−3y − z = −9the second equation minus 2 times the first equationy − 2z = −4the third equation minus the first equationy = 2z − 4solve the new second equation for y−3(2z − 4) − z = −9substitute into the new first equation−7z + 12 = −9collect the termsz = 3subtract 12, then divide by −7y = 2(3) − 4 = 2substitute z = 3x = 6 − 2 − 3 = 1the first original equation, with y = 2 and z = 3Check:
1 + 2 + 3 = 6the first equation2(1) − 2 + 3 = 3the second equation1 + 2(2) − 3 = 2the third equationThe solution is (1, 2, 3).
During elimination, only the coefficients and the right sides change. The letters x, y, and z do not have to be written at each step. The numbers of the system can be kept in a table, with one row for each equation:
1112−1112−1 with right sides 632A table of numbers like this is called a matrix. Topic 2.2 uses this table to organize elimination.
| Term | Meaning |
|---|---|
| Solution | Values of the unknowns that make all of the equations true |
| Row picture | Each equation is a line or a plane, and the solution is where they meet |
| Column picture | The unknowns are the coefficients of a linear combination that must reach a target |
| Elimination | Combining equations to remove one unknown at a time |
Work each problem on paper first. Then open the answer to check your work.
2x = 8add the two equationsx = 4divide both sides by 2y = 7 − 4 = 3substitute x = 4 into the first equation4 + 3 = 7the check in the first equation4 − 3 = 1the check in the second equation
−2x + 4y = 2multiply the second equation by −27y = 14add this to the first equationy = 2divide both sides by 7x = −1 + 2(2) = 3the second equation, solved for x2(3) + 3(2) = 12the check in the first equation3 − 2(2) = −1the check in the second equation
x(2, 1) + y(3, −2) = (12, −1). The column vectors hold the coefficients of x and the coefficients of y.
Infinitely many. The first equation is 3 times the second equation, so both equations describe the same line.
None. Subtracting the first equation from the second gives 0 = 3, which is false. The lines are parallel.
z = 2the third equationx + y = 2the first equation with z = 2x = ythe second equation2x = 2substitute y = xx = 1divide both sides by 2y = 1because y = x
The solution is (1, 1, 2).
Python reads the code one line at a time, from the top to the bottom. The equals sign stores the value on its right under the name on its left, and print shows a result. The name np stands for NumPy, the part of Python that works with vectors and matrices.
The system from this topic is x + 2y = 5 and 3x − y = 1. To solve it with Python, write the coefficients as a table with one row for each equation. This table is called a matrix. Each row goes inside its own square brackets, and all of the rows go inside one more pair of square brackets. The coefficient of y in the second equation is −1.
Python
Python prints the two rows on two lines. The first row holds the coefficients of the first equation, and the second row holds the coefficients of the second equation.
The right sides of the two equations go into a vector b. The instruction np.linalg.solve solves the system. It needs the matrix and the vector of right sides, in that order, with a comma between them.
Python
The result is [1. 2.], so x = 1 and y = 2. This is the solution that elimination gave in Part 4 of this topic. Python prints the numbers with a period, because it stores the solution as decimal numbers.
Now solve the system 2x + y = 7 and x − 3y = −7. Change the matrix and the vector of right sides in the next box.
Python
A solution should be checked in the original equations. Python can read one component of a vector. The first component of x is x[0], and the second component is x[1]. Python starts counting at 0, not at 1.
The code below solves the first system again, and then calculates the left side of each equation.
Python
The results are 5.0 and 1.0. These are the right sides of the two equations, so the solution is correct. If a result is printed as a number such as 0.9999999999999998, that is a very small rounding error, and the value is 1.
The same instruction works for more unknowns. The system from Part 5 of this topic is x + y + z = 6, 2x − y + z = 3, and x + 2y − z = 2. The matrix now has three rows, and each row has three numbers. One row has been left as zeros. Replace the zeros with the coefficients of the third equation, and then press Run.
Python
The solution is (1, 2, 3), as in Part 5. If you press Run before you replace the zeros, Python reports the error Singular matrix. The next step explains this error.
The system x + 2y = 5 and 2x + 4y = 7 has no solution, because the two lines are parallel. Press Run to see what Python does with this system.
Python
Python stops and reports the error Singular matrix. The instruction np.linalg.solve works only when the system has exactly one solution. To find out whether a system has no solution or infinitely many solutions, use elimination, as in Part 4.
This quiz has 5 questions on this topic. A question asks you either to choose one answer or to type numbers. The page grades your answers and explains each one. A number can be typed as a whole number, a decimal, a fraction such as 1/3, or a calculation such as sqrt(18)/2 or arccos(1/2). The page shows the value of a calculation next to the box. Angles in a calculation are in degrees. The Calculator button under each question opens a calculator. Your answers are saved in your browser, so they are still on the page when you come back to it.
Choose how your answers are checked
1. Which equation is the column form of the system 2x + y = 4, 3x + 5y = 13?
The column that multiplies x holds the coefficients of x in the two equations, which are 2 and 3. The column that multiplies y holds 1 and 5. The right side holds 4 and 13.
2. Solve the system 2x + y = 4, 3x + 5y = 13.
y = 4 − 2xthe first equation, solved for y3x + 5(4 − 2x) = 13substitute into the second equation20 − 7x = 13collect the termsx = 1subtract 20, then divide by −7y = 4 − 2(1) = 2substitute x = 13(1) + 5(2) = 13the check in the second equation
3. How many solutions does the system x + 2y = 3, 2x + 4y = 6 have?
The second equation is 2 times the first equation. Both equations describe the same line, and each point of that line is a solution.
4. How many solutions does the system x + 2y = 3, 2x + 4y = 7 have?
The left side of the second equation is 2 times the left side of the first equation, but 7 is not 2 times 3. The two lines are parallel and different, so they do not cross.
5. For which value of k does the system x + 2y = 3, 2x + ky = 5 have no solution?
With k = 4, the left side of the second equation is 2 times the left side of the first equation, but 5 is not 2 times 3. The lines are parallel and different. For any other value of k, the lines cross at one point.
Next: Topic 2.2, Row Reduction