Monocurl Essays
Series Download

Solving two equations at once: where lines meet

Ten heads and 28 legs: how many chickens and rabbits? Each clue is a line of possibilities, and elimination pivots a line about the point where they cross.

21 min·High school·

AssumesWhat slope means, and why y = mx + b is a line

Ten animals, chickens and rabbits. Starting from ten chickens with 20 legs, each chicken swapped for a rabbit moves one step along the line of ten-head combinations and adds two legs. After four swaps the count reaches 28 legs, at 6 chickens and 4 rabbits, which is where the line of 28-leg combinations crosses.
Monocurl source
let Walk = |k| [
    Ring(at(fz, 10 - k, k), LEAF, 0.15, 4),
    center{[3.35, 1.3, 0]} scale{1.15} color{INK} Number(10 - k, 0),
    center{[3.35, 0.5, 0]} scale{1.15} color{INK} Number(k, 0),
    center{[3.35, -0.3, 0]} scale{1.15} color{AZURE} Number(10, 0),
    center{[3.35, -1.1, 0]} scale{1.15} color{EMBER} Number(20 + 2 * k, 0)
]
mesh plot = ZooPlot
mesh legs = []
mesh heads = [HeadLine, HeadDots]
mesh names = [Row(1.3, "chickens"), Row(0.5, "rabbits"), Row(-0.3, "heads", AZURE), Row(-1.1, "legs", EMBER)]
mesh walk = Walk(k: 0)

slide "swap"
    play Wait(1)
    walk.k = 1
    play Lerp(0.6, [&walk])
    play Wait(0.4)
    walk.k = 2
    play Lerp(0.6, [&walk])
    play Wait(0.4)
    walk.k = 3
    play Lerp(0.6, [&walk])
    play Wait(0.4)
    walk.k = 4
    play Lerp(0.6, [&walk])
    play Wait(0.6)
    legs = [LegLine, LegDots]
    play Fade(1, [&legs])
    play Wait(2.2)

Uses the shared definitions for this lesson's figures.

A farmer keeps chickens and rabbits in one pen. Looking over the fence you count 10 heads, and looking under it you count 28 legs. How many chickens are there, and how many rabbits?

Neither count answers the question by itself. Ten heads could be ten chickens, or ten rabbits, or anything in between. Twenty-eight legs could be seven rabbits, or fourteen chickens, or several other mixtures. The answer comes only from holding both facts at once. This puzzle is at least 1500 years old (it appears in the Chinese text Sunzi Suanjing with 35 heads and 94 feet), and the idea that solves it is the idea behind every system of equations.

Pause and try

Before reading on, solve the puzzle by any method you like. Then try to explain why there is only one answer.

Show answerHide answer

There are 6 chickens and 4 rabbits: $6 + 4 = 10$ heads and $6 \times 2 + 4 \times 4 = 12 + 16 = 28$ legs. The rest of this lesson gives three ways to find this and one reason it is the only possibility.

Handing out the legs

Here is a way to solve it that needs no algebra. Every animal, chicken or rabbit, has at least two legs. So begin by giving each of the ten heads two legs. That uses 20 legs, and 8 are left over. The leftover legs can only belong to rabbits, and each rabbit needs exactly two more. Eight legs in pairs is four pairs, so there are 4 rabbits, and the other 6 animals are chickens.

  1. Ten heads. Each belongs to a chicken or a rabbit, and there are 28 legs to hand out.
  2. Every animal has at least two legs. Give each head two: that uses 20.
  3. There are 8 legs left. Only rabbits take more, two more each, so the 8 go out in pairs to 4 animals.
  4. Those 4 animals are the rabbits. The other 6 are chickens.
Solving the chickens and rabbits puzzle by handing out legs. Ten heads each receive two legs, which uses 20 of the 28. The remaining 8 legs go out in pairs to 4 animals, which are therefore the rabbits. The other 6 are chickens.
Monocurl source
let HX = |i| -3.24 + 0.72 * i
let HY = 0.75
let LL = 1.25
let Head = |i, col| Disc([HX(i), HY, 0], 0.3, col, 0.3, 3)
let Leg = |i, dx, col| Seg([HX(i) + dx, HY - 0.32, 0], [HX(i) + dx, HY - 0.32 - LL, 0], col, 4.5)
let Heads = |n_rabbit| block {
    for (i in range(0, 10)) {
        var col = SLATE
        if (n_rabbit > 0) {
            col = GOLD
            if (i < n_rabbit) { col = PLUM }
        }
        . Head(i, col)
    }
}
let TwoEach = block {
    for (i in range(0, 10)) {
        . Leg(i, -0.08, AZURE)
        . Leg(i, 0.08, AZURE)
    }
}
let Extra = block {
    for (i in range(0, 4)) {
        . Leg(i, -0.22, EMBER)
        . Leg(i, 0.22, EMBER)
    }
}
let Tally = |tex, col = INK| center{[0, 1.7, 0]} Math(tex, 1.0, col)
mesh heads = []
mesh two = []
mesh extra = []
mesh tally = []
mesh names = []

