Sub topic 2
Two Ways to Change a Function: the Output and the Input
This chapter assumes you can evaluate f(x) with function notation, plot points on the coordinate plane, and sketch basic graphs such as x, x², |x|, √x, and x³. It also assumes you know what domain and range mean. Later chapters cover each transformation in detail. This one builds the model they all rely on.
A function as a two-stage pipeline
A function takes an input x, applies a rule, and returns an output y = f(x). You can change a function in two places:
- After the rule runs. You alter the output, the number that comes out of f.
- Before the rule runs. You alter the input, the number that goes into f.
Every transformation in this tutorial is one of these two kinds. The general form g(x) = a·f(b(x − h)) + k is a pipeline. The input changes (b and h) happen first, then f runs, then the output changes (a and k) happen last.
The sections below show how each side behaves and why the two sides behave differently.
Changing the output
An output change happens after f has done its work. You take the finished value f(x) and do something to it.
- Add a constant: g(x) = f(x) + k.
- Multiply by a constant: g(x) = a·f(x).
For each x, the new height is the old height with k added, or multiplied by a. The x-coordinate of every point stays where it was. Only the y-coordinate changes, so these are vertical changes.
These changes behave the way the formula looks:
- Adding 3 raises every point by 3.
- Multiplying by 2 doubles every height.
- Multiplying by −1 turns every height into its opposite, which flips the graph over the x-axis.
For example, let f(x) = x² and g(x) = f(x) + 3. At x = 2, f(2) = 4, so g(2) = 7. The point (2, 4) becomes (2, 7).
Changing the input
An input change happens before f runs. You alter x, and f then works on the altered value.
- Subtract a constant: g(x) = f(x − h).
- Multiply by a constant: g(x) = f(bx).
Now f never sees your x. It sees x − h, or bx. These changes move points horizontally, because the same output now appears at a different x.
The behavior here is less obvious, and it is the main source of mistakes in this topic.
Why input changes act "backwards"
Take f(x) = x² and g(x) = f(x − 3) = (x − 3)². The function f produces its lowest output, 0, when its input is 0. So g produces 0 when its input to f is 0, that is, when x − 3 = 0. That happens at x = 3.
The key step is to ask which x gives g the same output that f gave at some earlier input p. You need x − 3 = p, so x = p + 3. The point (p, f(p)) on the old graph reappears at (p + 3, f(p)) on the new graph. The graph moves right by 3, even though the formula contains a minus sign.
The same reasoning handles multiplication. For g(x) = f(2x), the function f receives twice the usual input. Whatever f did at input p now happens at x = p/2. Points move toward the y-axis, so the graph is compressed horizontally by a factor of 2. The change is the reciprocal of what the number 2 suggests.
Output changes do what the formula says. Input changes undo themselves, because you must find the x that cancels the change before f sees it.
Summary of the four basic changes
| Form | Where it acts | Direction of effect | What happens to a point (x, y) |
|---|---|---|---|
| f(x) + k | Output | Vertical, same as the sign of k | (x, y) becomes (x, y + k) |
| a·f(x) | Output | Vertical, scales by a | (x, y) becomes (x, a·y) |
| f(x − h) | Input | Horizontal, opposite to the sign | (x, y) becomes (x + h, y) |
| f(bx) | Input | Horizontal, scales by 1/b | (x, y) becomes (x/b, y) |
Notice that the point rules for input changes are the inverses of what appears inside f. The formula subtracts h, but the point adds h. The formula multiplies by b, but the point divides by b. The mapping rule (x, y) → (x/b + h, a·y + k) from the topic overview is just these four rows combined.
Checking the model with code
The function below applies an output change and an input change to the same f, so you can compare them.
f = lambda x: x ** 2
def change_output(f, k):
"""g(x) = f(x) + k: the change happens after f runs."""
return lambda x: f(x) + k
def change_input(f, h):
"""g(x) = f(x - h): the change happens before f runs."""
return lambda x: f(x - h)
up = change_output(f, 3)
right = change_input(f, 3)
print(up(0)) # 3 (the lowest point is now at height 3)
print(right(0)) # 9 (f receives -3 and returns 9)
print(right(3)) # 0 (f receives 0, so the lowest point is at x = 3)The call right(0) returns 9, not 0. At x = 0 the new function hands f the value −3. The call right(3) returns 0, which shows the vertex has moved to x = 3.
The next check confirms the point rule for an input change. Each point (p, f(p)) should reappear at (p + 3, f(p)).
f = lambda x: x ** 2
g = lambda x: f(x - 3)
points = [(-2, 4), (0, 0), (2, 4)] # on y = x^2
moved = [(x + 3, y) for x, y in points] # the rule: add h to x
print(moved) # [(1, 4), (3, 0), (5, 4)]
print(all(g(px) == py for px, py in moved)) # TrueEvery moved point satisfies g, so adding h to each x-coordinate is the correct rule for f(x − h).
What each side does to domain and range
The two sides tend to affect different parts of a function's description. This is a working rule for most of the parent functions you know:
- Output changes act on heights, so they change the range. Adding k shifts the range by k. Multiplying by a scales it, and a negative a flips it.
- Input changes act on x-values, so they change the domain. Subtracting h shifts the domain by h. Multiplying by b scales it by 1/b.
Consider g(x) = √(x + 4). The square root requires its input to be at least 0, so x + 4 ≥ 0, which gives x ≥ −4. The domain of √x is x ≥ 0, and the shift of 4 to the left moves the boundary to −4. The range stays y ≥ 0, since no output change was applied.
This rule is a guide, not a law. A transformation only changes a domain or range in a visible way when the original one has a boundary. For f(x) = x², the domain is already all real numbers. Shifting it left, right, or compressing it leaves the domain as all real numbers. A later chapter treats domain and range effects fully.
Common errors
- Reading the sign inside f literally. The expression f(x − 3) moves the graph right, not left. Use the "set the inside equal to the old input" check from above.
- Treating f(2x) like 2f(x). They are different. For f(x) = x², f(2x) = 4x², while 2f(x) = 2x². The first is an input change and the second is an output change. At x = 1 the values are 4 and 2.
- Adding k to x instead of to f(x). The expression f(x) + k is not f(x + k). The first moves the graph vertically, and the second moves it horizontally. The placement of the parentheses decides which.
- Applying a point rule to the wrong coordinate. Output changes alter y only. Input changes alter x only. If a rule seems to affect both coordinates, check that you have separated the changes correctly.
- Forgetting the order when several changes are present. In a·f(b(x − h)) + k, the input changes b and h are applied to x first, and a and k are applied to the result. The next chapters show why a different order gives a different graph.
Edge cases
- Constants of zero. Adding k = 0 or subtracting h = 0 changes nothing. Multiplying by a = 1 or b = 1 also changes nothing.
- Multiplying by zero. With a = 0, g(x) = 0 for every x, which is a flat line and not a transformed copy of f. With b = 0, g(x) = f(0), a constant. Both collapse the graph, so a and b are assumed nonzero in what follows.
- Negative factors. A negative a or b still scales, and it also flips the graph. This is the subject of the reflections chapter.
- Functions with symmetry. If f is symmetric, some input changes can look like output changes. For example, with f(x) = x², the graph of f(2x) = 4x² looks like a vertical stretch by 4. The two descriptions give the same graph for this f. They are still different operations, and for most other functions, such as √x, they give different graphs.
Exercise
Let f(x) = √x. For g(x) = √(x + 4) − 2, say which change happens on the input side and which on the output side. Then give the point that (0, 0) on f moves to, and the domain and range of g.
Show answer
The change x + 4 acts on the input before f runs, so it shifts the graph horizontally. Setting x + 4 = 0 gives x = −4, so it moves left by 4. The change − 2 acts on the output after f runs, so it shifts the graph down by 2. The point (0, 0) moves to (−4, −2). The domain needs x + 4 ≥ 0, so x ≥ −4. The range of √x is y ≥ 0, and subtracting 2 gives y ≥ −2.
Exercise
For f(x) = x², compute f(2x) and 2f(x) at x = 3. Which one is an input change, and which is an output change?
Show answer
f(2·3) = f(6) = 36, and 2·f(3) = 2·9 = 18. The expression f(2x) changes the input before f runs, so it is an input change. The expression 2f(x) multiplies the result of f, so it is an output change. The values differ, so the two transformations are not interchangeable.
Exercise
A graph of f has a peak at (1, 5). Where is the peak on the graph of g(x) = f(x − 2) + 1?
Show answer
The input change x − 2 moves the point right by 2, so the x-coordinate becomes 1 + 2 = 3. The output change + 1 raises the height by 1, so the y-coordinate becomes 5 + 1 = 6. The peak is at (3, 6).