(*
   This mathematica file creates frames for two animations to
   illustrate the definition of e as the number whose associated
   exponential function has derivative of 1 at 0.

   These animate the graph of y=a^x with a as the animation parameter.
   Using manual frame control, this gives a way to vary a manually and
   display the changing graph.
   
   The first animation lets a range from .1 to 10 and shows the
   graph on [-2,2]x[0,10].  The second animation shows a smaller
   range of a and plots the graph on [-1,1]x[0,2].  The line with
   slope 1 through (0,1) is shown as well.  By adjusting a we can
   make this line a tangent to the graph of y=a^x.  Of course this
   happens when a=e.

   Douglas N. Arnold, 10/11/94

   Douglas N. Arnold  <dna@math.psu.edu>
   Department of Mathematics
   Penn State
   University Park, PA  16802

   Online documentation related to this file can be found at WWW URL
   http://www.math.psu.edu/dna/graphics.html.*)

BeginPackage["Exponential`", "Graphics`Colors`"]

Begin["Private`"]

(* Describe the individual frames. *)

g[s_] := {s,{Gray,Thickness[0.001]}}
gridspec = {Table[g[s],{s,-2,2,.5}],Table[g[s],{s,0,10,2}]};
gridspec0 = {Table[g[s],{s,-1,1,.5}],Table[g[s],{s,0,2,.5}]};

expplot[s_]:= Plot[Exp[s x],{x,-2,2},
  PlotRange->{{-2,2},{0,10}},
  PlotStyle->{{Thickness[.01],Green}},
  Background->Black,DefaultColor->White,
  GridLines->gridspec,
  MaxBend->5,
  Epilog->{RGBColor[1,1,0],
    Text["a =",Scaled[{.5,.9}],{.5,0},
      TextStyle->{FontSize->24}
         ],
           Text[PaddedForm[N[Exp[s]],{3,2}],Scaled[{.5,.9},{-1.5,0}],
                 TextStyle->{FontSize->24}] },
  PlotLabel->StyleForm["y ="a^x,FontSize->20,FontColor->Yellow],
  TextStyle->{FontSize->18},
  DisplayFunction->Identity]
  
expplot0[s_]:= Plot[Exp[s x],{x,-2,2},
  PlotRange->{{-1,1},{0,2}},
  PlotStyle->{{Thickness[.01],Green}},
  Background->Black,DefaultColor->White,
  GridLines->gridspec0,
  MaxBend->5,
  Ticks->{{-1,-.5,0,.5,1},{0,.5,1,1.5,2}},
  AspectRatio->1,
  Epilog->{Yellow,
    Text["a = ",Scaled[{.7,.1}],{1,0},
      TextStyle->{FontSize->24}],
    Text[PaddedForm[N[Exp[s]],{4,2}],Scaled[{.7,.1}],{-1,0}]},
  Prolog->{Magenta,Thickness[.01],Line[{{-1,0},{1,2}}] },
  PlotLabel->StyleForm["y ="a^x,FontSize->20,FontColor->Yellow],
  TextStyle->{FontSize->18},
  DisplayFunction->Identity]
  
(* Create the frames. *)
smin=-2.3;
smax=2.3;
nframes=20;
delta = (smax-smin)/nframes;
prefix = "exponential1/T";
pixels=400;
filename[prefix_,number_] := StringJoin[prefix,ToString[number],".gif"]
Table[Display[filename[prefix,n+1],
    expplot[smin + n delta],"gif",ImageSize->pixels],{n,0,nframes}]
Print[StringJoin["-- wrote ",prefix," frames --"]]

smin=0;
smax=1.67;
nframes=20;
delta = (smax-smin)/nframes;
prefix = "exponential2/T";
pixels=400;
Table[Display[filename[prefix,n+1],
  expplot0[smin + n delta],"gif",ImageSize->pixels],{n,0,nframes}]
Print[StringJoin["-- wrote ",prefix," frames --"]]

End[] (* end of context private *)

EndPackage[]

