The Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Order of Transformations of a Function

Date: 11/30/2005 at 09:21:42
From: Ozgur
Subject: The order in which transformations are performed

Could you please tell me in what order I would perform transformations
such as -f(x), f(-x), af(x), f(ax), f(x)+a, f(x+a) if two or more were
to be applied to f(x)?  As an example, if I had f(ax+b) would I do the
translation or the stretch first?

I've looked in many textbooks and have been unable to find an answer.

Date: 11/30/2005 at 10:19:48
From: Doctor Peterson
Subject: Re: The order in which transformations are performed

Hi, Ozgur.

Good question!  I haven't seen this treated well in textbooks, either, 
but it's an important topic.

You can perform transformations in any order you want, in general.  
But in this case, you are asking in which order to do them in order to 
transform f(x) into a specific goal, f(ax+b).  The order makes a 
difference in how you get there.

What I do is to explicitly write the steps, one at a time.  Suppose we 
first do the horizontal shrink f(x) -> f(ax).  If we then apply a 
horizontal shift (translation) b units to the left, we would be 
REPLACING x in f(ax) with x+b, and we'd get f(a(x+b)).  That is NOT 
what we are looking for; it's equal to f(ax+ab).  So this order of 
doing those particular transformations is wrong.

If instead we first do the shift, changing f(x) to f(x+b), and THEN do 
the shrink, we replace x in x+b with ax, and get f(ax+b), which is 
what we want.  So that is one answer:

  Start with:                           f(x)
  Shift b units to the left:            f(x+b)
  Shrink horizontally by a factor of a: f(ax+b)

But in fact we COULD do the two transformations in the other order, if 
we change the particular amounts.  We can write f(ax+b) as 
f(a(x+b/a)), factoring out the a, and then do this:

  Start with:                           f(x)
  Shrink horizontally by a factor of a: f(ax)
  Shift b/a units to the left:          f(a(x+b/a)) = f(ax+b)

There are a couple things to notice here.  First, let's visualize what 
each pair of transformations does.  The first takes the graph of f and 
moves it left; then shrinks it:
  |               |             |             
  |         /     |       /     |    /     
  |    +---+      |  +---+      | +-+      
  |   /           | /           |/           
  |  /            |/            |/            
  +----------     +----------   +----------   

The other shrinks first, and then shifts--but not as far, since the 
shrink reduced the distance it has to go:
  |               |             |             
  |         /     |     /       |    /     
  |    +---+      |  +-+        | +-+      
  |   /           | /           |/           
  |  /            | /           |/            
  +----------     +----------   +----------   

To put it another way, the shrink in the second version also moved the 
starting point of the graph I drew (by shrinking the empty space), so 
I had to shift it less to get to the destination graph.

A second point to make is that the order of operations determines the 
order of the transformations.  When we wrote the transformed function 
as f(ax+b), the operations inside the function were done in the order 
"multiply, then add"; since we are replacing x in each transformation, 
we ended up doing the last operation first (outside in), replacing x 
with x+b first, then with a, so we did the shift followed by the 
shrink.  When we wrote it as f(a(x+b/a)), the order of operations says 
the addition comes first, then the multiplication, so the 
transformations have to be done in the opposite order.

This applies to transformations of x, on the inside of the function. 
Transformations like a+bf(x) (vertical shifts and stretches) are done 
in the SAME order as the order of operations.  Also, these do not 
interact with the horizontal transformations, so it doesn't matter 
which order you do them in; if you had, say, af(bx) you could do the 
vertical stretch followed by the horizontal shrink, or vice versa.  
Try it and see!

If you have any further questions, feel free to write back.

- Doctor Peterson, The Math Forum 

Date: 11/30/2005 at 12:27:13
From: Ozgur
Subject: Thank you (The order in which transformations are performed)

Thank you very much for your answer.  Your excellent explanation has
cleared up the matter for me.

Date: 09/10/2007 at 22:12:45
From: Elizabeth
Subject: Order of Transformations of a Function

I read your explanation of transformations order of operations, but I
guess I'm still unclear on the order that I have to do them in.  For 
example, if I take the equation y=4 times sq root (2-x), I find that I 
get the correct graph by doing 1) reflection over y axis 2) horizontal 
shift of 2 3) vertical stretch of 4 OR 1) vertical stretch 
2) reflection 3) horizontal shift.  Either way, the horizontal shift 
has to come after the reflection.

It doesn't work if I 1) shift then 2) reflect or stretch 3) reflect or 
stretch (depending on what I did in step 2).  I was always taught to 
do the horizontal shift first!

