(A new question of the week)
Transformations of functions, which we covered in January 2019 with a series of posts, is a frequent topic, which can be explained in a number of different ways. A recent discussion brought out some approaches that nicely supplement what we have said before. Here, the focus will be on examples and alternate approaches; next week, the underlying reasons.
How do you determine the order?
The question came from Mario in early September, working through how to determine the appropriate transformations to graph a given function:
What order do we apply function transformations?
By transformations, I mean stuff like horizontal/vertical stretching/shrinking and translations.
I’ve been thinking about the order in which to apply the transformations to a graph when transforming its parent graph. Specifically. I am given the graph on an xy-plane, and I am given the new function. I have to then manipulate the parent function to get the graph of the new function.
A. Say I have f(x) = (x+1)2 + 3.
The parent function is p(x) = x2, so I start with a graph of that. When it comes to how I would apply the transformations, I think about how I would do the operation if I were to plug in an x in the transformed function, via the order of operations. First, I would add 1, which corresponds to a horizontal shift one unit to the left because it’s inside the parenthesis. After squaring, I would add 3 which corresponds to a shift 3 units up. Apply that to the whole graph, and I have my transformed function.
B. Now, let’s do the same thing to g(x) = √(-(x – 1)).
The parent function is h(x) = √(x). If I were to plug in an x, I would first subtract a 1, that corresponds to a shift 1 unit to the right. Then, I would multiply that result by a negative. Since that negative is inside the radical, it results in a reflection about the y-axis. If I do it that way, I get the wrong answer. To get the right answer, I would have to apply the reflection first and then shift 1 unit to the right even though the part that causes the shift is inside the parenthesis. So my rule of applying transformations like the order of operations falls apart.
From here it occurred to me that I should apply reflections first. Reason being that because I shifted to the right one and then reflected across the y-axis, I was actually reflecting not the x values, but the x – 1 values. A reflection across the y-axis applies a negative value to the x values only.
Then, I came to the conclusion that I could apply not just reflections but vertical/horizontal stretching at the start as well. They both involve multiplying the same parts of the function, and by the commutative property of multiplication, it doesn’t matter the order in which I do the multiplication. In summary, this is the order I’ve come up with at this point for applying transformations.
- Horizontal transformations/reflections
- Vertical transformations/reflections
- Horizontal translations
- Vertical translations
I discern the order of the translations the same way. Horizontal translations apply operations to the x-values, so they go first. Vertical translations apply to the parent function as a whole, so they go last.
These rules seem to hold so far.
C. Consider the function y(x) = -2(-4x – 2)2 + 1
First I applied the reflections, the horizontal shrink by a factor of 1/4, and the vertical stretch by a factor of 2. Then, I applied the translations. This gave me the right graph.
Is the rules I got, and the logic to how I got them mathematically solid?
There is a lot of good thinking here, but a few corrections are needed, and a good explanation of why things work the way they do.
Analyzing his ideas
I answered:
Hi, Mario.
I have previously dealt with this topic here:
Combining Function Transformations: Order Matters
There are several ways to express these ideas. Let’s see how your ideas agree with mine!
A. Looking first at your work for f(x) = (x+1)2 + 3, what you say (that x + 1 corresponds to a horizontal shift one unit to the left because it’s inside the parenthesis) is how I describe it, too. I say that “inside” transformations are horizontal transformations (which affect x); and they work backward.
B. In your second example, g(x) = √(-(x – 1)), your corrected approach (doing the reflection first) is correct. The way I describe this is that “inside” transformations are carried out “from the outside in”, reversing the order of operations. The last operation before the square root, when you evaluate the function, is the negation; so the first operation when you transform the function is the reflection.
Then you say,
From here it occurred to me that I should apply reflections first. Reason being that because I shifted to the right one and then reflected across the y-axis, I was actually reflecting not the x values, but the x – 1 values. A reflection across the y-axis applies a negative value to the x values only.
This is a valid alternative way to think about it. One way I like to explain this is that the reflection is accomplished by replacing x with -x, which would result in √(-x). If you then shift, you are replacing x with x – 1, which results in √(-(x – 1)), just as you need. If you shift first, you get √(x-1) from the shift, then √(-x – 1) from the reflection, which is a different function.
But this is only true of your example because of the parentheses. To get √(-x + 1), without the inner parentheses, you would first shift left, and then reflect. So you only reflect first when the notation (parentheses) demands it.
You correctly include stretching with reflections, for the right reason, and summarize:
In summary, this is the order I’ve come up with at this point for applying transformations.
- Horizontal transformations/reflections
- Vertical transformations/reflections
- Horizontal translations
- Vertical translations
This is mostly true, though I prefer to think of the horizontal and vertical transformations separately, as they affect different parts of the function. Stretches, being a multiplication, can be done together with reflections. But, as I said, horizontal reflections and stretches are usually (in the absence of parentheses) done after translations.
Then you say,
Horizontal translations apply operations to the x-values, so they go first. Vertical translations apply to the parent function as a whole, so they go last.
Actually, it doesn’t matter in what order horizontal and vertical translations (or any transformations) are done, because they don’t interact.
C. As for your third example, y(x) = -2(-4x – 2)2 + 1, you say
First I applied the reflections, the horizontal shrink by a factor of 1/4, and the vertical stretch by a factor of 2. Then, I applied the translations. This gave me the right graph.
It is possible that you didn’t write what you meant, or didn’t actually do to the graph what you say, which can be difficult to do. What you describe here is incorrect.
A better way
The post I referred to includes (in the last section, “Looking at the graph”) a discussion of the difficulty of graphing this combination of transformations correctly. The following follows the method I talked about there:
Here is what I would do:
Horizontal transformations first (only because they can be harder!):
Shift right 2 first, because the subtraction is last in the order of operations.
Reflect and shrink by 1/4 second, because multiplication is first in the order of operations.
Vertical transformations last (because they are easier):
Reflect and stretch by 3 first, because multiplication is first in the order of operations.
Shift up 1 second, because the addition is last in the order of operations.
As I said earlier, the order between horizontal and vertical doesn’t really matter; in fact they could be interleaved. But separating them in some way makes it easier to be careful with the parts that matter.
That is how I would handle the function written in that form. But since reflecting and shrinking something that has already been shifted is easy to get wrong, I prefer to instead change the form to what he had in example B:
Now, it is easier to actually draw a reflection first, so I would commonly start by factoring:
y(x) = -2(-4x – 2)2 + 1 = -2(-4(x + 1/2))2 + 1
Now the horizontal transformations are different:
Reflect and shrink by 1/4 first, because that’s on the outside of the parentheses.
Shift left 1/2 second, because the addition is on the inside of the parentheses.
This different pair of transformations has the same effect as the other, because the right shift by 2 in the first method is then reflected (now going to the left) and shrunk (from a distance of 2 to 1/4 of 2, which is 1/2).
Looking at the graph below, it definitely looks like it’s been shifted left 1/2, not right 2.
One thing I always do after making a graph like this, is to check a couple points on my graph by putting them into the equation. In this case, I get this graph:
One point I plotted was (1, 1) on the parent graph, as shown: I shifted that right 2, to (3, 1), then reflected and shrunk by 1/4 to (-3/4, 1), then reflected and stretched by 2 to (-3/4, -2), and finally shifted up 1 to (-3/4, -1) as shown. Now I check this by setting x = -3/4 and evaluating y(-3/4) = -2(-4(-3/4) – 2)2 + 1 = -2(1)2 + 1 = -1. There is enough complication in this work that I don’t trust myself until I check!
It is easier to see in the final result that the graph is shrunk horizontally, then shifted left 1/2, than the other way.
Why reverse the order of operations?
Mario replied:
I see. It makes sense that you could swap the order in which one does the vertical and horizontal movements. They seem very vector-like in their movements. Whatever you move in the x-direction first or the y-direction first, you still end up at the same endpoint because moving in just the x-direction doesn’t change your distance with respect to the y-axis and vice versa. And yeah, I see why doing the horizontal transformations first makes things easier.
There’s still some things I don’t get though. Why the order of operations?
When you did y(x) = -2(-4x – 2)2 + 1 in its unfactored form, you did the shifting two units to the right first because subtraction is last in the order of operations and then you did the horizontal reflecting and shrinking last because they are first in the order or operations. Why did you do it in reverse order from the order of operations?
When you did the vertical transformations on the same problem, you did the stretching and reflecting first because multiplication goes first in the order of operations and then you did the shifting up by 1 because addition goes last in the order of operations. You followed the order of operations. Why did you follow the order of operations here, but when you did the horizontal transformations, you went in the reverse order of operations?
He has a good perspective (more advanced than most students being introduced to these ideas), that just as we add vectors by separately adding their x and y components, we can separate the transformations that affect the x– and y-coordinates of points on the graph.
The “why” question is an important one; in what I’ve said so far I’ve been mostly just asserting it. This was a good opportunity to dig in a little deeper than I had in previous posts.
I answered, first by showing how the transformations individually affect the equation, starting with the vertical:
Your questions are at least partly answered in the post I referred to. Have you read it?
Let’s take two simpler examples, so we can look at only one direction at a time.
First, suppose we have f(x), and we first stretch it vertically by A, and then shift vertically by B.
To stretch it, we just have to multiply the value of y by A, so the new function is Af(x).
To shift it, we have to add B to the value of Y, so we have Af(x) + B.
Since we are simply operating on a number, y, the first transformation we did is the first operation in the order of operations.
Vertical transformations act directly on the y-coordinate, just as when we evaluate an expression: we multiply, then add.
Horizontal transformations, in contrast, are indirect:
Now, suppose we want to first stretch f horizontally by A, and then shift horizontally by B.
To stretch it, we have to replace x with x/A (since then x will be A times as large to get any given input to f); so our new function is f(x/A).
To shift it, we have to replace x with x – B (since then x will be B greater than it was, to get any given input to f); so our new function is f((x – B)/A).
This has the form f(a(x + b)), where a = 1/A and b = -B. The first transformation we did is outside of the parentheses, making it the last operation in the order of operations.
Observe that each transformation we do modifies the x, the “inside” of the argument of the function, so we are working from the outside in.
Next week, we’ll be looking even deeper at how these individual transformations work, particularly at why the replacement idea is right.
On the other hand, suppose we want to first shift by A, and then stretch by B.
To shift it, we have to replace x with x – A, so we get f(x – A).
To stretch it, we ahve to replace x with x/B, so we get f(x/B – A).
This has the form f(bx + a), where a = -A and b = 1/B. This time we didn’t need parentheses; but again, the first transformation we did corresponds to the last operation in the order of operations.
Does that help at all? If not, there are other ways it can be explained.
We’ll get to some of those other ways next time, because Mario wrote back to ask about them.
A single big example, with graphs
Mario asked for a little more:
I see. This makes sense now. I found the answer in the article mentioned a little off-topic from my question, but this really provided me some insights on transformations that really gets to the why of it. Could you perhaps do a specific example involves all transformations that uses this exact way of explaining transformations? I really feel like that’s the final push I need.
Let’s do it! I replied, first giving an example in which we are told to do a certain sequence of transformations, rather than given the equation:
Let’s take f(x) = √x and transform it this way:
- Shift left 3 units.
- Shrink horizontally by a factor of 2.
- Reflect over the y axis.
- Stretch vertically by a factor of 2 and reflect over the x axis.
- Shift up 2 units.
The successive equations are
- y = √(x + 3)… replaced x with x+3 [ – – – ]
- y = √(2x + 3)… replaced x with 2x [ . . . ]
- y = √(-2x + 3)… replaced x with -x [ – – – ]
- y = -2√(-2x + 3)… multiplied function by -2 [ . . . ]
- y = -2√(-2x + 3) + 2… added 2 to function
Here are graphs of each step, shown in the colors I used above:
Working through each curve on the graph is good exercise in thinking about the effect of each transformation. We start with the solid black line, and end with the solid purple line.
What if we are given the equation, as in his examples, and have to find the transformations (and then graph it)?
Now, if we were given y = -2√(-2x + 3) + 2, we could see that vertically we first multiply by -2 (reflect and stretch), and then add 2 (shift up); and horizontally, we first replaced x with x+3 (shift left), and then replaced x with -2x (reflect and shrink).
Here I am just reading the order of transformations from the equation, not planning ahead what order to do them in. (It happens that this time I chose to do the vertical transformations first.) The graphing is done just as above.
That equation involved a somewhat awkward shrink. Let’s repeat, using my recommendation:
Or, the way I prefer, we could rewrite it as y = -2√(-2(x – 3/2)) + 2, so that horizontally we first replaced x with -2x (reflect and shrink), and then replaced x with x – 3/2 (shift up by a smaller amount). Here is the sequence when we think that way. The successive equations are
- y = √(2x)… replaced x with 2x
- y = √(-2x)… replaced x with -x
- y = √(-2(x – 3/2)… replaced x with x – 3/2
- y = -2√(-2(x – 3/2))… multiplied function by -2
- y = -2√(-2(x – 3/2)) + 2… added 2 to function
The transformations in this order are:
- Shrink horizontally by a factor of 2. [ – – – ]
- Reflect over the y axis. [ . . . ]
- Shift right 3/2 units. [ – – – ]
- Stretch vertically by a factor of 2 and reflect over the x axis. [ . . . ]
- Shift up 2 units.
Here are graphs seen this way:
The final result is the same.
Does that help?
Mario replied:
Yes! It helps tremendously! Thank you! This question has been bothering me ever since I first learned function transformations in middle school. I have asked a variety of teachers and professors since, but it is only until now that I have gotten a good answer.
This is why I chose to post this answer as a supplement to what I’ve written before.
But a month later, he had further questions about why both the order of transformations and their individual operations are “backward” from what we expect. We’ll look at that next time.
Pingback: Function Transformations Revisited (II) – The Math Doctors