Graphical Transformations

Recall to evluate cells in Mathematica you move the cursor into the cell and type “Shift-Enter”, or use the “Enter” on the keypad. 

To evaluate all the cells in the file, from the drop down menu choose Evaluation > Evaluate Notebook.

Here is a function that we can perform graphical manipulations on:

f[x_]=x^3-3x^2+1x+1

plotf=Plot[f[x],{x,-10,10},PlotRange->{{-5,5},{-20,20}},PlotStyle->{Thick,Dashed,Red}]

My advice is to understand the vertical modifications since they do what you would expect:

y=f[x]+k  (k>0 shift up)
 y=f[x]-k (k>0 shift down)
y=a*f[x] (a>1 vertical stretch)
y=1/a*f[x] (a>1 vertical compression)

The horizontal modifications do the opposite

y=f[x+h] (h>0 shift left)
 y=f[x-h] (h>0 shift right)
y=f[b*x] (b>1 horizontal compression)
y=f[1/b*x] (b>1 horizontal stretch)

A modification outside the function f(x) is a vertical modification.

Notice that any modification inside the function f(x)  is a horizontal modification.

Vertical Transformations

Manipulate[
transk=Plot[f[x]+k,{x,-20,20},PlotRange->{{-5,5},{-20,20}},PlotStyle->Thick];
Show[plotf,transk]
,{k,-5,5,0.1}
]

Manipulate[
transa=Plot[a*f[x],{x,-20,20},PlotRange->{{-5,5},{-20,20}},PlotStyle->Thick];
Show[plotf,transa]
,{a,0,15,0.1}
]

Horizontal Transformations

Manipulate[
transh=Plot[f[x+h],{x,-20,20},PlotRange->{{-5,5},{-20,20}},PlotStyle->Thick];
Show[plotf,transh]
,{h,-5,5,0.1}
]

Manipulate[
transb=Plot[f[b*x],{x,-20,20},PlotRange->{{-5,5},{-20,20}},PlotStyle->Thick];
Show[plotf,transb]
,{b,0,15,0.1}
]

Multiple Transformations

Let’s examine the graphical transformations of this function by graphing

y=a( f[b(x+h)]+k)

using the Manipulate command.

What we have here are, assuming a>0,b>0,h>0,k>0 will be:

As h increases, the graph will shift to the left,
As k increases, the graph will shift to up,
As a increases, the graph will experience a vertical stretch (notice the zeros do not change),
As b increases, the graph will experience a horizontal compression.

Manipulate[
trans=Plot[a(f[b(x+h)]+k),{x,-20,20},PlotRange->{{-5,5},{-20,20}},PlotStyle->Thick];
Show[plotf,trans]
,{h,0,5,0.1}
,{k,0,5,0.1}
,{a,1,6,0.1}
,{b,1,6,0.1}
]

You can vary these together to see how the graph is transformed by shifting left, then compressing horizontally, for example.

You can do this using more meaningful words in Mathematica:

Manipulate[
trans2=Plot[verticalstretch(f[horizontalcompress(x+horizontalshift)]+verticalshift),{x,-10,10},PlotRange->{{-5,5},{-20,20}},PlotStyle->Thick];
Show[plotf,trans2]
,{verticalshift,0,5,0.1}
,{horizontalshift,0,5,0.1}
,{verticalstretch,1,6,0.1}
,{horizontalcompress,1,6,0.1}
]

The order in which the transformations are applied matters.

Shift up 4 units, followed by a reflection about the x-axis:

plot1=Plot[f[x]+4,{x,-10,10},PlotStyle->{Thick,Blue}];
plot2=Plot[-(f[x]+4),{x,-10,10},PlotStyle->{Thick,Purple}];Show[plotf,plot1,plot2]

which is different from a reflection about the x-axis, followed by a shift up 4 units:

plot1=Plot[-f[x],{x,-10,10},PlotStyle->{Thick,Blue}];
plot2=Plot[-f[x]+4,{x,-10,10},PlotStyle->{Thick,Purple}];Show[plotf,plot1,plot2]

Notice the two purple curves are not the same.