Sub topic 5
Evaluating an Expression
Assume you know integer and fraction arithmetic, negative numbers, order of operations, and basic exponents such as \(3^2\). This chapter shows how to find the value of an algebraic expression when values are given for its variables.
What evaluation means
To evaluate an expression means to calculate its value. You do this by substitution, which means replacing each variable with its given number.
For example, evaluate \(4x - 7\) when \(x = 3\).
Replace \(x\) with 3:
\[ 4(3) - 7 \]
Then follow the order of operations:
\[ 12 - 7 = 5 \]
Therefore, \(4x - 7 = 5\) when \(x = 3\).
A variable can stand for different numbers in different situations. The expression stays the same, but its value can change.
A reliable substitution process
Use these steps:
- Write the original expression.
- Replace every variable with its assigned value.
- Put substituted values in parentheses, especially negative numbers.
- Apply the order of operations.
- Simplify to one number.
Consider \(2x^2 + 3y\), where \(x = -2\) and \(y = 5\).
\[ 2(-2)^2 + 3(5) \]
Evaluate the exponent first:
\[ 2(4) + 15 \]
Then multiply and add:
\[ 8 + 15 = 23 \]
The value is 23.
Why parentheses matter
Suppose \(x = -3\). These two expressions are different:
\[ x^2 = (-3)^2 = 9 \]
\[ -x^2 = -((-3)^2) = -9 \]
The exponent applies to \(x\) in \(x^2\), but the negative sign is outside the power in \(-x^2\). Writing \((-3)\) during substitution makes the intended grouping visible.
Expressions with several variables
Replace each variable separately. For \(3a - 2b + c\), let \(a = 4\), \(b = -1\), and \(c = 6\).
\[ 3(4) - 2(-1) + 6 \]
Now calculate:
\[ 12 + 2 + 6 = 20 \]
The minus sign before \(2b\) combines with the negative value of \(b\). This creates a positive term.
| Expression | Values | Substituted form | Result |
|---|---|---|---|
| \(3a - 2b + c\) | \(a=4,\ b=-1,\ c=6\) | \(3(4)-2(-1)+6\) | 20 |
Fractions and parentheses
Substitution also works with fractional values. Evaluate
\[ \frac{x+2}{y-1} \]
when \(x = 4\) and \(y = 3\).
Replace the variables:
\[ \frac{4+2}{3-1} \]
Evaluate the numerator and denominator:
\[ \frac{6}{2} = 3 \]
Keep the numerator and denominator grouped. The fraction bar acts like parentheses around both parts.
from sympy import symbols
x, y = symbols("x y")
expression = 3*x + 2*y + 5*x - y
values = {x: 2, y: 1}
print(expression.subs(values)) # 17The program substitutes the values \(x=2\) and \(y=1\), then evaluates the expression. It is a check, not a replacement for showing the mathematical steps.
A visual model
Checking your result
Estimate the expression before calculating exactly. For \(5x - 2\) with \(x=4\), the result should be near \(20\), so \(18\) is reasonable. A result such as \(-22\) suggests a sign error.
You can also substitute the values into the expression twice, using a different order of written steps. Matching results increase confidence that the calculation is correct.
Exercise
Evaluate \(2m^2 - 3n + 4\) when \(m=-3\) and \(n=2\). Show the substitution and calculation.
Show answer
\(2(-3)^2 - 3(2) + 4 = 2(9) - 6 + 4 = 18 - 6 + 4 = 16\).