Sub topic 2
Choosing and Defining a Variable
This chapter assumes you can do arithmetic with integers, fractions, and decimals, follow the order of operations, and read a simple expression such as 3x + 2. It also assumes you have already read a problem and listed what is asked and what is given. Here you take the next step: turning the unknown into a variable you can calculate with.
Why the definition comes first
A variable is a letter that stands for a number you do not yet know. The equation you write later is only as good as the meaning you gave that letter. If you cannot say exactly what x counts, you cannot tell whether x + 15 is sensible, and you cannot interpret the answer.
Most setup mistakes in word problems trace back to a vague definition. "Let x be the tickets" leaves open whether x counts adult tickets, child tickets, or all tickets. The equation will then mix them without you noticing.
What a complete definition contains
A good definition has three parts:
- The quantity. Name exactly what the letter measures, including whose quantity it is.
- The unit. Say what it is measured in: dollars, hours, years, centimeters, tickets.
- The direction of counting. State the starting point when it matters, such as "hours since Car A left" or "years from now".
Write the definition as a full sentence, in the form "Let letter = quantity in unit."
| Weak definition | Strong definition |
|---|---|
| Let a = adults | Let a = the number of adult tickets sold |
| Let t = time | Let t = hours Car A has traveled when Car B catches up |
| Let x = Lee | Let l = the amount of money Lee has, in dollars |
| Let p = price | Let p = the original price of the jacket, in dollars, before the discount |
The weak versions name a person or a vague idea. The strong versions name a number with a unit. A letter should always stand for a number, never for a thing or a person.
Deciding which quantity gets the letter
Many problems mention several unknowns. You need to pick one to name directly. Two rules usually give a good choice.
- Use the quantity the question asks for. If the final answer is the original price, let
pbe the original price. You then get the answer straight from the solution, with no extra step. - Use the base quantity when others are compared to it. If one amount is described as "3 times" or "15 more than" another, let the letter stand for the one being compared against. The others then become simple expressions.
The second rule matters because the choice changes how hard the algebra is. Take this problem: a 120 cm board is cut into two pieces, and the long piece is 3 times as long as the short piece. The code below solves it twice, once with each choice.
from fractions import Fraction
total = 120
# Choice 1: let s = length of the short piece, in cm.
# Long piece = 3s, so s + 3s = 120.
s = Fraction(total, 4)
print(s, 3 * s) # 30 90
# Choice 2: let x = length of the long piece, in cm.
# Short piece = x/3, so x + x/3 = 120.
x = Fraction(total) / (1 + Fraction(1, 3))
print(x, x / 3) # 90 30Both choices reach the same pieces, 30 cm and 90 cm. Choice 1 keeps whole numbers throughout. Choice 2 introduces x/3, which is correct but easier to get wrong by hand. When you have a free choice, let the letter stand for the smaller or base quantity, so the other quantities are multiples of it and not fractions of it.
Expressing the other unknowns
Once one quantity has a letter, every other unknown should become an expression in that letter. That way the equation contains only one unknown.
Three patterns cover most problems.
- Part of a known total. If there are 10 tickets in all and
aare adult tickets, the child tickets are10 - a. - Compared by a difference. If Sam has $15 more than Lee, and Lee has
ldollars, Sam hasl + 15dollars. - Compared by a multiple. If the long piece is 3 times the short piece, and the short piece is
scm, the long piece is3scm.
The code below uses the difference pattern. Lee and Sam together have $85, and Sam has $15 more than Lee.
# Let l = the number of dollars Lee has.
# Sam has l + 15 dollars. Together: l + (l + 15) = 85, so 2l + 15 = 85.
total = 85
difference = 15
l = (total - difference) / 2
s = l + difference
print(l, s) # 35.0 50.0
print(l + s == total) # True
print(s - l == difference) # TrueThe two checks at the end test the wording of the problem, not just the equation. The amounts add to $85, and Sam's amount exceeds Lee's by $15.
Units are part of the definition
The unit you choose for the variable must match the units in the rest of the problem. A mismatch produces an equation that looks fine and gives a wrong answer.
Suppose a car travels at 60 miles per hour and the problem gives a time in minutes. If you let t be minutes, the distance is not 60t. You have two options:
- Let
tbe hours, and convert any given minutes to hours first (30 minutes is 0.5 hours). - Keep minutes, and convert the rate to 1 mile per minute.
Either works. Pick one, write it in the definition, and convert every given number to match. Writing "in hours" next to the letter is a cheap reminder.
Direction matters: "more than" and "less than"
Defining the variable correctly includes keeping track of who is compared with whom. "Sam has $15 more than Lee" means Sam = Lee + 15. If you write l = s + 15, you have reversed the relationship, and the equation will still solve, to a wrong answer.
A reliable test is to substitute a made-up number. If Lee has $10, then Sam should have $25. The expression l + 15 gives 25, so it matches. The reversed expression l - 15 gives -5, which is clearly wrong for Sam since he has more.
A worked example from definition to answer
A school sells 10 tickets to a show. Adult tickets cost $8 and child tickets cost $5. The total is $62. How many adult tickets were sold?
- Unknown asked for: the number of adult tickets.
- Definition: Let
a= the number of adult tickets sold. This is a count, so there is no currency unit, but the quantity is clear. - Other quantities: child tickets =
10 - a. - Money from each type: adults bring in
8adollars, children bring in5(10 - a)dollars. - Equation:
8a + 5(10 - a) = 62, which reduces to3a + 50 = 62.
from fractions import Fraction
# 10 tickets total, adult $8, child $5, total $62. Let a = number of adults.
# 8a + 5(10 - a) = 62 -> 3a + 50 = 62
a = Fraction(62 - 50, 3)
print(a, 10 - a) # 4 6
print(8 * a + 5 * (10 - a) == 62) # TrueThere were 4 adult tickets and 6 child tickets. Notice that the solution depends on the definition at every step: the 10 - a and the dollar amounts only make sense because a was defined as a count of adult tickets.
Common definition mistakes
- Naming a thing, not a number. "Let x = the jacket" cannot be used in arithmetic. Say "the original price of the jacket, in dollars".
- Skipping the unit. The letter works in the equation, but you may report the answer in the wrong unit.
- Defining the result of a step. If the problem asks for the original price, do not let
pbe the sale price unless you plan an extra step at the end. - Choosing a quantity that forces fractions. As in the board example, this is correct but riskier by hand.
- Introducing two letters when one suffices. Two unknowns need two equations. Use a second letter only when you genuinely cannot express one unknown through the other, a case covered later in the chapter on systems.
Exercise
A rectangle's length is 4 cm more than its width, and its perimeter is 36 cm. Write a complete definition of a variable for the width, and write the expression for the length.
Show answer
Let w = the width of the rectangle, in centimeters. The length is w + 4 centimeters. (Choosing the width as the base makes the length a simple expression. The equation would then be 2w + 2(w + 4) = 36.)
Exercise
A store sells a notebook for $2 less than twice the price of a pen. Let p = the price of a pen, in dollars. Write the price of a notebook as an expression, then test your expression with a pen price of $3.
Show answer
The notebook costs 2p - 2 dollars. With p = 3, the notebook costs 2(3) - 2 = $4, which is $2 less than twice $3 ($6). The test confirms the direction of "less than".
Exercise
A trip takes 45 minutes at 40 miles per hour. A student writes "let t = time" and the distance as 40t. Explain what is wrong, and give a corrected definition and distance expression for the case where t is a number of minutes.
Show answer
"Time" has no unit, and 40t is only correct if t is in hours, because the rate is in miles per hour. If t is in minutes, convert the rate: 40 miles per hour is 40/60 = 2/3 mile per minute, so the distance is (2/3)t miles. The corrected definition is: let t = the travel time in minutes. (Alternatively, let t = 0.75 hours and use 40t.)