restart;with(plots):fcn:=proc()local a, b, c, d, e, g, h, f,k; global x;use Maplets[Tools] in a:=Get('DDB1'::symbol);end use:if a = oneformula then use Maplets[Tools] in b:=Get('TF1'::algebraic); end use: f:=b; else use Maplets[Tools] in e:=Get('TF2'::numeric); g:=Get('TF3'::algebraic); h:=Get('TF4'::numeric);k:=Get('TF5'::algebraic): end use: f:=piecewise(x<e,g,x=e,h,x>e,k);fi; end:graphfcn:=proc(p,r,s,t,u)local a,g, h, e, k, F, A, B, C; global x; F:=unapply(p,x); use Maplets[Tools] in a:=Get('DDB1'::symbol): end use: if a=oneformula then plot(F(x),x=r..s,y=t..u); else use Maplets[Tools] in e:=Get('TF2'::numeric); g:=Get('TF3'::algebraic); h:=Get('TF4'::numeric);k:=Get('TF5'::algebraic): end use:A:=plot(p,x=r..e,style=point):B:=pointplot([e,h]):C:=plot(p,x=e..s,style = point):display({A,B,C});fi;end proc:graphfcnseq:=proc(p,q,r,s,t,u)local F,G; global x,n; F:=unapply(p,x);G:=unapply(q,n):plot({seq([n,F(G(n))],n=r..s)},x=r..s,y=t..u,style=point,color=navy);end proc:seqandfcngraph:=proc(p,q,r,s,t,u,v,w)local A,B,F,G;global x,n;F:=unapply(p,x):G:=unapply(q,n):A:=graphfcn(p,r,s,t,u): B:=plot({seq([G(n),F(G(n))],n=v..w)},x=r..s,y=t..u,style=point,color=navy):{A,B}:end proc:use Maplets[Elements] in
lab9maplet:= Maplet(
'onstartup' = RunWindow('W1'),
Window['W1']('title'= "Enter the function formula",[
[
"Choose the case which describes the function with which you are working and then complete the appropriate box(es)"
],
DropDownBox['DDB1']('value'="oneformula",[
"oneformula","piecewisedefined"
]),
[
"CASE 1: If the function is not defined piecewise, enter the formula for the function as a function of x",TextField['TF1']()
],
[ " "
],
[
""
],
[
"CASE 2: If the function is defined piecewise, complete the next three boxes."
], [
"Value of x at which the definition changes:", TextField['TF2']()
],
[
"Formula for x values less than the value you just entered:", TextField['TF3']()
],
[
"Function value for that specified x value:",TextField['TF4']() ],
[
"Formula for x values greater than the specified x value:",TextField['TF5']()
],
TextBox['TB1']('editable'='false'),
[
Button("Display the formula for your function",Evaluate('TB1'='fcn()'))
],
[
Button("Ready to graph the function",Action(CloseWindow('W1'),RunWindow('W2')))
]
]),
Window['W2']('title'="Graph of the function",[
[
"enter range for graphing: ",
"minimum x",TextField['TF6'](5),
"maximum x",TextField['TF7'](5),
"minimum y",TextField['TF8'](5),
"maximum y",TextField['TF9'](5)
],
Plotter['PL1'](),
[
Button("Graph function",
Evaluate('PL1'='graphfcn(TB1,TF6,TF7,TF8,TF9)')),
Button("I need to change the viewing window",Action(SetOption('TF9'=""), SetOption('TF6'=" "), SetOption('TF7'=" "), SetOption('TF8'=" ")))
],
[
"Enter the formula for the sequence a(n) or b(n)",TextField['TF10'](),"Enter starting index",TextField['TF11'](5),"Enter ending index",TextField['TF12'](5)
],
[
Button("Replace the graph above with the graph of the sequence f(a(n)) or f(b(n))",Evaluate('PL1'= 'graphfcnseq(TB1,TF10,TF11,TF12,TF8,TF9)'))
],
[
Button("Show the sequence of function values superimposed on the graph of the function",Evaluate('PL1'= 'display(seqandfcngraph(TB1,TF10,TF6,TF7,TF8,TF9, TF11,TF12))'))
],
[
Button("Ready to try second sequence",Action(SetOption('TF12'=""),
SetOption('TF10'=""),SetOption('TF11'="")))
, Button("Ready to try another function",Action(SetOption('TF12'=""),SetOption('TF1'=""),SetOption('TF2'=""),SetOption('TF3'=""),SetOption('TF4'=""),SetOption('TF5'=""),SetOption('TF6'=""),SetOption('TF7'=""),SetOption('TF8'=""),SetOption('TF9'=""),
SetOption('TF10'=""),SetOption('TF11'=""), SetOption('TB1'=""),Evaluate('PL1'="plot(undefined,x=1..10,axes = none)"), CloseWindow('W2'), RunWindow('W1'))) ]
])
);
end use:
Maplets[Display](lab9maplet);restart;