TExcelTAD
Home › Algebra › Introduction to Algebra

Introduction to Algebra

Algebra uses letters to stand for numbers, so that one statement can describe a whole family of calculations and so that an unknown quantity can be found by reasoning instead of guessing. This lesson explains what a variable is, the difference between an expression and an equation, and the basic idea behind solving.

From arithmetic to algebra

Arithmetic answers questions about specific numbers: 7×4+3=317 \times 4 + 3 = 31. Algebra lets you talk about every number at once. Suppose a gym charges a €25 sign-up fee and €18 per month. Instead of a table of prices, one line covers every case:

cost=25+18mwhere m is the number of months\text{cost} = 25 + 18m \qquad \text{where } m \text{ is the number of months}

The letter mm is a variable: a name for a number that can change, or that we do not know yet. The idea is the same as a variable in code, with one difference. In a program, m = 4 is an instruction: "store 4 in m". In algebra, m=4m = 4 is a statement: "mm equals 4", which is either true or false.

Expressions and equations

Kind Example Has an = sign? What you do with it
Expression 25+18m25 + 18m no evaluate it or simplify it
Equation 25+18m=13325 + 18m = 133 yes solve it: find mm
Formula A=l⋅wA = l \cdot w yes a rule linking several quantities
Inequality 25+18m≤20025 + 18m \le 200 no (≤\le, <<, ≥\ge, >>) find all mm that make it true

An expression is like a function body that has not been called. You can evaluate it by putting in a value:

python · try it yourself
def cost(m):
    return 25 + 18 * m

for months in [1, 3, 6, 12]:
    print(months, "months:", cost(months), "euros")
1 months: 43 euros
3 months: 79 euros
6 months: 133 euros
12 months: 241 euros

Solving: running the rule backwards

The table says 6 months cost €133. But what if the question is "I paid €133; how many months?" That is the equation 25+18m=13325 + 18m = 133. You could try values until one fits, which is how the loop below works, but algebra gets there directly:

25+18m=13318m=108subtract 25 from both sidesm=6divide both sides by 18\begin{aligned} 25 + 18m &= 133 \\ 18m &= 108 && \text{subtract 25 from both sides} \\ m &= 6 && \text{divide both sides by 18} \end{aligned}

The key rule: an equation stays true if you do the same thing to both sides (add, subtract, multiply or divide by the same non-zero number). Each step peels one operation off the variable, in reverse order of how it was applied. You first met this in Solving Equations.

python · try it yourself
# guessing versus solving
target = 133
for m in range(0, 20):           # brute force: try every m
    if 25 + 18 * m == target:
        print("found by search:", m)
        break

print("found by algebra:", (target - 25) / 18)
print("paid 150, by algebra:", (150 - 25) / 18)
found by search: 6
found by algebra: 6.0
paid 150, by algebra: 6.944444444444445

The last line shows why algebra beats guessing. A search over whole months could never find an answer for €150, because (150−25)/18=6.944…(150 - 25)/18 = 6.944\ldots is not a whole number. Algebra gives the answer whether or not it is a "nice" one, and it tells you at once that €150 buys 6 full months with money left over.

Why letters are powerful

  • Generality. a+b=b+aa + b = b + a is true for every pair of numbers. One line states infinitely many facts.
  • Unknowns. A letter holds the place of a number you have not found yet, so you can write down what you know about it and then work out its value.
  • Relationships. A formula like distance=speed×time\text{distance} = \text{speed} \times \text{time} connects quantities. Knowing any two gives the third.

Tip: Choose letters that remind you of the quantity: mm for months, tt for time, pp for price. In code you would pick meaningful names, and the same habit helps on paper.

In software

Code is written in the language of algebra. A function def f(x): return 3*x + 2 is an expression with a variable. A config value like timeout = base * 2**attempt is a formula. And every time you invert a calculation, such as converting a pixel position back into a data value or a final price back into a pre-tax price, you are solving an equation.

Exercises

Exercise 1: Evaluate

Evaluate 4n−74n - 7 for n=3n = 3, n=0n = 0 and n=−2n = -2.

Answer

5, −7 and −15

Solution
n=3:4⋅3−7=12−7=5n=0:4⋅0−7=−7n=−2:4⋅(−2)−7=−8−7=−15\begin{aligned} n = 3{:}&\quad 4 \cdot 3 - 7 = 12 - 7 = 5 \\ n = 0{:}&\quad 4 \cdot 0 - 7 = -7 \\ n = -2{:}&\quad 4 \cdot (-2) - 7 = -8 - 7 = -15 \end{aligned}

Exercise 2: Expression or equation?

Classify each: (a) 9−2y9 - 2y, (b) 9−2y=19 - 2y = 1, (c) P=2l+2wP = 2l + 2w, (d) 3k>123k > 12.

Answer

(a) expression, (b) equation, (c) formula (an equation linking several variables), (d) inequality.

Solution

An expression has no relation sign. (b) has == and one unknown, so it is an equation you can solve (y=4y = 4). (c) is an equation relating perimeter, length and width. (d) uses >>, so it is an inequality, true for every k>4k > 4.

Exercise 3: Solve the gym question

With cost=25+18m\text{cost} = 25 + 18m, how many months can you get for €259?

Answer

m=13m = 13

Solution
25+18m=25918m=234m=13check: 25+18⋅13=25+234=259 ✓\begin{aligned} 25 + 18m &= 259 \\ 18m &= 234 \\ m &= 13 \\[1ex] &\text{check: } 25 + 18 \cdot 13 = 25 + 234 = 259\ \checkmark \end{aligned}

Exercise 4: Write the inverse function

Write months_for(cost) that inverts cost=25+18m\text{cost} = 25 + 18m, and print it for 79 and 241.

Answer

3.0 and 12.0

Solution

Solving cost=25+18m\text{cost} = 25 + 18m for mm gives m=(cost−25)/18m = (\text{cost} - 25)/18.

python · try it yourself
def months_for(cost):
    return (cost - 25) / 18

print(months_for(79), months_for(241))
3.0 12.0

Test yourself

What is the difference between 2x+52x + 5 and 2x+5=112x + 5 = 11?

  1. None, they are the same
  2. The first is an expression, the second is an equation you can solve
  3. The first is an equation, the second is an expression
  4. Both are formulas

In algebra, what does the statement m=4m = 4 mean?

  1. Store 4 in m
  2. mm is a constant forever
  3. mm equals 4; the statement is true or false
  4. mm is greater than 4

Which step is allowed when solving an equation?

  1. Add 5 to the left side only
  2. Divide both sides by 0
  3. Multiply both sides by the same non-zero number
  4. Square only the right side