slide "Ten heads. Each belongs to a chicken or a rabbit, and there are 28 legs to hand out."
    heads = Heads(0)
    tally = Tally("28 \text{ legs to hand out}")
    play Fade(0.7)

slide "Every animal has at least two legs. Give each head two: that uses 20."
    tally = []
    play Fade(0.3, [&tally])
    two = TwoEach
    tally = Tally("10 \times 2 = 20 \text{ legs used}", AZURE)
    play Fade(0.8)

slide "There are 8 legs left. Only rabbits take more, two more each, so the 8 go out in pairs to 4 animals."
    tally = []
    play Fade(0.3, [&tally])
    extra = Extra
    tally = Tally("28 - 20 = 8 \text{ left}, \quad 8 \div 2 = 4", EMBER)
    play Fade(0.8)

slide "Those 4 animals are the rabbits. The other 6 are chickens."
    heads = Heads(4)
    names = [
        center{[(HX(0) + HX(3)) / 2, -1.3, 0]} Cap("4 rabbits", 0.9, PLUM),
        center{[(HX(4) + HX(9)) / 2, -1.3, 0]} Cap("6 chickens", 0.9, GOLD)
    ]
    play Fade(0.8)

Uses the shared definitions for this lesson's figures.

That argument is quick, and it looks like a trick that depends on legs coming in twos and fours. It is actually a general method in disguise, and the way to see that is to write the puzzle in symbols and then draw it.

Each clue is a line of possibilities

Let $c$ be the number of chickens and $r$ the number of rabbits. The two counts say

$$ c + r = 10 \qquad\text{and}\qquad 2c + 4r = 28. $$

Take the first equation alone. It has many solutions: $(c, r) = (10, 0), (9, 1), (8, 2)$, and so on down to $(0, 10)$. Plot each as a point, with chickens measured across and rabbits measured up, and the eleven points fall on a straight line. The second equation alone has its own list: $(14, 0), (12, 1), (10, 2), \dots, (0, 7)$, which falls on a different straight line. Step through the figure.

  1. Every way to have 10 heads, from 10 chickens and no rabbits to 10 rabbits and no chickens.
  2. The eleven points lie on a straight line. Each step trades one chicken for one rabbit.
  3. Every way to have 28 legs. Each step trades two chickens for one rabbit.
  4. Only one combination is on both lists: 6 chickens and 4 rabbits.
The combinations of chickens and rabbits allowed by each clue. The eleven combinations with 10 heads lie on one line, the eight combinations with 28 legs lie on another, and exactly one point, 6 chickens and 4 rabbits, is on both.
Monocurl source
let Eq = |y, tex, col| center{[2.75, y, 0]} Math(tex, 0.95, col)
mesh plot = ZooPlot
mesh hline = []
mesh lline = []
mesh hdots = []
mesh ldots = []
mesh cross = []
mesh eqs = []

slide "Every way to have 10 heads, from 10 chickens and no rabbits to 10 rabbits and no chickens."
    hdots = HeadDots
    eqs = [Eq(1.2, "c + r = 10", AZURE)]
    play Fade(0.7)

slide "The eleven points lie on a straight line. Each step trades one chicken for one rabbit."
    hline = HeadLine
    play Write(0.9, [&hline])

slide "Every way to have 28 legs. Each step trades two chickens for one rabbit."
    ldots = LegDots
    lline = LegLine
    eqs = [Eq(1.2, "c + r = 10", AZURE), Eq(0.4, "2c + 4r = 28", EMBER)]
    play Fade(0.8)

slide "Only one combination is on both lists: 6 chickens and 4 rabbits."
    cross = [
        Seg(at(fz, 6, 0), at(fz, 6, 4), LEAF, 2.5),
        Seg(at(fz, 0, 4), at(fz, 6, 4), LEAF, 2.5),
        Ring(at(fz, 6, 4), LEAF, 0.16, 4)
    ]
    eqs = [Eq(1.2, "c + r = 10", AZURE), Eq(0.4, "2c + 4r = 28", EMBER), Eq(-0.6, "(c, r) = (6, 4)", LEAF)]
    play Fade(0.8)

Uses the shared definitions for this lesson's figures.

The picture explains why the answer is unique. Each clue confines the answer to a line, and two different straight lines that cross do so at a single point.

We should check that these sets of points really are straight lines. The lesson on slope proved that the graph of $y = mx + b$ is a straight line with slope $m$ crossing the vertical axis at height $b$. Our equations can be put in that form by solving for $r$:

$$ c + r = 10 \;\text{ becomes }\; r = -c + 10, \qquad 2c + 4r = 28 \;\text{ becomes }\; r = -\tfrac12 c + 7. $$

The slopes $-1$ and $-\frac12$ are the trades in the figure: one rabbit gained per chicken lost on the first line, half a rabbit per chicken on the second.

The solutions of one linear equation always form a straight line. If $b \ne 0$, dividing by $b$ gives $y = -\frac{a}{b}x + \frac{c}{b}$, a line of slope $-\frac{a}{b}$. If $b = 0$, then $a \ne 0$ and the equation says $x = \frac{c}{a}$, a vertical line. So a solution of a system is a point that lies on two lines.

