Slide-Squash Animation

by
K. D.  Stroyan
University of Iowa

copyright 1997 by Academic Press, Inc. - All rights reserved.

Special Mathematica Functions: The parabola function

Below we will define a function called parabola[alpha, beta, gamma] that will take as input the three parameters alpha, beta, and gamma and draw a plot of the parabola determined by those parameters over a certain range.  You can ignore it provided you answer"YES" to "Evaluate Initailization?"

The program is complicated by the fact that it produces a special label to give the graph specifying the parameters given as input.

Off[General::spell1];
Needs["Graphics`Colors`"];
parabola[α_, β_, γ_,opns___] :=
	Module[{label},
label = StringForm["α = ``,  β = ``,  γ = ``",α, β, γ] ;
Plot[ α (x - β)^2 + γ,{x, -5, 5},PlotRange -> {-5, 5}, AspectRatio -> 1,PlotLabel -> label,opns ] ;
	] ; On[General::spell1];

Notebook Overview

This notebook experiments with changes of the parameters in the function

y = α (((x - β))^2) + γ

Exercises on the Use of the Parabola Function

A Simple Example of the Parabola Function (Open and <Enter> it.)

α = 1; β = 2; γ = -3; parabola[α, β, γ, PlotStyle -> {Blue}]

You can also put the parameters inside directly.  <Enter> the next computation

parabola[-1, 2, 3, PlotStyle -> {Orange}]

The horizontal slide parameter - a pre-computed example

Altering beta in  y = (((x - β))^2) + 1  will slide the parabola  y = (x^2) + 1  to the right or left by running a Mathematica "animation"  that shows a 'movie' of the changes.   Enter the next computation and run the animation it produces.  This animation goes with part (a) of the text Problem 28.4, except that Mathematica makes lots more graphs.  It graphs for  β = -5, -4.75, -4.5, -4.25, ..., 4.5, 4.75, 5.0.  This is  21  graphs!

\(\(betavalues\  = \ Range[\(-5\), \ 5, \ 0.25]; \ 

    Map[parabola[1, \ #1, \ 1, PlotStyle -> {Red}]&, \ betavalues]; \ \)\)

To see the 'movie', close the first cell that contains all the graphs (by double clicking).   This will turn it dark.  Then hold down the  <Command> key and press the <Y> key at the same time.  The machine will load a sequence of pictures and then run a movie or animation.  <Enter> the computation and follow these instructions.

The input cell that generated this animation lets the beta parameter vary between -5 and 5 in steps of 1/4 with the Range function.  The function "parabola" defined in the next cell draws a parabola for given values of alpha, beta, and gamma.  The Map command will apply the function to every element of a list, in this case, a list of beta values.

The stretch-squash parameter

The cell below will produce a series of stills showing the effect of the alpha parameter on the shape of a parabola.  As we did with beta above, we will let alpha vary between -5 and 5  in steps of 0.25.  This corresponds to Problem 28.4, part (2), except that we plot  21  graphs instead of just a few.

After Entering the cell below, be patient.  Mathematica will take some time in drawing all the graphs.

\(alphavalues\  = \ Range[\(-5\), \ 5, \ 0.25]\ ; 

    Map[\ parabola[#, \ 1, \ 1, PlotStyle -> {Thickness[0.02], Purple}]&, \ 
      alphavalues\ ]; \)

Once you have generated all the graphs, you can run the animation.  Highlight the cell containing all the graphs and press Command-Y to animate the graphs. (They can be grouped with the "Cell" option on Mathematica's menu, but this is only neater, not necessary.)

The vertical slide parameter

As you may have guessed by now, the gamma parameter moves the parabola up and down.  To see this use the cell below to generate a movie displaying the effect of changing the gamma parameter.  This corresponds to Problem 28.4 part (3)

gammavalues = Range[-5, 5, 0.25] ;
Map[ parabola[1, 1, #,PlotStyle->{DarkGreen}]&, gammavalues ] ;

Problem 28.4

Use the ideas in the computations above to make animations of a parabola sliding over and up and of a parabola stretching as  alpha  increases.