According to your explanation, as long as what I'm doing yields the
correct final equation, I can do whatever order I need to get there.
So looking at what didn't work, if I shift first I get sq root (x-2).
Then reflect makes sq root (-1)(x-2) or in other words sq root (-x+2) 
which is the same as sq root (2-x), then finally vertical stretch 
yields what I want:  y=4 times sq root (2-x).  But this doesn't graph
correctly; the reflection must come before I do the horizontal shift.

Date: 09/10/2007 at 23:37:46
From: Doctor Peterson
Subject: Re: Order of Transformations of a Function

Hi, Elizabeth.

Your question brings up details I didn't emphasize in my original answer.

First, I want to point out clearly what each individual transformation
looks like, because there are a few points that are easily missed.
Here are the transformations mentioned on that page:

  -f(x)     reflection in the x-axis
  af(x)     vertical stretch by factor a
  f(x)+a    vertical shift up by a

  f(-x)     reflection in the y-axis
  f(ax)     horizontal shrink by factor a
  f(x+a)    horizontal shift left by a

Note that the first set, the "vertical" transformations, involve
changing something OUTSIDE the original function; that is, we do
something to the "y" that comes out. The second set, the "horizontal"
transformations, involve changing something on the INSIDE of the
function. This MUST be seen as REPLACING the x itself with a negative,
multiple, or sum. These are the tricky ones. (They are also the ones
that tend to act in the opposite direction to what many people expect,
shrinking or shifting left rather than stretching or shifting right.)

Let's take an example of a reflection in the y-axis for a relatively
complicated (compound) function. If

  f(x) = sqrt(x - 2)

then reflection in the y-axis involves NOT replacing x-2 with its
opposite, 2-x, but replacing x with its opposite:

  g(x) = f(-x) = sqrt(-x-2)

Try graphing this to see for yourself what happens. A point (x,y) that
satisfies y=f(x), reflected in the y-axis to the point (-x,y), will
satisfy y=g(x) (using the new value of x). If you graph sqrt(2 - x),
you'll see something different.

Now, let's break your function down into a series of transformations,
starting with the basic square root function:

  f1(x) = sqrt(x)

and heading toward our goal,

  f(x) = 4 sqrt(2 - x)

It doesn't matter how the vertical and horizontal transformations are
ordered relative to one another, since each group doesn't interact
with the other. Let's do all the horizontal transformations first,
since they're the awkward ones. We need to do something with the 2,
and something with the -x. As mentioned in the page above, it's most
convenient (because of the order of operations) to do the shift FIRST:

  f1(x) = sqrt(x)
  f2(x) = f1(x + 2) = sqrt(x + 2)   shift left by 2
  f3(x) = f2(-x) = sqrt(-x + 2)     reflect in y-axis

Now we have f3(x) = sqrt(2 - x), and we can apply the vertical

  f4(x) = 4 f3(x) = 4 sqrt(2 - x)   stretch vertically by 4

So we find that we can shift left by 2, then reflect in the y-axis,
and then stretch vertically by 4. And that sequence of transformations
works on the graph:

                                                         *       |
                                                            *    |
  |        *          |       *        *       |                 |
  |   *        -->    |  *        -->       *  |    -->       *  |
  |*                 *|                        |*                |
  *---------        *-+--------        --------+-*              *|
                                                                 | *

This is the right graph; for example, f(2) = 4 sqrt(2 - 2) = 0, and
f(0) = 4 sqrt(2 - 0) = 4 sqrt(2) = 5.6.

Now, this disagrees with what you say:

>if I shift first I get sq root (x-2).  Then reflect makes
>sq root(-1)(x-2) or in other words sq root(-x+2) which is the same
>as sq root(2-x), then finally vertical stretch yields what I want:
>y=4 times sq root(2-x).  But this doesn't graph correctly; the
>reflection must come before I do the horizontal shift.  Why?

You seem to have fallen into the trap I mentioned, negating the entire
argument of the sqrt, rather than replacing x with -x, and thinking
that you have reflected the graph in the y-axis. Be sure to graph the
function you got, and convince yourself that it is not the reflection
you think it is. The functions sqrt(x-2) and sqrt(2-x) both have
x-intercept x=2, so in fact you have reflected around the line x=2!

Similarly, I suspect that when you did the shift after the reflection,
you were doing some wrong transformations, and not actually graphing
what you got and seeing that it really worked. Please let me know if
I'm wrong about that.

If you have any further questions, feel free to write back.

- Doctor Peterson, The Math Forum 

Date: 09/11/2007 at 20:53:18
From: Elizabeth
Subject: Thank you (Order of Transformations of a Function)

Aha!  You are absolutely correct.  [of course :) ]  I was improperly 
applying the transformation.  Your key phrase "This MUST be seen as 
REPLACING the x itself with a negative, multiple or sum" cleared it 
up for me.  Thank you for your time and clear explanation!
Associated Topics:
High School Functions

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.