Function Reflector Movies (Bruce & Tami's functional form)
Created with Maple 5 Release 5.1, by John Pais, pais@kinetigram.com, 07-20-03
Define Reflector procedure to create parameterized functions.
> Reflector:=proc(k1,n1,c1)
> local k,n,c,f,g:
> k:=k1:n:=n1:c:=c1:
> f:=unapply(k*x^n -c,x):
> g:=unapply(((x+c)/k)^(1/n),x):
> [f,g]
> end:
>
Initialize Reflector and print functions.
> k:='k':n:='n':c:='c':
> f:=op(1,Reflector(k,n,c)):
> g:=op(2,Reflector(k,n,c)):
> 'f(x)'=f(x);
> 'g(x)'=g(x);
>
Initialize Reflector with specific values, print and plot functions.
>
k:=1:n:=3:c:=1:
p1:=plot(f(x),x=-4..4,y=-4..4,color=blue):
p2:=plot(g(x),x=-c..4,y=-4..4,color=red):
# Note that the branch below (p3) must be done separately,
# in order to trick Maple into ploting it.
p3:=plot(-g(-x-2*c),x=-4..-c,y=-4..4,color=navy):
> 'f(x)'=f(x);
>
'g(x)'=g(x);
plots[display]([p1,p2,p3],scaling=constrained);
>
Define Function Reflector Movie procedure.
> FunctionReflectorMovie:=proc(k,n,frame)
> local f,g,m,n_str,i,c,c_str,txtcolor,rp,
> movie_frame,j,reflector_movie,FunctionReflector:
> Digits:=4:
> m:=40:
> n_str:=convert(n,string):
> for i from 0 to m do
>
if i <= 20 then
c:=i*.1:
else
c:=-(i-20)*.1:
fi:
c_str:=convert(evalf(abs(c),2),string):
if c = 0 then
c_str:="0.".c_str:
fi:
if 0 < abs(c) and abs(c) < 1 then
c_str:="0".c_str:
fi:
f:=op(1,Reflector(k,n,c)):
>
g:=op(2,Reflector(k,n,c)):
#Setup axes: don't use default axes, in order
#to obtain a less clutered view.
rp[1]:=plot([[-2.,-0.075],[-2.,0.075]],
> linestyle=1,color=black):
> rp[2]:=plots[textplot]([-2.,-0.3,`-2`],
> font=[HELVETICA,DEFAULT,10],
> color=black):
> rp[3]:=plot([[2.,-0.075],[2.,0.075]],
> linestyle=1,color=black):
> rp[4]:=plots[textplot]([2.,-0.3,`2`],
> font=[HELVETICA,DEFAULT,10],
> color=black):
> rp[5]:=plot([[-0.1,-2.],[0.1,-2.]],
> linestyle=1,color=black):
> rp[6]:=plots[textplot]([-0.28,-2.,`-2`],
> font=[HELVETICA,DEFAULT,10],
> color=black):
> rp[7]:=plot([[-0.1,2.],[0.1,2.]],
> linestyle=1,color=black):
> rp[8]:=plots[textplot]([-0.25,2.,`2`],
> font=[HELVETICA,DEFAULT,10],
> color=black):
> rp[9]:=plot([[-4.,-0.075],[-4.,0.075]],
> linestyle=1,color=black):
> rp[10]:=plots[textplot]([-4.,-0.3,`-4`],
>
font=[HELVETICA,DEFAULT,10],
color=black):
> rp[11]:=plot([[4.,-0.075],[4.,0.075]],
> linestyle=1,color=black):
> rp[12]:=plots[textplot]([4.,-0.3,`4`],
> font=[HELVETICA,DEFAULT,10],
> color=black):
> rp[13]:=plot([[-0.1,-4.],[0.1,-4.]],
> linestyle=1,color=black):
> rp[14]:=plots[textplot]([-0.25,-3.8,`-4`],
> font=[HELVETICA,DEFAULT,10],
> color=black):
> rp[15]:=plot([[-0.1,4.],[0.1,4.]],
> linestyle=1,color=black):
> rp[16]:=plots[textplot]([-0.25,4.0,`4`],
> font=[HELVETICA,DEFAULT,10],
>
color=black):
#Plot functions, lines, points (Note that plotting these
#first resulted in an intended blue color of the numbers
#on the axes.)
> rp[17]:=plot(f(x),x=-4..4,-4..4,color=blue):
>
rp[18]:=plot(g(x),x=-c..4,-4..4,color=red):
rp[19]:=plot(-g(-x-2*c),x=-4..-c,y=-4..4,color=red):
rp[20]:=plot([[-4,-4],[4,4]],linestyle=2,color=magenta):
> rp[21]:=plots[textplot]([-1.8,2.99,n_str],
> font=[HELVETICA,DEFAULT,11],
>
color=blue,align=RIGHT):
if c >= 0 then
rp[22]:=plots[textplot]([-3.3,2.8,`f(x) = x - `.c_str],
> font=[HELVETICA,DEFAULT,12],
>
color=blue,align=RIGHT):
else
rp[22]:=plots[textplot]([-3.3,2.8,`f(x) = x +`.c_str],
> font=[HELVETICA,DEFAULT,12],
>
color=blue,align=RIGHT):
fi:
> rp[23]:=plots[textplot]([-3.4,1.8,`g(x) = ?`],
> font=[HELVETICA,DEFAULT,12],
> color=red,align=RIGHT):
>
rp[24]:=plot([[0,f(0)],[f(0),0]],
linestyle=2,color=magenta):
rp[25]:=plot([[0,f(0)]],style=POINT,symbol=CIRCLE,color=blue):
> rp[26]:=plot([[f(0),0]],style=POINT,symbol=CIRCLE,color=red):
>
rp[27]:=plot([[2,g(2)],[g(2),2]],
linestyle=2,color=magenta):
rp[28]:=plot([[2,g(2)]],style=POINT,symbol=CIRCLE,color=red):
rp[29]:=plot([[g(2),2]],style=POINT,symbol=CIRCLE,color=blue):
rp[30]:=plot([[-2,-g(-(-2)-2*c)],[-g(-(-2)-2*c),-2]],
linestyle=2,color=magenta):
>
rp[31]:=plot([[-2,-g(-(-2)-2*c)]],style=POINT,symbol=CIRCLE,color=red):
rp[32]:=plot([[-g(-(-2)-2*c),-2]],style=POINT,symbol=CIRCLE,color=blue):
movie_frame[i+1]:=plots[display]([seq(rp[j],j=1..32)]):
>
od:
if frame = 0 then
##### Create Maple movie.
reflector_movie[frame]:=plots[display](
> [movie_frame[1],movie_frame[1],movie_frame[1], seq(movie_frame[j],j=2..21),
> movie_frame[21],movie_frame[21],movie_frame[21],
> movie_frame[1],movie_frame[1],movie_frame[1], seq(movie_frame[j],j=22..41),
> movie_frame[41],movie_frame[41],movie_frame[41]],
> insequence = true,
> scaling=constrained,
> labels=[``,``],
> xtickmarks=0,ytickmarks=0,
> titlefont=[HELVETICA,DEFAULT,14],
>
title=`Inverse functions are reflections in y = x `):
else
##### Create individual frames to export to *.gifs for animated gif or Java movie.
reflector_movie[frame]:=plots[display](
> [movie_frame[frame]],
> scaling=constrained,
> labels=[``,``],
> xtickmarks=0,ytickmarks=0,
> titlefont=[HELVETICA,DEFAULT,14],
>
title=`Inverse functions are reflections in y = x `):
fi:
> FunctionReflector:=reflector_movie[frame]:
> FunctionReflector
> end:
>
Create & run Maple movie.
>
#FunctionReflectorMovie(k,n,frame),frame = 0 creates Maple movie.
FunctionReflectorMovie(1,3,0);
>
Create individual frames to export to *.gifs for an animatied gif or a Java movie.
for j from 1 to 41 do
#FunctionReflectorMovie(k,n,frame),frame = j > 0 creates frame j only.
FunctionReflectorMovie(1,3,j);
od;
>
>
>