Sub topic 11
Writing expressions from word descriptions
This chapter assumes you can evaluate an expression by substitution and can recognize terms, coefficients, and like terms. It also assumes you know the order of operations. Here you go the other way: you start with a sentence and build the expression it describes.
Why translation is its own skill
Earlier chapters started with an expression and worked on it. Real problems usually start with words, such as "a taxi charges a $3 fee plus $2 per mile." Before you can simplify or evaluate anything, you have to turn that sentence into symbols.
A translation is an expression, not an equation. It has no equals sign unless the sentence says two things are equal. The phrase "five more than a number" becomes n + 5. It does not become n + 5 = something.
A repeatable process
Translation goes wrong when you try to do it in one jump. Work in steps instead.
Step 2 matters more than it looks. Write "let n be the number of tickets" before you use n. If you skip this, you may use the same letter for two different quantities later without noticing.
Vocabulary for operations
Most phrases map to one of the four operations. This table covers the common ones.
| Operation | Phrases | Example | Expression |
|---|---|---|---|
| Addition | sum, plus, more than, increased by, total of | 7 more than a number | `n + 7` |
| Subtraction | difference, minus, decreased by, less than, subtracted from | 7 less than a number | `n - 7` |
| Multiplication | product, times, twice, double, triple, of (with a fraction or percent) | twice a number | `2n` |
| Division | quotient, divided by, per, ratio of, half of | a number divided by 4 | `n / 4` |
| Exponent | squared, cubed, square of | the square of a number | `n^2` |
The table is a guide, not a dictionary. The same word can behave differently depending on its sentence, so read the whole phrase before you pick an operation.
Order traps in subtraction
Addition and multiplication give the same result in either order, so "7 more than n" and "n plus 7" both give n + 7. Subtraction does not. Some phrases reverse the order in which the quantities appear in the sentence.
| Phrase | Expression | Why |
|---|---|---|
| the difference of `n` and 5 | `n - 5` | Same order as written. |
| `n` minus 5 | `n - 5` | Same order as written. |
| subtract 5 from `n` | `n - 5` | Reversed: the thing you subtract from comes after "from". |
| 5 less than `n` | `n - 5` | Reversed: you start from the quantity after "than". |
| `n` less than 5 | `5 - n` | You start from 5. |
The word "than" and the word "from" are the signals. The quantity that follows them is the one you start with. You can confirm this with numbers.
from sympy import symbols
n = symbols('n')
five_less_than_n = n - 5
n_less_than_five = 5 - n
print(five_less_than_n.subs(n, 12)) # 7
print(n_less_than_five.subs(n, 12)) # -7Both phrases contain the same words, but with n = 12 they give 7 and -7. They are different expressions.
Grouping: when a phrase acts as one unit
Some phrases tell you to build one quantity first and then use it as a whole. Words like "sum," "difference," "product," and "quantity" often mark this. The translation needs parentheses.
- "Twice the sum of
xand 3" means2(x + 3). The sum is built first, then doubled. - "The sum of twice
xand 3" means2x + 3. The doubling is built first, then 3 is added. - "Twice
x, plus 3" means2x + 3. The comma ends the doubling.
The two similar-looking phrases give different expressions. A test value shows it.
from sympy import symbols, expand
x = symbols('x')
twice_the_sum = 2 * (x + 3)
sum_of_twice = 2 * x + 3
print(twice_the_sum.subs(x, 4)) # 14
print(sum_of_twice.subs(x, 4)) # 11
print(expand(twice_the_sum)) # 2*x + 6The last line uses the distributive property from the earlier chapter. 2(x + 3) and 2x + 6 are equivalent, but neither is equivalent to 2x + 3.
A useful reading habit is to find the main operation of the sentence first. "Twice the sum of x and 3" is mainly a doubling, so the outermost structure is 2 × (...). "The sum of twice x and 3" is mainly an addition, so the outermost structure is (...) + 3.
Fixed amounts and rates
Many word problems describe a fixed amount plus a rate times a quantity. The rate multiplies the variable. The fixed amount is a constant term.
A taxi charges a $3 fee plus $2 per mile. Let m be the number of miles. The cost in dollars is 3 + 2m. The constant 3 is the fee, and the coefficient 2 is the rate. Reading it back this way is a good check: if you cannot say what each term means in the story, the translation is probably wrong.
from sympy import symbols
m = symbols('m')
cost = 3 + 2 * m
for miles in (0, 1, 5):
print(miles, cost.subs(m, miles))
# 0 3
# 1 5
# 5 13At 0 miles the cost is still $3, which matches the fee. This is the kind of sanity check you should run before moving on.
Words such as "per," "each," and "every" signal a rate. In "$4 per ticket," 4 is the coefficient and the number of tickets is the variable, so the cost is 4t.
Several quantities in one expression
When a sentence has more than one unknown, you have two choices. Use two variables, or express one unknown in terms of the other.
Suppose Ana is a years old, and Ben is 3 years older than twice Ana's age. Ben's age is 2a + 3. The total of their ages is a + (2a + 3). That total contains like terms, so you can simplify it.
from sympy import symbols, expand
a = symbols('a')
ben = 2 * a + 3
total = a + ben
print(total) # 3*a + 3
print(expand(total)) # 3*a + 3Here you used only one variable, because Ben's age depends on Ana's. That is usually the better choice when the sentence defines one quantity from another. Use two variables when the quantities are independent, as in "adult tickets cost $12 and child tickets cost $7." With a adult tickets and c child tickets, the total cost is 12a + 7c. The two terms are not like terms, so the expression stays as it is.
Percent phrases
"Of" after a percent usually means multiplication, and "more than" or "less than" a percent of something adds or subtracts that product. A price p increased by 15% is p + 0.15p. Those two terms are like terms, so they combine.
from sympy import symbols, expand
p = symbols('p')
increased = p + 0.15 * p
print(expand(increased)) # 1.15*pThe result 1.15p is a shortcut worth remembering. A 15% increase is the same as multiplying by 1.15. A 15% decrease is p - 0.15p, which is 0.85p.
Checking a translation
After you write an expression, pick a number that is easy to work with and run the story by hand. Then substitute the same number into the expression. If both give the same answer, the translation is probably right.
For "3 less than the product of 4 and a number," choose the number 10. The story gives a product of 40, then 3 less than that is 37. The expression 4n - 3 gives 4(10) - 3 = 37. A common wrong version, 3 - 4n, gives -37, so the check catches it.
Pick a test number that is not 0 or 1. Those values hide mistakes because n + n and n * n and 2n can all agree at some of them. Using 0, 1, or 2 together can make wrong expressions look right.
Common translation errors
- Reversing the order for "less than" and "subtracted from" (
5 - ninstead ofn - 5). - Leaving out parentheses around a sum or difference that a phrase treats as one unit.
- Writing
0.15pfor "15% more than p" and forgetting to add the original amount. - Using the same letter for two different quantities in one problem.
- Putting an equals sign in an expression that the sentence did not ask you to equate.
- Reading "twice" as an exponent. "Twice
x" is2x, and "xsquared" isx^2.
Exercise
Write an expression for "4 less than three times the sum of a number and 2." Let n be the number. Then simplify it and check with n = 5.
Show answer
The sum of n and 2 is (n + 2). Three times that is 3(n + 2). Four less than that is 3(n + 2) - 4. Distributing gives 3n + 6 - 4, which simplifies to 3n + 2. Check with n = 5: the story gives a sum of 7, times 3 is 21, minus 4 is 17. The expression 3(5) + 2 is also 17.
Exercise
A gym charges a $25 sign-up fee and $18 per month. A second gym charges $30 per month with no fee. Using m for the number of months, write an expression for the first gym's cost and one for the second. Then write the expression for how much more the first gym costs than the second, and simplify it.
Show answer
First gym: 25 + 18m. Second gym: 30m. The first costs this much more than the second: (25 + 18m) - 30m. The parentheses are needed so that the whole first cost is the starting amount. Combining the like terms 18m and -30m gives 25 - 12m. Check with m = 2: the first costs 61, the second 60, so the difference is 1, and 25 - 12(2) = 1.