Substitution: walk along one line until the other is satisfied

Reading the crossing off a drawing works when the answer is a pair of small whole numbers. We want a method that works by calculation.

The first equation says $r = 10 - c$: once you choose $c$, the line tells you $r$. So every point on the first line has the form $(c, 10 - c)$, and we can ask which of these points satisfies the second equation. Replace $r$ by $10 - c$ there:

$$ 2c + 4(10 - c) = 28, \quad\text{so}\quad 40 - 2c = 28, \quad\text{so}\quad c = 6. $$

Then $r = 10 - 6 = 4$. This is the substitution method, and the animation at the top of the page is a picture of it. The marker walks along the ten-heads line, the leg count $2c + 4(10 - c) = 40 - 2c$ changes by 2 at each step, and we stop when it reads 28.

Elimination: a third line through the same point

The leg-handing argument did something different. It never solved for one unknown in terms of the other. In symbols, “give every head two legs” is the first equation multiplied by 2:

$$ 2c + 2r = 20. $$

“See what is left over” is subtracting that from the second equation, left side from left side and right side from right side:

$$ (2c + 4r) - (2c + 2r) = 28 - 20, \quad\text{that is,}\quad 2r = 8. $$

The chickens have disappeared from the equation, which is why this is called elimination. It is not obvious that one equation may be subtracted from another, so the step needs a reason.

At a solution, both equations are true statements about numbers. If $2c + 4r$ really is 28 and $2c + 2r$ really is 20, then their difference really is 8. So any solution of the system must also satisfy the new equation $2r = 8$. Put geometrically: the new equation is a new line, and it passes through the crossing point of the old two.

Nothing forced us to subtract exactly two copies of the first equation. Subtract $t$ copies, for any number $t$, and you get

$$ (2 - t)c + (4 - t)r = 28 - 10t, $$

a whole family of lines, every one of which must pass through the crossing.

Pause and try

Take $t = 3$. Write down the combined equation and check that $(6, 4)$ satisfies it. Then find the value of $t$ that eliminates $r$ instead of $c$, and solve the resulting equation.

Show answerHide answer

With $t = 3$: $-c + r = -2$, and indeed $-6 + 4 = -2$. To eliminate $r$ we need $4 - t = 0$, so $t = 4$, which gives $-2c = -12$ and $c = 6$.

The legs equation with $t$ copies of the heads equation subtracted from it, as $t$ runs from 0 to 4. The combined line pivots about the crossing point $(6, 4)$. At $t = 2$ the chickens are eliminated and the line is horizontal, $r = 4$. At $t = 4$ the rabbits are eliminated and the line is vertical, $c = 6$.
Monocurl source
let Combo = |t| {
    var sa = 2 - t
    var sb = 4 - t
    if (abs(sa) < 0.05) { sa = 0 }
    if (abs(sb) < 0.05) { sb = 0 }
    return [
        Through(fz, 6, 4, 4 - t, t - 2, INK, 4.5),
        Pt(at(fz, 6, 4), LEAF, 0.11),
        center{[2.9, 1.45, 0]} scale{1.15} color{INK} Number(t, 1),
        center{[1.92, 0.55, 0]} scale{1.05} color{INK} Number(sa, 1),
        center{[3.08, 0.55, 0]} scale{1.05} color{INK} Number(sb, 1),
        center{[2.98, -0.1, 0]} scale{1.05} color{INK} Number(28 - 10 * t, 1)
    ]
}
mesh plot = ZooPlot
mesh lines = [HeadLine, LegLine]
mesh names = [
    center{[2.3, 1.45, 0]} Math("t =", 0.95),
    center{[2.52, 0.55, 0]} Math("c \;+", 0.95),
    center{[3.47, 0.55, 0]} Math("r", 0.95),
    center{[2.42, -0.1, 0]} Math("=", 0.95)
]
mesh combo = Combo(t: 0)
mesh note = []

slide "pivot"
    play Wait(0.8)
    combo.t = 2
    play Lerp(2.4, [&combo])
    note = center{[2.75, -1.1, 0]} Math("2r = 8", 1.0, LEAF)
    play Fade(0.4, [&note])
    play Wait(1.1)
    note = []
    play Fade(0.3, [&note])
    combo.t = 4
    play Lerp(2.4, [&combo])
    note = center{[2.75, -1.1, 0]} Math("-2c = -12", 1.0, LEAF)
    play Fade(0.4, [&note])
    play Wait(1.6)

Uses the shared definitions for this lesson's figures.

As $t$ changes, the combined line swings around the crossing point like a clock hand. Among all those lines two are especially easy to read, the horizontal one and the vertical one, because a horizontal line states the value of $r$ and a vertical line states the value of $c$. Elimination is the art of choosing the multiple that swings the line flat or upright.

We argued that every solution of the original pair satisfies the combined equation. For the method to be safe we need the reverse as well: replacing an equation by a combination must not let in new, false solutions.

