# Antiderivative Maplet # Copyright 2002 Waterloo Maple Inc. # # The Antiderivative maplet graphically illustrates the concept of an antiderivative of a function. # # The user enters a function f(x) and a range on the x-axis [a,b]. If the user provides an initial value for the antiderivative of f(x), the maplet plots the antiderivative that satisfies the initial value condition. # # To run this maplet, click the Execute (!!!) button in the context bar. # restart; AntiderivativeMaplet := module() ############################################################ export getAntiderivativePlot, runAntiderivativeMaplet: local helpStr, valueStr, defStr: ############################################################ ############################################################ helpStr := "The Antiderivative maplet graphically illustrates the concept of an antiderivative of a function. Enter a function f(x) and a range on the x-axis [a,b]. Click 'Plot'. Provide an initial value for the antiderivative of f(x). The maplet plots the antiderivative that satisfies the initial value condition.": defStr:= " Antiderivative An antiderivative of the function f is a function F such that Diff(F(x), x) = f(x) wherever f(x) is defined. ab1+xfx2x ": : valueStr := "This algebraic value, vector, or list determines the primary antiderivative. Any algebraic value, vector, or list can be entered. If no initial value is entered, the primary antiderivative plotted is the one for which the value at the left end point (a) is 0. An algebraic value, such as 0 or Pi, for this option specifies the value of the antiderivative at the left end point of the range. A 2-dimensional Vector or list, such as [0,0], specifies the value of the antiderivative at a point.": ############################################################ ############################################################ getAntiderivativePlot := proc(boo1, boo2, boo3, P_fun, P_a, P_b, P_value, P_x1, P_x2, P_y1, P_y2) local temp, temp2, str, view: use Maplets:-Tools in str:=StringTools:-Trim(P_fun): if str="" then error "No function entered in the text field: TF_fun": end if: temp:=StringTools:-Trim(P_a): temp2:=StringTools:-Trim(P_b): if temp<>"" and temp2<>"" then str:=cat(str, ", ", temp, "..", temp2): end if: if not(boo1 or boo2 or boo3) then return plots[textplot]([1,2,"Select function, antiderivative, or class of antiderivatives"]): end if: if not boo1 then str := cat(str, ", showfunction=false") end if: if not boo2 then str := cat(str, ", showantiderivative=false") end if: if boo3 then str := cat(str, ", showclass=true") end if: temp:=StringTools:-Trim(P_value): if temp<>"" then str := cat(str, ", value=", temp): end if: view := ["DEFAULT","DEFAULT"]: temp:=StringTools:-Trim(P_x1): temp2:=StringTools:-Trim(P_x2): if temp<>"" and temp2<>"" then view[1]:=cat(temp, "..", temp2): end if: temp:=StringTools:-Trim(P_y1): temp2:=StringTools:-Trim(P_y2): if temp<>"" and temp2<>"" then view[2]:=cat(temp, "..", temp2): end if: temp:=cat(", view=[", view[1], ", ", view[2], "]"): str := cat(str, temp): Student:-Calculus1:-AntiderivativePlot(eval(parse(str))): end use: end proc: ############################################################ ############################################################ runAntiderivativeMaplet := proc() local maplet: use Maplets:-Elements in ############################################################ maplet := Maplet( 'onstartup'=RunWindow('mainWin'), ############################################################ Font['F1']('family'="Default", 'bold'='true', 'italic'='true'), Font['F2']('family'="Default", 'bold'='true', 'size'=14), ############################################################ MenuBar['MB']( Menu("File", MenuItem("Plot",'onclick'='A_plot'), MenuSeparator(), MenuItem("Close", 'onclick'=Shutdown()) ), # end Menu/File Menu("Help", MenuItem("Using this Maplet", 'onclick'=RunWindow('helpWin')) ) # end menu/Help ), # end MenuBar ############################################################ Window['mainWin']('resizable'='true', 'title'="Calculus 1 - Antiderivative", 'menubar'='MB', 'defaultbutton'='B_plot', BoxRow('inset'=0, 'spacing'=0, 'background'="#DDFFFF", BoxColumn('inset'=0, 'spacing'=0, 'background'="#DDFFFF", 'border'='true', 'caption'="Plot Window", Plotter['P']('background'="#EEFFFF") ), # end BoxRow BoxColumn('inset'=0, 'spacing'=0, 'background'="#DDFFFF", 'border'='false', BoxRow('inset'=0, 'spacing'=0, 'background'="#DDFFFF", 'border'='true', 'caption'="Enter a function and the plot range (optional)", Label("Function ", 'font'='F2', 'background'="#DDFFFF"), TextField['TF_fun']('width'=15, 'background'="#EEFFFF", 'tooltip'="Continuous on [a,b], differentiable on (a,b)", 'value'=3*x^2), Label(" a ", 'font'='F2', 'background'="#DDFFFF"), Label(" = ", 'font'='F1', 'background'="#DDFFFF"), TextField['TF_a']('value'=-2, 'width'=3, 'background'="#EEFFFF", 'tooltip'="Lower end point"), Label(" b ", 'font'='F2', 'background'="#DDFFFF"), Label(" = ", 'font'='F1', 'background'="#DDFFFF"), TextField['TF_b']('value'=2, 'width'=3, 'background'="#EEFFFF", 'tooltip'="Upper end point") ), # end BoxRow BoxRow('inset'=0, 'spacing'=2, 'background'="#DDFFFF", 'border'='true', 'caption'="Initial Value of the Primary Antiderivative", Label(" Value", 'font'='F2', 'background'="#DDFFFF"), TextField['TF_value']('width'=15, 'background'="#EEFFFF", 'value'=0), Button("What is this?", 'background'="#DDFFFF", 'onclick'=RunWindow(valueWin)) ), # end BoxRow BoxRow('inset'=0, 'spacing'=0, 'background'="#DDFFFF", BoxColumn('inset'=0, 'spacing'=0, 'background'="#DDFFFF", 'border'='true', 'caption'="Display Options", BoxRow('inset'=0, 'spacing'=0, 'background'="#DDFFFF", CheckBox[CB1]('value'=true, 'background'="#DDFFFF", 'caption'="Show the function" ), # end CheckBox CheckBox[CB2]('value'=true, 'background'="#DDFFFF", 'caption'="Show an antiderivative" ) # end CheckBox ), # end BoxRow BoxRow('inset'=0, 'spacing'=0, 'background'="#DDFFFF", CheckBox[CB3]('value'=false, 'background'="#DDFFFF", 'caption'="Show class of antiderivatives" ) # end CheckBox ), # end BoxRow BoxRow('inset'=0, 'spacing'=0, 'background'="#DDFFFF", Label("x", 'font'='F2', 'background'="#DDFFFF"), Label(" = ", 'font'='F1', 'background'="#DDFFFF"), TextField['x1'](2, 'background'="#EEFFFF", 'value'=" "), Label("..", 'font'='F2', 'background'="#DDFFFF"), TextField['x2'](2, 'background'="#EEFFFF", 'value'=" "), Label(" y", 'font'='F2', 'background'="#DDFFFF"), Label(" = ", 'font'='F1', 'background'="#DDFFFF"), TextField['y1'](2, 'background'="#EEFFFF", value=" "), Label("..", 'font'='F2', 'background'="#DDFFFF"), TextField['y2'](2, 'background'="#EEFFFF", value=" ") ) # end BoxRow )), # end BoxColumn BoxRow('inset'=0, 'spacing'=4, 'background'="#DDFFFF", 'halign'=center, Button['B_plot'](" Plot ", 'background'="#EEFFFF", 'onclick'='A_plot' ), # end Button Button("Close", 'background'="#EEFFFF", Shutdown()) ) # end BoxColumn ) # end BoxRow ) # end BoxColumn ), # end Window ############################################################ Window['helpWin']( 'resizable'='false', 'title'="Using the Antiderivative Maplet", BoxColumn('border'='true', 'inset'=0, 'spacing'=5, 'background'="#CCFFFF", BoxCell( TextBox('height'=9, 'width'=26, 'background'="#DDFFFF", 'foreground'="#333399", 'editable'='false', 'font'='F2', 'value'=helpStr ) # end TextBox ), # end BoxCell BoxRow('inset'=0, 'spacing'=0, 'background'="#CCFFFF", Button("Close", CloseWindow('helpWin'), 'background'="#DDFFFF") ) # end BoxRow ) # end BoxColumn ), # end helpWin ############################################################ Window['valueWin']( 'resizable'='false', 'title'="The Initial Value of the Primary Antiderivative", BoxColumn('border'='true', 'inset'=0, 'spacing'=5, 'background'="#CCFFFF", BoxCell( TextBox['ML_def']('height'=15, 'width'=26, 'value'=valueStr, 'height'=15, 'width'=26, 'background'="#CCFFFF", 'foreground'="#333399", 'font'='F2', 'editable'='false') ), # end BoxRow BoxRow('background'="#CCFFFF", 'inset'=0, 'spacing'=0, 'background'="#CCFFFF", Button("Close", 'font'='F2', CloseWindow('valueWin'), 'background'="#DDFFFF", 'foreground'="#333399") ) # end BoxRow ) # end BoxColumn ), # end valueWin ############################################################ Action['A'](), Action['A_plot'] ( Evaluate ( 'waitforresult'='false', 'function'='getAntiderivativePlot', 'target'='P', Argument('CB1'), Argument('CB2'), Argument('CB3'), Argument('TF_fun', quotedtext='true'), Argument('TF_a', quotedtext='true'), Argument('TF_b', quotedtext='true'), Argument('TF_value', quotedtext='true'), Argument('x1', quotedtext='true'), Argument('x2', quotedtext='true'), Argument('y1', quotedtext='true'), Argument('y2', quotedtext='true') ) ) ############################################################ ): # end Maplet ############################################################ Maplets:-Display(maplet): end use: # end use end proc: # end proc ############################################################ end module: # end AntiderivativeMaplet AntiderivativeMaplet:-runAntiderivativeMaplet();