Evaluating a function at an expression
A function’s input can be a whole expression, such as x plus 2 or 3a. What does the rule do with it, and why is f of (x plus 2) a different thing from f of x, plus 2?
Where you are 3 in Function notation
When you reach for it
You can already evaluate a function at a number: with f(x) = x^2 - 3x - 2, the input 4 goes in wherever x stands, and f(4) = 16 - 12 - 2 = 2. That lesson put a short expression into a linear rule once. Here it is the main move, for any rule: the input is a whole expression, such as x + 2, 3a or -x, and the answer is a new expression rather than a number.
You reach for it to say something about many inputs at once. How much does the output change when the input goes up by 1? That compares f(x + 1) with f(x) for every x together. What happens to a graph when every input is shifted? That is f(x + 2). What such statements mean in a real situation, with units, is function notation in a real situation.
The procedure
The whole expression replaces every x
Take f(x) = x^2 - 3x - 2. The x in the rule only marks where the input goes, so the rule could be written with an empty box in its place:
Whatever goes in the box on the left goes into every box on the right. For f(x + 1):
The brackets are needed because the rule squares the whole input and multiplies the whole input by 3. Without them, x + 1^2 - 3x + 1 - 2 squares only the 1 and multiplies only the x, a different expression. Nor is there a clash in using x twice: the same function is f(t) = t^2 - 3t - 2, and f(x + 1) means “put t = x + 1”.
Simplifying what comes out
The rest is ordinary algebra. The square is a binomial times itself (multiplying two binomials):
The distributive property gives -3(x + 1) = -3x - 3. Then like terms are gathered, reordering with the commutative property:
Check with a number. At x = 2 the left side is f(3) = 9 - 9 - 2 = -2, and the right side is 4 - 2 - 4 = -2. One matching number does not prove the algebra right, but a mismatch proves it wrong.
Squaring a sum
Most of the work is in squares like this, so do it once with letters. Multiply each term of one bracket by each term of the other:
The products xh and hx are equal by the commutative property of multiplication, and together make 2hx. That middle term is why (x + h)^2 and x^2 + h^2 differ: at x = 3, h = 1 the first is 16 and the second 10. In the same way, (x - h)^2 = x^2 - 2hx + h^2. A product in the bracket has every factor squared, (3a)^2 = 9a^2, and (-x)^2 = x^2.
Inside the bracket or outside
In f(x + 2) the 2 is added to the input, before the rule runs. In f(x) + 2 the rule runs first and the 2 is added to the output. In the same way f(2x) doubles the input and 2f(x) doubles the output. Examples 2 and 4 show how far apart each pair is.
What it does to a graph
The graph of y = f(x) + 2 is the graph of f raised by 2, since every output is 2 more. The graph of y = f(x + 2) is the graph of f moved 2 to the left: its height above x is the height of f above x + 2, two units further right, so every feature of f turns up two units sooner. The lowest point of y = f(x) is at x = 1.5; on y = f(x + 2) it is at x = -0.5, because -0.5 + 2 = 1.5.
Moving graphs like this is shifting a graph up, down, left and right, part of the wider transformations of functions.
Worked examples
A linear rule
Let g(x) = 3x - 4. Find and simplify g(x + 3), g(3a), g(-x) and g(a^2).
SolutionThe whole expression replaces x, in brackets, and the distributive property clears the bracket.
Check the first at x = 1: g(4) = 12 - 4 = 8 and 3(1) + 5 = 8. The last answer is quadratic in a even though g is linear, because the input was a square.
Compare g(-x) with -g(x) = -(3x - 4) = -3x + 4. In g(-x) the minus sign changes the input, so only the x term feels it; in -g(x) it changes the whole output, constant included.
Inside or outside, on a table of values
Let f(x) = x^2 - 3x - 2. Find f(x + 2) and f(x) + 2, and compare them on a table of values from x = -2 to x = 4.
SolutionFor f(x + 2) the whole of x + 2 goes into both places, with (x + 2)^2 = x^2 + 4x + 4:
For f(x) + 2 the input is just x, and the 2 comes afterwards:
| x | f(x) | f(x) + 2 | f(x + 2) |
|---|---|---|---|
| -2 | 8 | 10 | -2 |
| -1 | 2 | 4 | -4 |
| 0 | -2 | 0 | -4 |
| 1 | -4 | -2 | -2 |
| 2 | -4 | -2 | 2 |
| 3 | -2 | 0 | 8 |
| 4 | 2 | 4 | 16 |
The column f(x) + 2 is the column f(x) with 2 added to each entry. The column f(x + 2) is the column f(x) read two rows further down: in the row x = 0 it holds f(2) = -4. Its last two entries, f(5) = 8 and f(6) = 16, run past the table, and the formula agrees: 16 + 4 - 4 = 16.
The two are equal only where x^2 + x - 4 = x^2 - 3x. Subtracting x^2 and adding 3x on both sides leaves 4x - 4 = 0, so x = 1, the one row where both columns show -2.
A quadratic with a coefficient
Let q(x) = 2x^2 + x - 3. Find and simplify (a) q(x - 1), (b) q(3a) and (c) q(-x), and compare (c) with -q(x).
Solution(a) The order of operations squares before it multiplies by 2, so the bracket is squared first, using (x - 1)^2 = x^2 - 2x + 1:
Check at x = 2: q(1) = 2 + 1 - 3 = 0, and 8 - 6 - 2 = 0.
(b) The square of 3a is 9a^2, the 3 squared too:
(c) Since (-x)^2 = x^2, the square term does not notice the sign:
But -q(x) = -2x^2 - x + 3 negates every term. So q(-x) is neither q(x) nor -q(x). That comparison is how even and odd functions are recognized, and this q is neither.
Doubling the input or the output
With f(x) = x^2 - 3x - 2 and g(x) = 3x - 4 as before, find 2f(x) and f(2x), then 2g(x) and g(2x), and compare each pair.
Solution2f(x) doubles every term of the output. f(2x) puts 2x in each place, and (2x)^2 = 4x^2:
The square term gets 4 in f(2x) but 2 in 2f(x), since the doubled input is squared. The constant is doubled in 2f(x) but untouched in f(2x), since it does not depend on the input. At x = 1, 2f(1) = 2(-4) = -8 while f(2) = 4 - 6 - 2 = -4.
For the linear rule only the constants differ:
So g(2x) is 4 more than 2g(x) for every x: the rule’s constant -4 is doubled by one and left alone by the other. A rule with no constant, such as p(x) = 5x, gives 2p(x) = 10x = p(2x).
The change over a step of one
(a) For g(x) = 3x - 4, find and simplify g(x + 1) - g(x). (b) Do the same for f(x) = x^2 - 3x - 2, and say what is different.
Solution(a) g(x + 1) = 3(x + 1) - 4 = 3x - 1. Subtract the whole of g(x), in brackets, so that its -4 is subtracted too:
No x is left, so the change is the same everywhere: one step right raises g by exactly 3, the slope of the line y = 3x - 4.
The same holds for any linear rule L(x) = mx + b:
For a linear rule, the change in output over one step of input is the slope, the rate of change that the slope formula finds.
(b) From the procedure, f(x + 1) = x^2 - x - 4, so
This time an x remains, so the change depends on where you start. The table in Example 2 agrees: f(1) - f(0) = -4 - (-2) = -2, a fall, and f(4) - f(3) = 2 - (-2) = 4, a rise. Measuring the change of such a rule across an interval is average rate of change from a formula.
A step of any size
Let f(x) = x^2 - 3x - 2. (a) Find and simplify f(x + h) and f(x + h) - f(x). (b) Use (a) to find the input x for which f(x + 2) = f(x), and check it.
Solution(a) Now x is the starting input and h the size of the step. Replace each x by x + h, using (x + h)^2 = x^2 + 2hx + h^2:
No two terms are alike, so this is fully simplified. Subtracting f(x) = x^2 - 3x - 2 removes the x^2, the -3x and the -2:
With h = 1 this is 2x - 2, as in Example 5.
(b) With h = 2 the difference is 4x + 4 - 6 = 4x - 2, and the outputs are equal exactly when it is 0:
Check: \displaystyle f\left(\frac{1}{2}\right) = \frac{1}{4} - \frac{3}{2} - 2 = -\frac{13}{4}, and \displaystyle f\left(\frac{5}{2}\right) = \frac{25}{4} - \frac{15}{2} - 2 = -\frac{13}{4}. The inputs \displaystyle \frac{1}{2} and \displaystyle \frac{5}{2} sit equally far either side of \displaystyle \frac{3}{2}, the input of the lowest point, because the graph is symmetric about the vertical line through its vertex.
Boundaries
Every x, the whole expression, in brackets. The rule acts on the whole input wherever it mentions it. Substituting into only some of the places, or dropping the brackets, gives a different expression.
A function does not split over a sum or a product. In general f(x + 2) is neither f(x) + 2 nor f(x) + f(2), and f(2x) is not 2f(x). For f(x) = x^2 - 3x - 2, f(2) = -4, so f(x) + f(2) = x^2 - 3x - 6, while f(x + 2) = x^2 + x - 4. Even a linear rule f(x) = mx + c splits over every sum only when c = 0: f(a + b) = ma + mb + c, but f(a) + f(b) = ma + mb + 2c.
The new input must be one the function accepts. If \displaystyle f(x) = \frac{1}{x}, then \displaystyle f(x - 3) = \frac{1}{x - 3} has no value at x = 3. If \displaystyle f(x) = \sqrt{x}, then \displaystyle f(x - 3) = \sqrt{x - 3} needs x \ge 3. The input expression has to land in the domain.
The change over a step of one is a single number for a linear rule, not for a quadratic. For a quadratic, f(x + 1) - f(x) still contains x.
Where this goes next
Putting a whole rule in for the input is composing functions: if u(x) = x + 2, then f(u(x)) is f(x + 2). Comparing f(-x) with f(x) and -f(x) decides whether a function is even, odd or neither, and adding the outputs of two rules at the same input builds the sum of two functions.
The difference f(x + h) - f(x), divided by the step h, is the difference quotient, the average rate of change over a step of width h. For f(x) = x^2 - 3x - 2 it is 2x + h - 3, and asking what happens to it as h shrinks toward 0 is the starting question of calculus.
Adding outside the bracket and adding inside it are the first of the transformations of functions; stretches and reflections follow, and they come from 2f(x), f(2x) and f(-x).
Exercises
Linear rules
Let r(x) = 9 - 2x. Find and simplify each.
- r(x + 4)
- r(3a)
- r(-x)
- r(x) + 4, and compare it with Exercise 1.
- r(2 - x)
Quadratic rules
Let s(x) = x^2 + x - 6. Find and simplify each.
- s(x + 2)
- s(x - 3)
- s(-x)
- s(2a)
- s(x) + 2. Then find its value and the value of s(x + 2) at x = 1.
- 2s(x) and s(2x). Is there any real x for which they are equal?
Squaring a sum
- Expand and simplify (x + h)^2 - x^2.
- Let w(x) = 2x^2 - 1. Find and simplify w(x + h).
- With the same w, find and simplify \displaystyle w\left(x - \frac{1}{2}\right).
From a table
A function u has these values.
| x | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| u(x) | 7 | 4 | 3 | 4 | 7 |
- Using only the table, find u(x) + 1 and u(x + 1) for x = 0, 1, 2, 3. For which of these x are the two equal?
The change over a step
- Find and simplify (a) L(x + 1) - L(x) for L(x) = 6x + 5, and (b) M(x + 1) - M(x) for \displaystyle M(x) = 3 - \frac{1}{2}x.
- For s(x) = x^2 + x - 6, find and simplify s(x + 1) - s(x). For which x is s(x + 1) = s(x)?
- The graph of y = s(x) has its lowest point at \displaystyle \left(-\frac{1}{2}, -\frac{25}{4}\right). Where is the lowest point of (a) y = s(x - 3) and (b) y = s(x) - 3?
Reasoning
- Show that for any linear rule L(x) = mx + b and any step h, L(x + h) - L(x) = mh. Then use Example 6 to explain why no statement of that kind holds for f(x) = x^2 - 3x - 2.
- For which linear rules L(x) = mx + b is L(x + 2) = L(x) + 2 for every x? Say what this means for the graph.
Answers
- r(x + 4) = 1 - 2x. 9 - 2(x + 4) = 9 - 2x - 8.
- r(3a) = 9 - 6a. 9 - 2(3a).
- r(-x) = 9 + 2x. 9 - 2(-x), and subtracting a negative adds.
- r(x) + 4 = 13 - 2x. Adding 4 to the output raises it by 4; adding 4 to the input, as in Exercise 1, lowers the output by 8, because r multiplies its input by -2.
- r(2 - x) = 5 + 2x. 9 - 2(2 - x) = 9 - 4 + 2x.
- s(x + 2) = x^2 + 5x. x^2 + 4x + 4 + x + 2 - 6.
- s(x - 3) = x^2 - 5x. x^2 - 6x + 9 + x - 3 - 6.
- s(-x) = x^2 - x - 6. (-x)^2 + (-x) - 6, and (-x)^2 = x^2.
- s(2a) = 4a^2 + 2a - 6. (2a)^2 + 2a - 6.
- s(x) + 2 = x^2 + x - 4. At x = 1 it is -2, while s(x + 2) at x = 1 is s(3) = 6.
- 2s(x) = 2x^2 + 2x - 12 and s(2x) = 4x^2 + 2x - 6. They are never equal: their difference s(2x) - 2s(x) = 2x^2 + 6 is at least 6, because x^2 \ge 0.
- 2hx + h^2. (x + h)^2 - x^2 = x^2 + 2hx + h^2 - x^2.
- w(x + h) = 2x^2 + 4hx + 2h^2 - 1. 2(x^2 + 2hx + h^2) - 1.
- \displaystyle w\left(x - \frac{1}{2}\right) = 2x^2 - 2x - \frac{1}{2}. Since \displaystyle \left(x - \frac{1}{2}\right)^2 = x^2 - x + \frac{1}{4}, the value is \displaystyle 2x^2 - 2x + \frac{1}{2} - 1.
- For x = 0, 1, 2, 3: u(x) + 1 is 8, 5, 4, 5, and u(x + 1) is 4, 3, 4, 7. They are equal only at x = 2, where both are 4. Each u(x) + 1 is the entry under x plus 1; each u(x + 1) is the entry one column to the right.
- (a) 6, since (6x + 11) - (6x + 5) = 6. (b) \displaystyle -\frac{1}{2}, since \displaystyle M(x + 1) = \frac{5}{2} - \frac{1}{2}x. Each is the slope.
- s(x + 1) - s(x) = 2x + 2, which is 0 at x = -1. s(x + 1) = x^2 + 3x - 4. Check: s(-1) = s(0) = -6.
- (a) \displaystyle \left(\frac{5}{2}, -\frac{25}{4}\right): the graph moves 3 to the right, since the height of s(x - 3) above x is the height of s three units to the left. (b) \displaystyle \left(-\frac{1}{2}, -\frac{37}{4}\right): every output is 3 less.
- L(x + h) - L(x) is m(x + h) + b - (mx + b), which is mh for every x. For f, Example 6 gives f(x + h) - f(x) = 2hx + h^2 - 3h, which still contains x: for the same step the change depends on where you start, so no single number plays the part of m.
- Exactly those with m = 1, whatever b is. L(x + 2) = mx + 2m + b and L(x) + 2 = mx + b + 2 agree for every x only when 2m = 2. On the graph, a line of slope 1 moved 2 left lands where it would land moved 2 up, since along it 2 across always comes with 2 up.