Two things about this statement matter. It keeps $E_1$: the pair $\{E_1, E_3\}$ has the same solutions as the pair $\{E_1, E_2\}$, but $E_3$ alone is only one line and has many more. And the step can be undone, which is what the second half of the proof uses. A second safe step is to multiply both sides of one equation by a number that is not zero, since dividing by that number undoes it.

Worked examples

The lines 3x + 2y = 16 and 5x - 3y = 14 cross at (4, 2). The two equations produced by elimination, 19x = 76 and 19y = 38, are the vertical and horizontal lines through the same point.
The lines $3x + 2y = 16$ and $5x - 3y = 14$ cross at $(4, 2)$. The two equations produced by elimination, $19x = 76$ and $19y = 38$, are the vertical and horizontal lines through the same point.
Monocurl source
let fe = Frame(-1, 8.2, -3.4, 9.4, [0.05, 0, 0], 6.3, 3.75)
mesh grid = GridLines(fe, [1, 2, 3, 4, 5, 6, 7, 8], [-2, 2, 4, 6, 8])
mesh axes = [
    Axes(fe, "x"),
    XTicks(fe, [1, 3, 5, 7]),
    YTicks(fe, [-2, 4, 6, 8]),
    center{[fx(fe, 0) + 0.3, fy(fe, 9.4) + 0.2, 0]} Math("y", 0.8, SLATE)
]
mesh found = [
    Through(fe, 4, 2, 0, 1, LEAF, 2.5),
    Through(fe, 4, 2, 1, 0, LEAF, 2.5)
]
mesh lines = [
    Through(fe, 4, 2, 2, -3, AZURE, 4),
    Through(fe, 4, 2, 3, 5, EMBER, 4),
    Pt(at(fe, 4, 2), LEAF, 0.12)
]
mesh labels = [
    center{[fx(fe, 1.6) + 0.2, fy(fe, 7.6), 0]} Math("3x + 2y = 16", 0.85, AZURE),
    center{[fx(fe, 5.5), fy(fe, 8.5), 0]} Math("5x - 3y = 14", 0.85, EMBER),
    center{[fx(fe, 4) + 0.9, fy(fe, -2.75), 0]} Math("19x = 76", 0.8, LEAF),
    center{[fx(fe, 6.9), fy(fe, 2) - 0.3, 0]} Math("19y = 38", 0.8, LEAF)
]

Uses the shared definitions for this lesson's figures.

When there is no crossing, or too many

Two lines do not always cross at one point. Suppose the pen holds chickens and ducks, both two-legged, and you count 10 heads and 28 legs.

Pause and try

Write the two equations for $c$ chickens and $d$ ducks. Try to eliminate $c$. What happens, and what does it say about the count?

Show answerHide answer

The equations are $c + d = 10$ and $2c + 2d = 28$. Subtracting twice the first from the second eliminates $c$ and $d$ together and leaves $0 = 8$, which is false. No pair $(c, d)$ can satisfy both equations: ten two-legged birds have 20 legs, never 28, so someone miscounted.

In the picture, $2c + 2d = 28$ is the line $c + d = 14$, which has the same slope as $c + d = 10$ and sits above it. The lines are parallel and never meet. If the leg count had been 20, the second equation would be $2c + 2d = 20$, which is the first equation doubled. Then the two lines coincide and every point of the line is a solution: the leg count tells you nothing that the head count had not.

The three possibilities for two linear equations. Lines with different slopes cross at exactly one point. Parallel lines never meet, so there is no solution. Two equations for the same line share every point, so there are infinitely many solutions.
The three possibilities for two linear equations. Lines with different slopes cross at exactly one point. Parallel lines never meet, so there is no solution. Two equations for the same line share every point, so there are infinitely many solutions.
Monocurl source
let Mini = |cx, top, bottom, title, col| {
    let fr = Frame(0, 15.5, 0, 15.5, [cx, -0.2, 0], 1.85, 1.85)
    return [
        GridLines(fr, [5, 10, 15], [5, 10, 15]),
        Axes(fr),
        XTicks(fr, [5, 10]),
        YTicks(fr, [5, 10]),
        center{[cx, 1.85, 0]} Math(top, 0.72, AZURE),
        center{[cx, 1.4, 0]} Math(bottom, 0.72, EMBER),
        center{[cx, -1.95, 0]} Cap(title, 0.74, col)
    ]
}
let fa = Frame(0, 15.5, 0, 15.5, [-2.4, -0.2, 0], 1.85, 1.85)
let fb = Frame(0, 15.5, 0, 15.5, [0.15, -0.2, 0], 1.85, 1.85)
let fc = Frame(0, 15.5, 0, 15.5, [2.7, -0.2, 0], 1.85, 1.85)
mesh panels = [
    Mini(-2.4, "c + r = 10", "2c + 4r = 28", "one solution", LEAF),
    Mini(0.15, "c + d = 10", "2c + 2d = 28", "no solution", ROSE),
    Mini(2.7, "c + d = 10", "2c + 2d = 20", "infinitely many", PLUM)
]
mesh lines = [
    Seg(at(fa, 0, 10), at(fa, 10, 0), AZURE, 3.5),
    Seg(at(fa, 0, 7), at(fa, 14, 0), EMBER, 3.5),
    Pt(at(fa, 6, 4), LEAF, 0.1),
    Seg(at(fb, 0, 10), at(fb, 10, 0), AZURE, 3.5),
    Seg(at(fb, 0, 14), at(fb, 14, 0), EMBER, 3.5),
    Seg(at(fc, 0, 10), at(fc, 10, 0), AZURE, 7),
    Seg(at(fc, 0, 10), at(fc, 10, 0), EMBER, 2.5)
]

