Cryptography and Horizontal Function Transformations

This lesson has gone well enough for me that I think it might be worth putting out there for others to use.  I’ve been troubled for years by the lame explanations I had to give for why horizontal transformations are backwards.  Why does y=(x – 3)2 get shifted to the right?  Every explanation I’d give was met with the polite “Oh, okay” that’s student for “I have no idea what you just said.”

So here’s a taste of what how I taught the topic using the context of cryptography.  I gave students the following function and asked them something to set a low barrier to entry: if someone sends you the message “8-9”, then what are they saying to you?


(The answer is “Hi”, of course).  But that code is too obvious, so then I introduced the idea of transforming the code to something more secret.  For example, you and a co-conspirator could agree that to read a message, you’d first add 3 to each number, and then look up the corresponding letter on the graph.  So if I send you the number 1, what letter did I send?  (The answer is that you first do 1 + 3 to get 4, so the correct letter is D).  That’s simple enough, so we practiced it and built up to something more complicated:

Easy Transformations

The answer to question e) is 55.  This is not easy to see without doing some calculations, and those calculations already get you thinking in the backwards logic of horizontal transformations.  Since “S” is the number 19, you need (x+2)/3 to come out to 19.  So you first multiply 19 by 3, and then subtract 2.  Students should show work like this: f[(55+2)/3)] = f(57/3) = f(19) = S.

After that discussion, it’s time to let the students have some fun by sending a secret message to a classmate with the code f(2x-3).

By then, we’ve noticed that it’s annoying to have to recalculate each letter you want to send.  Wouldn’t it be nicer to just notice the patterns, and adjust the entire code of f(x) at once?   We look for patterns in how the points on the graph are transformed, like this:

Graphical transformation

(I’ve put the answers in the graph in red font).  Here you can already see the backwards thinking in effect: although the fact that 0.25 < 1 might make you think that f(0.25x) is compressed, in fact it’s stretched.  And you understand the logic–you need a larger value of x, because the 0.25 is going to shrink it, and you’re still trying to come out to the same letters of A, B, and C.

What I really like about this approach is that it also makes clear why the order of operations is reversed for horizontal function transformations.  For example, in the function y=sin(2x+pi), you first shift everything to the left by pi, and then compress by a factor of 0.5.  Why are these transformations applied in the reverse order of operations?  Because in essence, you’re solving an equation, just like we solved (x+2)/3 = 19, above…and solving an equation always involves “undoing” the expression in the reverse order in which it was built up.

Students apply that reasoning, first by encoding the letters of the word “JAMES” using the function f(0.5x + 6), which has two transformations.  Then, looking at the pattern of the steps they took in each case (first subtracting 6 from both sides of an equation, and then multiplying by 2 to cancel out the 0.5), they apply those transformations graphically to another word, “BOND”, in the same order.  First subtracting 6 from each x-value means moving it to the left 6, and then multiplying by 2 means stretching it horizontally by a factor of 2.  Students know that the order matters here, because of some exploration we did in the intro section of this activity.


Students then translate their understanding to actual mathematical graphs:


This should set my students up nicely to understand period and phase shift.  Think again about the function y=sin(2x+pi).  When transforming graphs, it’s usually easier to stretch/compress before you translate.  Since order of operations is reversed, if we want to compress first, we have to rewrite it as y=sin[2(x + pi/2)].  This way, you compress by 0.5 first, and then just shift everything by pi/2 to the left. 

And, if you’ve gotten all the way down to this part of the blog post, here’s a link to the activity:

For some context, see Kate Nowak’s related musings:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s