Sub topic 5
Evaluating an Expression
This chapter assumes you can do arithmetic with integers and fractions, including negative numbers. It also assumes you know the order of operations and what an exponent such as 3^2 means. You should already know what a variable, a coefficient, and a term are from the earlier chapters.
What evaluating means
To evaluate an expression is to find its numerical value when each variable is replaced by a specific number. The replacement step is called substitution. After you substitute, no letters remain. What is left is a numerical expression, and you simplify it with the usual arithmetic rules.
Take the expression 3x + 2y - 4. Suppose x = 5 and y = 2. Replace each letter with its number:
3(5) + 2(2) - 4
Then calculate: 15 + 4 - 4 = 15. The value of the expression is 15 when x = 5 and y = 2.
The value depends on the numbers you choose. The same expression gives a different result for x = 1 and y = 0: 3(1) + 2(0) - 4 = -1. An expression is a rule for producing a number from other numbers. It is not a single fixed number.
A reliable procedure
Follow these steps every time. They look slow at first, but they prevent most errors.
- Rewrite the expression with every variable replaced by parentheses, for example 3( ) + 2( ) - 4.
- Place the given value inside each pair of parentheses.
- Apply the order of operations: parentheses, then exponents, then multiplication and division from left to right, then addition and subtraction from left to right.
- Write each step on its own line, so you can find a mistake later.
The parentheses in step 1 matter most when a value is negative or a fraction. They keep the sign and the operation attached to the right number.
Worked examples
Example 1: two variables
Evaluate 4a + 3b - 7 when a = 2 and b = -3.
- Substitute: 4(2) + 3(-3) - 7
- Multiply: 8 + (-9) - 7
- Add and subtract from left to right: 8 - 9 = -1, then -1 - 7 = -8
The value is -8.
Example 2: a negative value and an exponent
Evaluate x^2 + 5x when x = -4.
- Substitute: (-4)^2 + 5(-4)
- Apply the exponent first: (-4)^2 = 16
- Multiply: 5(-4) = -20
- Add: 16 + (-20) = -4
The value is -4.
Here the parentheses decide the answer. Without them, -4^2 would be read as -(4^2) = -16, which is a different number. The exponent applies only to what is directly next to it. Writing (-4)^2 makes it apply to the whole negative number.
Example 3: a fraction
Evaluate (1/2)n + 6 when n = 8.
- Substitute: (1/2)(8) + 6
- Multiply: 4 + 6
- Add: 10
The value is 10.
Example 4: a variable in a denominator
Evaluate 12/t + t when t = 3.
- Substitute: 12/3 + 3
- Divide: 4 + 3
- Add: 7
The value is 7. Every variable is replaced everywhere it appears, including in the denominator.
Same letter, same number
If a letter appears more than once, give it the same value each time. In 2x + x^2 - x with x = 3, every x becomes 3:
2(3) + (3)^2 - (3) = 6 + 9 - 3 = 12
Different letters can hold the same number or different numbers. The expression does not require them to differ. If x = 2 and y = 2, then x + y = 4, and that is allowed.
Evaluating expressions with grouping
Parentheses and other grouping symbols are evaluated first. When groups are nested, work from the innermost group outward.
Evaluate 2(x + 3y) - 4 when x = 5 and y = -1.
- Substitute: 2(5 + 3(-1)) - 4
- Innermost multiplication: 3(-1) = -3
- Inside the group: 5 + (-3) = 2
- Multiply: 2(2) = 4
- Subtract: 4 - 4 = 0
The value is 0.
A fraction bar also acts as a grouping symbol. In (x + 4)/(y - 1), the whole numerator and the whole denominator are each computed before you divide. With x = 6 and y = 3, the numerator is 10, the denominator is 2, and the value is 5.
Common errors in evaluation
| Error | Example | What goes wrong | Correct approach |
|---|---|---|---|
| Treating 3x as 3 followed by x | x = 4 gives 34 | Juxtaposition of a coefficient and a variable means multiplication, not digits side by side | 3(4) = 12 |
| Losing parentheses with negatives | x = -2 in 5 - x gives 5 - 2 = 3 | The subtraction of a negative is missed | 5 - (-2) = 7 |
| Wrong exponent target | -3^2 read as 9 | The exponent applies to 3 only | -(3^2) = -9, but (-3)^2 = 9 |
| Adding before multiplying | 2 + 3x with x = 4 gives 5(4) = 20 | Multiplication comes before addition | 2 + 3(4) = 14 |
| Changing the value mid-problem | x = 2 in one place, x = 3 in another | A variable has one value per evaluation | Use the same number for every x |
Pay special attention to the second row. When a variable is negative and is being subtracted, the two minus signs combine into a plus. Writing the substituted number inside parentheses makes the subtraction visible.
Why evaluation matters later
Evaluation is more than an exercise in arithmetic. It gives you a test you can run on your own work. Two expressions that are truly equivalent give the same value for every choice of variables. If you simplify an expression and you want to know whether you made an error, substitute a value into both the original and the simplified version. If the numbers differ, the simplification is wrong. A later chapter develops this idea fully, and the code below previews it.
Checking evaluation with code
SymPy is a Python library for symbolic algebra. Its subs method performs substitution. You give it a dictionary that maps each symbol to a value.
from sympy import symbols
x, y = symbols('x y')
expr = 3*x + 2*y - 4
print(expr.subs({x: 5, y: 2})) # 15
print(expr.subs({x: 1, y: 0})) # -1The two printed values match the hand calculations at the start of this chapter. The same expression gives different results for different inputs.
Negative values and exponents also behave as described above:
from sympy import symbols
x = symbols('x')
expr = x**2 + 5*x
print(expr.subs(x, -4)) # -4In Python, x**2 means x squared. When SymPy substitutes -4, it squares the whole value, so the result is 16 - 20 = -4. This matches Example 2.
One limit of a partial check is worth knowing. If you substitute a single pair of values and the results agree, the expressions might still differ elsewhere. For example, x + x and x^2 both equal 4 when x = 2, yet they are not equivalent. Agreement at one point is evidence, not proof. Disagreement at even one point is proof that the expressions are different. A good habit is to test with two or three values, and to avoid special values such as 0 and 1 that can hide differences, since 0 and 1 raised to any positive power give the same result.
Summary of the key ideas
- Evaluating means substituting numbers for variables and then simplifying with the order of operations.
- Use parentheses around each substituted value, especially negatives and fractions.
- A repeated variable takes the same value everywhere.
- Evaluate grouping symbols first, starting from the innermost group.
- Evaluation lets you test whether a simplified expression matches the original.
Exercise
Evaluate 3x^2 - 2xy + y when x = -2 and y = 5. Show each step.
Show answer
Substitute with parentheses: 3(-2)^2 - 2(-2)(5) + 5. Exponent first: (-2)^2 = 4, so 3(4) = 12. Next, 2(-2)(5) = -20, so subtracting it gives -(-20) = +20. The expression is 12 + 20 + 5 = 37. The value is 37.
Exercise
A student evaluates 10 - 2x when x = -3 and writes 10 - 2(3) = 4. Identify the mistake and give the correct value.
Show answer
The student dropped the negative sign on x. The substitution should be 10 - 2(-3). Multiplying gives 10 - (-6), and subtracting a negative is the same as adding, so the value is 10 + 6 = 16.
Exercise
Show that x + x and x^2 give the same value at x = 2 but are not equivalent expressions. Which test value reveals the difference?
Show answer
At x = 2, x + x = 4 and x^2 = 4, so they agree. At x = 3, x + x = 6 but x^2 = 9, so they differ. One mismatch is enough to prove the expressions are not equivalent.