Uses the shared definitions for this lesson's figures.

These are the only three things that can happen, and one number computed from the coefficients tells them apart.

When $b_1$ and $b_2$ are not zero, the two slopes are $-\frac{a_1}{b_1}$ and $-\frac{a_2}{b_2}$, and they are equal exactly when $a_1b_2 = a_2b_1$. So $D = 0$ says that the lines have the same direction. The number $D$ is called the determinant of the system, and it has a geometric meaning of its own, as the factor by which a matrix scales areas. For the farm, $D = 1 \times 4 - 2 \times 1 = 2$, and the formulas give $c = \frac{10 \times 4 - 28 \times 1}{2} = 6$ and $r = \frac{1 \times 28 - 2 \times 10}{2} = 4$.

A solution the farm cannot use

The theorem is about real numbers. A puzzle about animals wants whole numbers that are not negative, and the algebra does not know that. Change the leg count to 27. Then $D$ is still 2, so there is exactly one solution: twice the heads equation subtracted from $2c + 4r = 27$ leaves $2r = 7$, so $r = 3.5$ and $c = 6.5$.

Ten heads and 27 legs. The lines c + r = 10 and 2c + 4r = 27 cross at (6.5, 3.5), which falls between the grid points. The system has a solution, but no whole number of chickens and rabbits matches the count.
Ten heads and 27 legs. The lines $c + r = 10$ and $2c + 4r = 27$ cross at $(6.5, 3.5)$, which falls between the grid points. The system has a solution, but no whole number of chickens and rabbits matches the count.
Monocurl source
let fl = Frame(4, 9.3, 1.3, 5.9, [-0.2, 0.12, 0], 4.3, 3.9)
mesh grid = GridLines(fl, [5, 6, 7, 8, 9], [2, 3, 4, 5])
mesh ticks = block {
    for (c in [5, 6, 7, 8, 9]) {
        . center{[fx(fl, c), fy(fl, 1.3) - 0.2, 0]} Math(to_string(c), 0.75, SLATE)
    }
    for (r in [2, 3, 4, 5]) {
        . center{[fx(fl, 4) - 0.22, fy(fl, r), 0]} Math(to_string(r), 0.75, SLATE)
    }
    . center{[fx(fl, 9.3) + 0.75, fy(fl, 1.3) - 0.2, 0]} Note("chickens", 0.72)
    . center{[fx(fl, 4) - 0.85, fy(fl, 4.5), 0]} Note("rabbits", 0.72)
}
mesh lattice = block {
    for (c in range(5, 10)) {
        for (r in range(2, 6)) {
            . Pt(at(fl, c, r), SLATE, 0.05)
        }
    }
}
mesh lines = [
    Through(fl, 6.5, 3.5, 1, -1, AZURE, 4),
    Through(fl, 6.5, 3.5, 2, -1, EMBER, 4),
    Pt(at(fl, 5, 5), AZURE, 0.09),
    Pt(at(fl, 6, 4), AZURE, 0.09),
    Pt(at(fl, 7, 3), AZURE, 0.09),
    Pt(at(fl, 8, 2), AZURE, 0.09),
    Ring(at(fl, 6.5, 3.5), ROSE, 0.13, 4)
]
mesh labels = [
    center{[2.95, 1.2, 0]} Math("c + r = 10", 0.85, AZURE),
    center{[2.95, 0.5, 0]} Math("2c + 4r = 27", 0.85, EMBER),
    center{[2.95, -0.5, 0]} Math("(6.5, \, 3.5)", 0.9, ROSE)
]

Uses the shared definitions for this lesson's figures.

Half a rabbit is not an answer, so the count of 27 must be wrong. (You could have known in advance: $2c + 4r$ is even for whole numbers $c$ and $r$.) In the same way, 10 heads and 44 legs gives $r = 12$ and $c = -2$, a crossing point outside the part of the plane where the puzzle lives. After solving a system that came from a situation, check the solution against the situation.

Common mistakes

Stepping back

One equation with two unknowns leaves a line of possibilities. A second equation leaves another line, and what both allow is where the lines meet. The difficulty was that a crossing point is easy to see and awkward to compute, and the idea that removed it was that equations may be combined: any multiple of one added to the other gives a new line through the same point, and we are free to choose the one that is horizontal or vertical.

