Transformations of Functions- College Algebra 2012

52 days ago by greenlinda

Transformations of Functions Using Sage

by Susan Schmoyer (adapted by Linda Green)

 


In this worksheet you will learn how to graph functions using transformations.  In particular, you will learn how horizontal and vertical shifts and stretches of the graph of a function affect the equation for the function.

Before you begin, make sure you know the graphs of our "toolkit" functions: 

 

y = x

y = x^2

y = \sqrt{x}   (denoted by sqrt(x) )

y = x^3

y = |x|  (denoted by abs(x))

y = 1/x

\sin(x)

If the function \sin(x) is new to you, that's okay.  You don't need to know what it means, but you should familiarize yourself with its shape below.

 

%auto functions = {'sin(x)':sin(x), 'x':x,'x^2':x^2,'x^3':x^3, 'sqrt(x)':sqrt(x),'1/x':1/x, 'abs(x)':abs(x)} @interact def _(g = selector(functions.keys(),label='function $f(x)$'), auto_update=True): g(x) = g P=plot(g(x), (x, -5, 5), legend_label='$y = f(x)$') P.show(gridlines='minor', ymin=-5, ymax=5, aspect_ratio=1) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Experiment A: transformations of toolkit functions.

For each of the following exercises, type the following expressions into the boxes below.  

Exercise 1:  f(x) =  x^2, \;\;\; g(x) = x^2 + 1, \;\;\; h(x) = x^2 - 2  (type x^2 to get the squaring function).

Exercise 2: f(x) = |x|, \;\;\; g(x) = |x + 3|, \;\;\; h(x) = |x - 4|  (type abs(x), abs(x-1), abs(x+2)  into the respective cells).

Exercise 3: f(x) = \sqrt{x}, \;\;\; g(x) = - \sqrt{x}, \;\;\; h(x) = \sqrt{-x}  (type sqrt(x), - sqrt(x), sqrt(-x) into the respective cells).

Exercise 4: f(x) = \sin(x), \;\;\; g(x) = 5 * \sin(x), \;\;\; h(x) = (1/3)*\sin(x) (you must use * for multiplication).

Exercise 5:  f(x) = \sin(x), \;\;\; g(x) = \sin(3*x), \;\;\; h(x) = \sin((1/2)*x)  (you must use * for multiplication).

%auto @interact def _(f = x^2, g = x^2 + 1, h = x^2 - 2): f(x) = f g(x) = g h(x) = h P1=plot(f, (x, -6.5, 6.5), legend_label='$f(x)$') P2 = plot(g, (x, -6.5, 6.5), color = 'red', legend_label='$g(x)$') P3 = plot(h, (x, -6.5, 6.5), color = 'green', legend_label='$h(x)$') (P1+P2+P3).show(gridlines='minor', ymin=-10, ymax=10, aspect_ratio=1) 
       

Click to the left again to hide and once more to show the dynamic interactive window

 Generalize experiment A:

1: How does the graph of f(x) + c compare to the graph of f(x)?

2: How does the graph of f(x+c) compare to the graph of f(x)?

3: How does the graph of -f(x) compare to the graph of f(x)?  How does the graph of f(-x) compare to the graph of f(x)?

4: How does the graph of c*f(x) compare to the graph of f(x)?

5: How does the graph of f(c*x) compare to the graph of f(x)?

Experiment B: combining shifts

Use the drop-down menu to pick a toolkit function for f(x).  Then use the sliders to pick

  • k, the vertical shift
  • h, the horizontal shift
and graph the shifted function f(x+h)+k
 
The original toolkit function stays in gray.  The newly transformed function appears in blue.  
%auto @interact def _(q = [x^2, x^3, sqrt(x), 1/x, abs(x), sin(x)], h = (0, (-5, 5, 1)), k = (0, (-5, 5, 1))): q(x) = q Pnew=plot(q(x+h)+k,(x,-10,10), legend_label='$y = g(x+%s) + %s$' %(h,k), color='blue') Pold = plot(q(x), (x, -10, 10), legend_label='$y = g(x)$', color='gray') (Pold+Pnew).show(gridlines='minor', ymin=-10, ymax=10, aspect_ratio=1, axes_labels=(['$x$','$y = g(x+h) + k$'])) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Experiment C: Combining shifts and stretches

Use the drop-down menu to pick a toolkit function for f(x).  Then use the sliders to pick

  • a, the vertical stretch / shrink
  • b, the horizontal stretch / shrink
  • k, the vertical shift
  • h, the horizontal shift
and graph the shifted function a*f(b*(x+h))+k
 
The original toolkit function stays in gray.  The newly transformed function appears in blue.

 


%auto @interact def _(f = [x^2, x^3, sqrt(x), 1/x, abs(x), sin(x)], a=slider(-4,4,0.1,default=1.00), b = (1, (-4, 4, 0.1)), h = (0, (-5, 5, 1)), k = (0, (-5, 5, 1))): f(x) = f Pnew=plot(a*f(b*(x+h))+k,(x,-10,10), legend_label='$y = %6.1f*f(%6.1f*(x+%s)+%s)$' %(a,b,h,k), color='blue') Pold = plot(f(x), (x, -10, 10), legend_label='$y = f(x)$', color='gray') (Pold+Pnew).show(gridlines='minor', ymin=-10, ymax=10, aspect_ratio=1, axes_labels=(['$x$','$y = a*f(b*(x+h))+k$'])) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Challenges for Experiment C (above):