That idea scales up. With three unknowns each equation is a plane in space, and with a thousand unknowns there is no picture at all, but adding multiples of equations to one another to eliminate unknowns one at a time still works. Under the name Gaussian elimination it is how computers solve the large systems that arise in engineering and statistics, and the lesson on linear systems explains the same three cases, one solution, none or infinitely many, by treating the two left sides as a single transformation of the plane.

Check yourself

The system $x + 2y = 7$, $3x + 6y = 21$ has how many solutions?

Problems

Problem 1

Solve by substitution: $y = 2x - 1$ and $3x + 2y = 12$.

Show solutionHide solution

The first equation gives $y$ in terms of $x$, so substitute it into the second: $3x + 2(2x - 1) = 12$, that is, $7x - 2 = 12$, so $x = 2$. Then $y = 2 \times 2 - 1 = 3$.

Check in the second equation: $3 \times 2 + 2 \times 3 = 12$. The solution is $(2, 3)$.

Problem 2

Solve by elimination: $x + y = 9$ and $x - y = 3$. Then describe the two lines and their crossing point.

Show solutionHide solution

Adding the equations cancels $y$: $2x = 12$, so $x = 6$. Subtracting the second from the first cancels $x$: $2y = 6$, so $y = 3$.

Check: $6 + 3 = 9$ and $6 - 3 = 3$. The first line is $y = -x + 9$, falling with slope $-1$, and the second is $y = x - 3$, rising with slope 1. They cross at $(6, 3)$.

Problem 3

A parking lot holds motorcycles and cars: 30 vehicles and 96 wheels in all. Solve it twice, once by the “hand out the wheels” argument in words, and once by writing equations and eliminating.

Show solutionHide solution

In words. Give every vehicle two wheels: that uses 60. The remaining $96 - 60 = 36$ wheels belong to cars, two more for each, so there are 18 cars and $30 - 18 = 12$ motorcycles.

With equations. Let $m$ be the number of motorcycles and $k$ the number of cars: $m + k = 30$ and $2m + 4k = 96$. Subtracting twice the first equation from the second gives $2k = 36$, so $k = 18$ and $m = 12$.

Check: $12 \times 2 + 18 \times 4 = 24 + 72 = 96$. Each sentence of the first argument is one line of the second.

Problem 4

Solve $4x + 3y = 5$ and $6x - 5y = 17$.

Show solutionHide solution

To cancel $x$, scale so both equations carry $12x$: three times the first is $12x + 9y = 15$, and twice the second is $12x - 10y = 34$. Subtract the second of these from the first: $9y - (-10y) = 15 - 34$, so $19y = -19$ and $y = -1$.

Put this into the first original equation: $4x - 3 = 5$, so $x = 2$.

Check in the second: $6 \times 2 - 5 \times (-1) = 12 + 5 = 17$. The solution is $(2, -1)$.

Problem 5

For each system, compute $D = a_1b_2 - a_2b_1$ and decide how many solutions there are: (a) $2x - y = 4$, $-4x + 2y = 3$; (b) $2x - y = 4$, $-4x + 2y = -8$; (c) $2x - y = 4$, $x + 2y = 7$.

Show solutionHide solution

(a) $D = 2 \times 2 - (-4) \times (-1) = 4 - 4 = 0$. Adding twice the first equation to the second gives $0 = 11$, which is false. No solution: the lines are parallel.

(b) $D = 0$ again. Adding twice the first to the second gives $0 = 0$. The second equation is $-2$ times the first, so the lines are the same and there are infinitely many solutions, namely all points with $y = 2x - 4$.

(c) $D = 2 \times 2 - 1 \times (-1) = 5 \ne 0$, so there is exactly one solution. Twice the first plus the second gives $5x = 15$, so $x = 3$, and then $y = 2 \times 3 - 4 = 2$. Check: $3 + 2 \times 2 = 7$.

Problem 6

A boat travels 24 km downstream in 2 hours, and takes 3 hours to return upstream. Assume the boat’s speed through the water and the speed of the current are both constant. Find them.

Show solutionHide solution

Let $b$ be the boat’s speed through the water and $w$ the speed of the current, in km per hour. Going downstream the current helps, so the speed over the ground is $b + w = \frac{24}{2} = 12$. Going upstream it hinders: $b - w = \frac{24}{3} = 8$.

Adding the equations gives $2b = 20$, so $b = 10$. Subtracting gives $2w = 4$, so $w = 2$.

Check: downstream at $10 + 2 = 12$ km/h for 2 hours is 24 km, and upstream at $10 - 2 = 8$ km/h for 3 hours is 24 km. The boat makes 10 km/h and the current runs at 2 km/h.

Problem 7

For which value of $k$ does the system $2x + 3y = 6$, $4x + ky = 5$ have no solution? For that $k$, is there any right-hand side in place of 5 that would give infinitely many solutions?

Show solutionHide solution

The system fails to have exactly one solution when $D = 2k - 4 \times 3 = 2k - 12 = 0$, that is, when $k = 6$. For $k = 6$, subtracting twice the first equation from the second gives $0 = 5 - 12 = -7$, which is false, so there is no solution. For every other $k$ there is exactly one.