Challenge 1:  Pick the function f(x) = abs(x) in the graph above.  What value do you need to pick for b to make the graph stretch out horizontally by a factor of 2?  Try it.  Now, without changing the value of b that you just set, can you pick a value of a that brings the graph back onto the original gray function?  What value of a do you need to use?  

Challenge 2:  Select the function f(x) = x^2.  What value do you need to pick for b to make the graph stretch out horizontally by a factor of 2?  Try it.  Now, without changing the value of b that you just set, can you find a value of a that brings the graph back onto the original gray function?  What value of a do you need to use?  

Explain challenges 1 and 2 in terms of the functions' equations.

Experiment D: Match the function

Try to make the blue function match the red function:

  • Enter the correct toolkit function in the box g
  • Enter the vertical stretch / shrink (if any) in box a
  • Enter the horizontal stretch / shrink (if any) in box b
  • Enter the horizontal shift in box h
  • Enter the vertical shift in box k

Once you have the blue function superimposed on the red one, you win!

To play again, click in the cell below and press Shift+Enter

%auto var('x') L = [x^2, x^3, 1/x, abs(x), sin(x), sqrt(x)] fPick = ZZ.random_element(0, 5) f(x) = L[fPick] M = [1, 1, 1, 2, 3] cPick = ZZ.random_element(0,5) cc = M[cPick] N = [1, 1, 1, 1, 2] dPick = ZZ.random_element(0,5) dd = N[dPick] r=ZZ.random_element(0,2) aa = (-1)^r*cc hh=ZZ.random_element(-5,6) kk = ZZ.random_element(-5,6) qq = plot(aa*f(x+hh) + kk, (x, -10, 10), color = 'red') @interact def _(g=0, a = 1, b = 1, h = 0, k = 0, auto_update=True): g(x) = g pp=plot(a*g(b*(x+h))+k,(x,-10,10), legend_label='$y = %6.1f*(%6.1f*(x+%s)+%s)$' %(a,b,h,k)) show(qq + pp, gridlines='minor', ymin=-10, ymax=10, aspect_ratio=1, axes_labels=(['$x$','$y = a*f(b*(x+h))+k$'])) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Experiment E: Transformations Guessing Game

Guess the equation of the following function, graphed using transformations. 

To get a new graph, click on the cell below, and press Shift-Enter. 

 

To check your answer, evaluate the cell below the graph.


%auto var('x') L = [x^2, x^3, 1/x, abs(x), sqrt(x), 1/x^2] r=ZZ.random_element(0,2) a = (-1)^r b=ZZ.random_element(-5,6) c = ZZ.random_element(-5,6) d = ZZ.random_element(0, 5) f(x) = L[d] p = plot(a*f(x-b) + c, (x, -10, 10)).show(gridlines='minor', ymin=-10, ymax=10, aspect_ratio=1) show(p) 
       
verbose 0 (4128: plot.py, generate_plot_points) WARNING: When plotting,
failed to evaluate function at 140 points.
verbose 0 (4128: plot.py, generate_plot_points) Last error message: ''

\newcommand{\Bold}[1]{\mathbf{#1}}\mathrm{None}
verbose 0 (4128: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 140 points.
verbose 0 (4128: plot.py, generate_plot_points) Last error message: ''

\newcommand{\Bold}[1]{\mathbf{#1}}\mathrm{None}

Did you guess correctly?  Click on the cell below and then click on 'evaluate' to see the correct formula.

print('f(x) = '); show(a*f(x-b) + c) 
       
f(x) = 
\newcommand{\Bold}[1]{\mathbf{#1}}x^{2}
f(x) = 
\newcommand{\Bold}[1]{\mathbf{#1}}x^{2}

 

 
       

Experiment F: Go wild 

Try typing in the formula for ANY function!  For example, try:

  • g(x) = x^3-3*x
  • g(x) = \sqrt{x} + \sin(x)
  • g(x) = (1/x)*abs(x)
  • or anything else you like
%auto @interact def _(g=x^3-3*x, a = 1, b = 1, h = 0, k = 0, auto_update=True): g(x) = g P=plot(a*g(b*(x+h))+k,(x,-10,10), legend_label='$y = %s*g(%s*(x+%s)) + %s$' %(a,b,h,k)) P.show(gridlines='minor', ymin=-10, ymax=10, aspect_ratio=1) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Review:

1: How does the graph of f(x) + c compare to the graph of f(x)?

2: How does the graph of f(x+c) compare to the graph of f(x)?

3: How does the graph of -f(x) compare to the graph of f(x)?  How does the graph of f(-x) compare to the graph of f(x)?

4: How does the graph of c*f(x) compare to the graph of f(x)?

5: How does the graph of f(c*x) compare to the graph of f(x)?