With $k = 6$ and a right-hand side $s$ in place of 5, the same subtraction gives $0 = s - 12$. This is true exactly when $s = 12$, and then the second equation, $4x + 6y = 12$, is twice the first, so the lines coincide and there are infinitely many solutions.

Problem 8

Find the error. “Take the system $x + y = 5$, $2x + 2y = 10$. Subtracting twice the first equation from the second gives $0 = 0$. From the first equation $y = 5 - x$, and choosing $x = 1$ gives $y = 4$. Therefore the solution of the system is $(1, 4)$.”

Show solutionHide solution

Every computation is correct, and $(1, 4)$ is a solution: $1 + 4 = 5$ and $2 + 8 = 10$. The error is the word “the”. The second equation is twice the first, so $D = 1 \times 2 - 2 \times 1 = 0$ and the combined equation $0 = 0$ imposes no condition. The system has the same solutions as $x + y = 5$ alone, an entire line of them, and $x = 1$ was a free choice. Choosing $x = 2$ gives $(2, 3)$, which is just as good. The correct conclusion is that the solutions are all pairs $(x, 5 - x)$.

Shared definitions used by this lesson's figures
# house kit: prepended to every essay figure after the std imports

# palette. AZURE and EMBER are the two actors, LEAF marks an answer, ROSE a problem
let PAPER = [1, 1, 1, 1]
let INK = [0.08, 0.09, 0.11, 1]
let SLATE = [0.40, 0.44, 0.50, 1]
let MIST = [0.85, 0.86, 0.88, 1]
let AZURE = [0.13, 0.42, 0.68, 1]
let EMBER = [0.89, 0.42, 0.12, 1]
let LEAF = [0.13, 0.55, 0.36, 1]
let ROSE = [0.78, 0.22, 0.24, 1]
let PLUM = [0.47, 0.30, 0.66, 1]
let GOLD = [0.85, 0.62, 0.08, 1]

background = PAPER

# an opaque pastel of col; use for fills so overlaps do not darken
let tint = |col, amount = 0.18| [
    1 - (1 - col[0]) * amount,
    1 - (1 - col[1]) * amount,
    1 - (1 - col[2]) * amount,
    1
]

# text: Cap for labels, Note for quiet labels, Math for typeset maths
let Cap = |txt, size = 0.75, col = INK| color{col} Text(txt, size, "Charter")
let Note = |txt, size = 0.65| color{SLATE} Text(txt, size, "Charter")
let Math = |tex, size = 0.9, col = INK| color{col} Tex(tex, size)

# a paper rectangle to sit behind text that crosses lines
let Plate = |pos, size| center{pos} fill{PAPER} stroke{alpha{0} PAPER, 0} Rect(size)

# shapes with fill and stroke both set, so no stray black appears
let Pt = |pos, col = INK, r = 0.075| center{pos} fill{col} stroke{col, 1} Circle(r, 48)
let Ring = |pos, col = INK, r = 0.1, w = 3| center{pos} fill{PAPER} stroke{col, w} Circle(r, 48)
let Seg = |a, b, col = INK, w = 3| stroke{col, w} Line(a, b)
let Path = |pts, col = INK, w = 3| stroke{col, w} Polyline(pts)
let Region = |pts, col| fill{col} stroke{alpha{0} col, 0} Polygon(pts)
let Outline = |pts, col = INK, w = 3| fill{alpha{0} PAPER} stroke{col, w} Polygon(pts)
let Shape = |pts, col, amount = 0.18, w = 3| fill{tint(col, amount)} stroke{col, w} Polygon(pts)
let Disc = |pos, r, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Circle(r, 96)
let Box = |pos, size, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Rect(size)
# a line from a to b ending in a small solid arrowhead
let Tip = |a, b, col = INK, w = 3, head = 0.17| {
    let d = normalize([b[0] - a[0], b[1] - a[1], 0])
    let n = [-d[1], d[0], 0]
    let base = [b[0] - d[0] * head, b[1] - d[1] * head, 0]
    return [
        stroke{col, w} Line(a, base),
        fill{col} stroke{col, 1} Polygon([
            b,
            [base[0] + n[0] * head * 0.42, base[1] + n[1] * head * 0.42, 0],
            [base[0] - n[0] * head * 0.42, base[1] - n[1] * head * 0.42, 0]
        ])
    ]
}

# plots. a frame is [x0, x1, y0, y1, centre, width, height]: a data window and the scene box it fills
let Frame = |x0, x1, y0, y1, c = [0, 0, 0], w = 6.4, h = 3.6| [x0, x1, y0, y1, c, w, h]
let fx = |fr, x| fr[4][0] + (x - (fr[0] + fr[1]) / 2) * fr[5] / (fr[1] - fr[0])
let fy = |fr, y| fr[4][1] + (y - (fr[2] + fr[3]) / 2) * fr[6] / (fr[3] - fr[2])
let at = |fr, x, y| [fx(fr, x), fy(fr, y), 0]

# axes through the data origin (or the nearest edge of the window), with optional names
let Axes = |fr, x_name = "", y_name = "", col = SLATE| {
    let ox = clamp(fr[0], 0, fr[1])
    let oy = clamp(fr[2], 0, fr[3])
    var parts = [
        Tip(at(fr, fr[0], oy), [fx(fr, fr[1]) + 0.25, fy(fr, oy), 0], col, 2.5, 0.15),
        Tip(at(fr, ox, fr[2]), [fx(fr, ox), fy(fr, fr[3]) + 0.25, 0], col, 2.5, 0.15)
    ]
    if (x_name != "") {
        parts .= center{[fx(fr, fr[1]) + 0.5, fy(fr, oy), 0]} Math(x_name, 0.8, col)
    }
    if (y_name != "") {
        parts .= center{[fx(fr, ox), fy(fr, fr[3]) + 0.5, 0]} Math(y_name, 0.8, col)
    }
    return parts
}

# tick marks with numbers at the listed data values
let XTicks = |fr, xs, col = SLATE, places = 0| block {
    let oy = fy(fr, clamp(fr[2], 0, fr[3]))
    for (x in xs) {
        . Seg([fx(fr, x), oy - 0.07, 0], [fx(fr, x), oy + 0.07, 0], col, 2)
        . center{[fx(fr, x), oy - 0.33, 0]} Math(to_string(x, places), 0.72, col)
    }
}
let YTicks = |fr, ys, col = SLATE, places = 0| block {
    let ox = fx(fr, clamp(fr[0], 0, fr[1]))
    for (y in ys) {
        . Seg([ox - 0.07, fy(fr, y), 0], [ox + 0.07, fy(fr, y), 0], col, 2)
        . center{[ox - 0.36, fy(fr, y), 0]} Math(to_string(y, places), 0.72, col)
    }
}

# faint grid lines at the listed data values
let GridLines = |fr, xs, ys, col = MIST| block {
    for (x in xs) {
        . Seg(at(fr, x, fr[2]), at(fr, x, fr[3]), col, 1.5)
    }
    for (y in ys) {
        . Seg(at(fr, fr[0], y), at(fr, fr[1], y), col, 1.5)
    }
}

# the graph of f over [a, b], drawn in the frame. values are clamped to the window
let Graph = |fr, f, a, b, col = AZURE, w = 4, n = 160|
    stroke{col, w} Polyline(map(sample(a, b, n), |x| at(fr, x, clamp(fr[2], f(x), fr[3]))))

# the region between the graph of f and the x axis over [a, b]
let AreaUnder = |fr, f, a, b, col = AZURE, amount = 0.2, n = 80| {
    var pts = [at(fr, a, 0)]
    for (x in sample(a, b, n)) {
        pts .= at(fr, x, clamp(fr[2], f(x), fr[3]))
    }
    pts .= at(fr, b, 0)
    return fill{tint(col, amount)} stroke{alpha{0} col, 0} Polygon(pts)
}

# the running example: c chickens and r rabbits with 10 heads and 28 legs
# plotted with chickens across and rabbits up, on a square grid
let fz = Frame(0, 15.5, 0, 11.5, [-1.15, 0.2, 0], 4.1, 3.04)
let ZooPlot = [
    GridLines(fz, range(1, 16), range(1, 12)),
    Axes(fz),
    XTicks(fz, [2, 4, 6, 8, 10, 12, 14]),
    YTicks(fz, [2, 4, 6, 8, 10]),
    center{[fx(fz, 15.5) - 0.45, fy(fz, 0) - 0.63, 0]} Note("chickens", 0.72),
    center{[fx(fz, 0) + 0.7, fy(fz, 11.5) + 0.25, 0]} Note("rabbits", 0.72)
]
let heads_r = |c| 10 - c
let legs_r = |c| 7 - c / 2
let HeadDots = map(range(0, 11), |c| Pt(at(fz, c, heads_r(c)), AZURE, 0.07))
let LegDots = map(range(0, 8), |j| Pt(at(fz, 2 * j, legs_r(2 * j)), EMBER, 0.07))
let HeadLine = Seg(at(fz, 0, 10), at(fz, 10, 0), AZURE, 3)
let LegLine = Seg(at(fz, 0, 7), at(fz, 14, 0), EMBER, 3)
# the part inside the frame of the line through (px, py) with direction (dx, dy)
let Through = |fr, px, py, dx, dy, col = INK, w = 4| {
    var lo = -1000
    var hi = 1000
    if (abs(dx) > 0.00001) {
        let s1 = (fr[0] - px) / dx
        let s2 = (fr[1] - px) / dx
        lo = max(lo, min(s1, s2))
        hi = min(hi, max(s1, s2))
    }
    if (abs(dy) > 0.00001) {
        let s1 = (fr[2] - py) / dy
        let s2 = (fr[3] - py) / dy
        lo = max(lo, min(s1, s2))
        hi = min(hi, max(s1, s2))
    }
    return Seg(at(fr, px + lo * dx, py + lo * dy), at(fr, px + hi * dx, py + hi * dy), col, w)
}
let Row = |y, name, col = SLATE| center{[2.3, y, 0]} Cap(name, 0.74, col)