{VERSION 6 0 "IBM INTEL NT" "6.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "" -1 260 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 261 "" 1 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 265 "" 1 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Tim es" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 } {PSTYLE "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {PARA 256 "" 0 "" {TEXT 260 49 "Calculus Exploration 8A: Appr oximate Integration" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT 261 213 "The following is the Maple code for the Approximate I ntegration Maplet, which can be used to create various Riemann sums in order to approximate the area under a curve using a variety of approx imation techniques. " }{TEXT -1 0 "" }{TEXT 265 87 "You can either exe cute the code below or run the corresponding Maplet from the webpage. " }{TEXT -1 0 "" }}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 23 "Approximate In tegration" }}{EXCHG {PARA 0 "" 0 "" {TEXT 262 36 "Click in red area an d press [Enter]." }{TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 35264 "# Approximate Integration Maplet\n# Copyright 2002 Waterloo Map le Inc.\n# \n# The Approximate Integration maplet computes, plots, and animates approximated definite integrals of a given function f(x) ove r a given interval [a, b] using any of the following methods.\n# Riema nn sums using left, right, upper, lower, midpoint, or random points\n# Trapezoidal rule\n# Simpson's rule or Simpson's 3/8 rule\n# Bode's ru le\n# Newton-Cotes' formula \n# \n# It also provides a comparison of t he above approximations for a given function, range, and number of par titions. \n# \n# The user enters a function, and the upper and lower \+ limits (a and b) of the definite integral to approximate. \n# \n# The user selects a method for approximation and sets the number of partit ions by moving the slider.\n# \n# When the user clicks the Plot button , the definite integral of the input function from a to b is approxima ted and displayed in the plotter window. \n# \n# An animation showing how the approximation improves as the number of partitions increases \+ can be generated by setting various options and then clicking the Anim ate button. \n# \n# The user can control how an interval is subdivide d. The halve option indicates that the interval is to be subdivided in to two equal subintervals. The random option indicates that the inter val is to be randomly subdivided. \n# \n# The user can control which \+ intervals are to be subpartitioned with each iteration. The all optio n indicates that every interval is subpartitioned. The width option in dicates that the interval with greatest width is subpartitioned. If th ere is more than one interval with largest width, the leftmost is subp artitioned. The area option indicates that the interval with greatest \+ area is subpartitioned. If there is more than one interval with larges t area, the leftmost is subpartitioned. \n# \n# When the user clicks t he Compare button, a comparison of the values computed by all methods \+ is displayed.\n# \n# To run this maplet, click the Execute (!!!) butto n in the context bar.\n# \nrestart; \nApproxIntegralMaplet := module ()\n\n\n############################################################\n \nexport getApproxIntegral, runApproxIntegralMaplet, \n getPlotO ptions, getAnimationOptions, getMethod, \n getMainExpr, getParti tionExpr, getSavedStr, getupStr, getlowStr, getleftStr, getmidStr, get rightStr, gettrapStr, getsimpStr, getsimp38Str, getbodeStr, getorder5S tr, getorder6Str, getorder7Str, getorder8Str:\nlocal helpStr, savedStr , upStr, lowStr, leftStr, midStr , rightStr, trapStr, simpStr, simp38S tr, bodeStr, order5Str, order6Str,order7Str,order8Str:\n\n############ ################################################\n\n################## ##########################################\n\nhelpStr := \n\"The Appro ximate Integration maplet computes, plots, and animates approximated d efinite integrals of a given function f(x) over a given interval [a, b ] using any of the following methods.\n\267\011Riemann sums using left , right, upper, lower, midpoint, or random points\n\267\011Trapezoidal rule\n\267\011Simpson's rule or Simpson's 3/8 rule\n\267\011Bode's ru le\n. Newton-Cotes' formula \n\nIt also provides a comparison of the \+ above approximations for a given function, range, and number of partit ions. \n\nEnter a function, and the upper and lower limits (a and b) \+ of the definite integral to approximate. \nSelect a method for approx imation and set the number of partitions by moving the slider.\n\nClic k the 'Plot' button. The definite integral of the function from a to \+ b is approximated and displayed in the plotter window. \n\nTo display an animation of how the approximation improves as the number of parti tions increases, set various options and click the 'Animate' button. \+ \n\nTo control how an interval is subdivided, select 'halve' or 'rando m'. The 'halve' option indicates that the interval is to be subdivided into two equal subintervals. The 'random' option indicates that the i nterval is to be randomly subdivided. \n\nTo control which intervals \+ are to be subpartitioned with each iteration, select 'all', 'width', o r 'area'. The 'all' option indicates that every interval is subpartit ioned. The 'width' option indicates that the interval with greatest wi dth is subpartitioned. If there is more than one interval with largest width, the leftmost is subpartitioned. The 'area' option indicates th at the interval with greatest area is subpartitioned. If there is more than one interval with largest area, the leftmost is subpartitioned. \+ \n\nTo compare the values computed by all methods, click the 'Compare' button.\n \n\":\n\n################################################# ###########\n\n####################################################### #####\n\ngetSavedStr:= proc()\n savedStr;\nend:\n\ngetupStr:=proc()\n \+ upStr;\nend:\n \ngetlowStr:=proc()\n lowStr;\nend:\n\ngetleftStr:=proc ()\n leftStr;\nend:\n\ngetmidStr:=proc()\n midStr;\nend:\n\ngetrightSt r:=proc()\n rightStr;\nend:\n\ngettrapStr:=proc()\n trapStr;\nend:\n\n getsimpStr:=proc()\n simpStr;\nend:\n\ngetsimp38Str:=proc()\n simp38St r;\nend:\n\ngetbodeStr:=proc()\n bodeStr;\nend:\n\ngetorder5Str:=proc( )\n order5Str;\nend:\n\ngetorder6Str:=proc()\n order6Str;\nend:\n\nget order7Str:=proc()\n order7Str;\nend:\n\ngetorder8Str:=proc()\n order8S tr;\nend:\n\n######################################################### ###\ngetMainExpr := proc(P_fun, P_a, P_b)\n\n local temp, temp2, str, view:\n \n use Maplets:-Tools, StringTools in\n\n temp:=Trim(P_f un):\n if temp=\"\" then \n error \"No function or algebraic e xpression entered\":\n end if:\n str := temp:\n \n temp: =Trim(P_a):\n \n if temp=\"\" then \n error \"No lower limit e ntered: a = ?\":\n end if:\n \n temp2:=Trim(P_b):\n \n if temp2=\"\" then \n error \"No upper limit entered: b = ?\" :\n end if:\n str := cat(str, \", \", temp, \"..\", temp2):\n \+ \n return str:\n\n end use:\n\nend proc: # end getMainExpr\n\n#### ########################################################\n\n########## ##################################################\n\ngetPartitionExpr := proc(P_partition,P_fun, P_a, P_b)\n local str, numPartition:\n u se Maplets:-Tools, StringTools in\n numPartition:=parse(P_partition ): \n return cat(getMainExpr(P_fun, P_a, P_b), \", \", \"partition =\", numPartition ):\n end use:\nend proc: # end getPartitionExpr\n\n ############################################################\n\n###### ######################################################\n\ngetPlotOptio ns := proc(isOutline, isShowArea, isShowFunction, isShowPoints,P_x1, P _x2, P_y1, P_y2,P_partition,P_fun, P_a, P_b)\n\n local temp, temp2, s tr, view:\n \n use Maplets:-Tools, StringTools in\n\n str := getP artitionExpr(P_partition,P_fun, P_a, P_b):\n\n if isOutline=true th en\n str := cat(str, \", outline=true\"):\n end if:\n\n if \+ isShowArea=false then\n str := cat(str, \", showarea=false\"):\n \+ end if:\n\n if isShowFunction=false then\n str := cat(str, \+ \", showfunction=false\"):\n end if:\n\n if isShowPoints=false t hen\n str := cat(str, \", showpoints=false\"):\n end if: \n\n \+ view := [\"DEFAULT\",\"DEFAULT\"]:\n\n temp:=Trim(P_x1):\n te mp2:=Trim(P_x2):\n if temp<>\"\" and temp2<>\"\" then\n temp:= cat(temp, \"..\", temp2):\n view[1]:=temp:\n end if: \n\n t emp:=Trim(P_y1):\n temp2:=Trim(P_y2):\n if temp<>\"\" and temp2< >\"\" then\n temp:=cat(temp, \"..\", temp2):\n view[2]:=temp :\n end if: \n\n if not (view[1]=\"DEFAULT\" and view[2]=\"DEFAU LT\") then \n temp:=cat(\", view=[\", view[1], \", \", view[2], \+ \"]\"):\n str := cat(str, temp):\n end if:\n \n return s tr:\n\n end use:\n\nend proc: # end getPlotOptions\n\n############### #############################################\n\n##################### #######################################\n\ngetAnimationOptions := proc (P_iterations, isRandomly, isWidth,isArea)\n\n local temp, list, i, s tr:\n \n use Maplets:-Tools, StringTools in\n\n temp:=Trim(P_iter ations):\n if temp<>\"\" then \n list := [cat(\"iterations=\", temp)]:\n end if: \n\n if isRandomly=true then\n list := [o p(list), \"refinement=random\"]:\n end if:\n\n if isWidth=true t hen\n list := [op(list), \"subpartition=width\"]:\n elif isAre a=true then\n list := [op(list), \"subpartition=area\"]:\n end if:\n\n if nops(list)=0 then \n return NULL:\n else \n \+ str := \"\":\n for i from 1 to nops(list) do\n str := ca t(str, \", \", list[i]):\n end do:\n return str:\n end if : \n\n end use:\n\nend proc: # end getAnimationOptions\n\n########### #################################################\n\n################# ###########################################\n\ngetMethod := proc(way, \+ isLeft, isRight, isUp, isLow, isRandom, isTrap, isSimp, isSimp38, isBo de, isNewton,P_order)\n \n local method:\n \n use Maplets:-Tools i n \n\n if isLeft = true then\n method := \"left\":\n\n elif isRight = true then \n method := \"right\":\n\n elif isUp = t rue then \n method := \"upper\":\n\n elif isLow = true then \n method := \"lower\":\n\n elif isRandom = true then \n me thod := \"random\":\n\n elif isTrap = true then \n method := \+ \"trapezoid\":\n\n elif isSimp = true then \n method := \"simp son\":\n\n elif isSimp38 = true then \n method := \"simpson[3/ 8]\":\n\n elif isBode = true then \n method := \"bode\":\n\n \+ elif isNewton = true then \n method := StringTools:-Trim(P_orde r):\n if method=\"\" then\n error \"Enter the order of New ton-Cotes' method\":\n end if:\n method := cat(\"newtoncotes [\", method, \"]\"):\n\n else \n return NULL:\n\n end if:\n \n return cat(\", method=\", method):\n \n end use: \n\nend proc : # end ApproxIntegral\n\n############################################ ################\n\n################################################## ##########\n \ngetApproxIntegral := proc(way,P_fun, P_a, P_b,isLeft, i sRight, isUp, isLow, isRandom, isTrap, isSimp, isSimp38, isBode, isNew ton,P_order,isOutline, isShowArea, isShowFunction, isShowPoints,P_x1, \+ P_x2, P_y1, P_y2,P_iterations, isRandomly, isWidth,isArea,P_partition) \n \n local str, temp,method:\n \n use Student:-Calculus1, Maplets :-Tools, StringTools in \n \n method:= parse(way):\n if method=plo t then\n str := getPlotOptions(isOutline, isShowArea, isShowFunct ion, isShowPoints,P_x1, P_x2,\n P_y1,P_y2,P _partition,P_fun, P_a, P_b):\n str := cat(str, \n \+ getMethod(way, isLeft, isRight, isUp, isLow, isRandom, isTrap, isSimp ,\n isSimp38, isBode, isNewton,P_order)\n \+ ): \n savedStr:=evalf(ApproximateInt(parse (str))): \n ApproximateInt(parse(str), title=\" \",output=plot): \n\n elif method=animation then\n str := getPlotOptions(isOutl ine, isShowArea, isShowFunction, isShowPoints,P_x1, P_x2,\n \+ P_y1, P_y2,P_partition,P_fun, P_a, P_b):\n str : = cat\n (str, \n getMethod(way, isLeft, isRight , isUp, isLow, isRandom, isTrap, isSimp, isSimp38,\n \+ isBode, isNewton,P_order), \n getAnimationOptions(P_i terations, isRandomly, isWidth,isArea)\n ): \n \n \+ savedStr:=ApproximateInt(parse(str)): \n ApproximateInt(parse(s tr),title=\" \", output=animation):\n \n elif method=list then\n \+ str := getPartitionExpr(P_partition,P_fun, P_a, P_b):\n temp: = cat(str,\",method=upper\"):\n upStr := evalf(ApproximateInt(par se(temp)), 22): \n temp:= cat(str,\",method=lower\"):\n low Str := evalf(ApproximateInt(parse(temp)), 22): \n temp:= cat(str ,\",method=left\"):\n leftStr := evalf(ApproximateInt(parse(temp)) , 22): \n temp:= cat(str,\",method=midpoint\"):\n midStr := evalf(ApproximateInt(parse(temp)), 22): \n temp:= cat(str,\",me thod=right\"):\n rightStr:= evalf(ApproximateInt(parse(temp)), 22 ): \n temp:= cat(str,\",method=trapezoid\"):\n trapStr := e valf(ApproximateInt(parse(temp)), 22): \n temp:= cat(str,\",meth od=simpson\"):\n simpStr:= evalf(ApproximateInt(parse(temp)), 22) : \n temp:= cat(str,\",method=simpson[3/8]\"):\n simp38Str \+ := evalf(ApproximateInt(parse(temp)), 22): \n temp:= cat(str,\", method=bode\"):\n bodeStr := evalf(ApproximateInt(parse(temp)), 2 2): \n temp:= cat(str,\",method=newtoncotes[5]\"):\n order5 Str:= evalf(ApproximateInt(parse(temp)), 22): \n temp:= cat( str,\",method=newtoncotes[6]\"):\n order6Str := evalf(Approximate Int(parse(temp)), 22): \n temp:= cat(str,\",method=newtoncot es[7]\"):\n order7Str := evalf(ApproximateInt(parse(temp)), 22): \+ \n temp:= cat(str,\",method=newtoncotes[8]\"):\n order8 Str := evalf(ApproximateInt(parse(temp)), 22):\n \n\n else \n \+ ApproximateInt(parse(str)): \n\n end if:\n \n end use: \n\ne nd proc: # end getApproxIntegral\n\n################################## ##########################\n\n\n###################################### ######################\n\n# pre: null\n# post: run Inverse Function Ma plet\nrunApproxIntegralMaplet := proc()\n\nlocal maplet:\nuse Maplets: -Elements, MathML in\n\n############################################## ##############\n\nmaplet := Maplet(\n 'onstartup'=RunWindow('mainWin' ),\n\n############################################################\n\n Font['F1']('family'=\"Default\", 'bold'='true', 'italic'='true'),\n \+ Font['F2']('family'=\"Default\", 'bold'='true', 'size'=14),\n\n###### ######################################################\n\n MenuBar['M B'](\n Menu(\"File\",\n MenuItem(\"Plot\", 'onclick'='A_plot') , \n MenuItem(\"Animate\", 'onclick'='A_animate'), \n MenuSe parator(),\n MenuItem(\"Close\", 'onclick'=Shutdown())\n ), # \+ end Menu/File\n Menu(\"Compare\", \n MenuItem(\"Compare Method s\", 'onclick'=A_compare)\n ), # end menu/Compare\n Menu(\"Help \", \n MenuItem(\"Using this Maplet\", 'onclick'=RunWindow('helpW in'))\n ) # end menu/Help\n ), # end MenuBar \n\n################# ###########################################\n\n Window['mainWin']('re sizable'='false', \n 'title'=\"Calculus 1 - Approximate Integration \",\n 'menubar'='MB', 'defaultbutton'='B_plot', \n \n BoxCo lumn('inset'=0, 'spacing'=0, 'background'=\"#DDFFFF\",\n\n BoxRow ('inset'=0, 'spacing'=2, 'background'=\"#DDFFFF\", \n\n BoxRow( 'inset'=0, 'spacing'=0, 'background'=\"#DDFFFF\", \n 'border' ='true', 'caption'=\"Enter a function and interval\", \n Lab el(\"Function \", 'font'='F2', 'background'=\"#DDFFFF\"), \n \+ TextField['TF_fun']('width'=20, 'background'=\"#EEFFFF\", \n \+ 'tooltip'=\"Enter any valid function or algebraic expression\",\n \+ 'value'=sin(x)),\n Label(\" a \", 'font'='F2', 'back ground'=\"#DDFFFF\"), \n Label(\" = \", 'font'='F1', 'backgro und'=\"#DDFFFF\"), \n TextField['TF_a']('value'=0, 'width'=2, 'background'=\"#EEFFFF\", \n 'tooltip'=\"Enter the lower l imit of approximated integral\"),\n Label(\" b \", 'font'='F2 ', 'background'=\"#DDFFFF\"), \n Label(\" = \", 'font'='F1', \+ 'background'=\"#DDFFFF\"), \n TextField['TF_b']('value'=\"Pi \", 'width'=2, 'background'=\"#EEFFFF\", \n 'tooltip'=\"Ent er the upper limit of approximated integral\")\n ) # end BoxRow \n\n ), # end BoxRow \n\n BoxRow('inset'=0, 'spacing'= 0, 'background'=\"#DDFFFF\",\n \n BoxColumn('inset'=0, 'spacing '=0, 'background'=\"#DDFFFF\", \n\n BoxRow('inset'=0, 'spacin g'=0, 'background'=\"#DDFFFF\", \n 'border'='true', 'capt ion'=\"Plot Window\", \n Plotter['P']('background'=\"#EEF FFF\", 'cyclic'=true, \n 'continuous'=true, 'delay'=300 )\n ), # end BoxRow\n\n BoxColumn('inset'=0, 'spacin g'=5, 'background'=\"#DDFFFF\",\n 'border'='true', 'caption '=\"Display Options\",\n \n BoxRow('inset'=0, 'sp acing'=6, 'background'=\"#DDFFFF\",\n CheckBox[CB_showare a]('value'=true, 'background'=\"#DDFFFF\", \n 'caption' =\"Show the value of the area\" \n ), # end CheckBox\n CheckBox[CB_showfunction]('value'=true, 'background'=\"# DDFFFF\", \n 'caption'=\"Show function\" \n \+ ) # end CheckBox\n ), # BoxRow \n\n BoxRow( 'inset'=0, 'spacing'=4, 'background'=\"#DDFFFF\",\n Check Box[CB_outline]('value'=false, 'background'=\"#DDFFFF\", \n \+ 'caption'=\"Outline the boxes as a whole\" \n ), \+ # end CheckBox\n CheckBox[CB_showpoints]('value'=true, 'b ackground'=\"#DDFFFF\", \n 'caption'=\"Show points\" \+ \n ) # end CheckBox\n ), # BoxRow\n\n \+ BoxRow('inset'=0, 'spacing'=0, 'background'=\"#DDFFFF\", \n \+ Label(\"x\", 'font'='F2', 'background'=\"#DDFFFF\"), \n \+ Label(\" = \", 'font'='F1', 'background'=\"#DDFFFF\"),\n \+ TextField['x1'](2, 'background'=\"#EEFFFF\",'value'=\" \"), \+ \n Label(\" .. \", 'font'='F2', 'background'=\"#DDFFFF\") ,\n TextField['x2'](2, 'background'=\"#EEFFFF\",'value'= \" \"),\n Label(\" y\", 'font'='F2', 'background'=\"#DDFF FF\"), \n Label(\" = \", 'font'='F1', 'background'=\"#DDF FFF\"),\n TextField['y1'](2, 'background'=\"#EEFFFF\",'va lue'=\" \"),\n Label(\" .. \", 'font'='F2', 'background'= \"#DDFFFF\"),\n TextField['y2'](2, 'background'=\"#EEFFFF \",'value'=\" \") \n ) # end BoxRow \n ) \+ # end BoxColumn\n\n ), # end BoxColumn\n\n BoxColumn('ins et'=0, 'spacing'=0, 'background'=\"#DDFFFF\",\n\n BoxColumn(' inset'=0, 'spacing'=0, 'background'=\"#DDFFFF\", \n 'border '='true', 'caption'=\"Riemann Sums\", \n BoxRow('inset'=0 , 'spacing'=0, 'background'=\"#DDFFFF\", \n RadioButton ['RB_up']('caption'=\"upper\", 'group'='BG_methods', \n \+ 'background'=\"#DDFFFF\",\n 'tooltip'=\"Upper Riem ann sum\"),\n RadioButton['RB_low']('caption'=\"lower\" , 'group'='BG_methods', \n 'background'=\"#DDFFFF\", \n 'tooltip'=\"Lower Riemann sum\"),\n \+ RadioButton['RB_random']('caption'=\"random\", 'group'='BG_methods', \+ \n 'background'=\"#DDFFFF\",\n 'tool tip'=\"Random selection of point\")\n ), # end BoxRow\n \+ \n BoxRow('inset'=0, 'spacing'=0, 'background'=\"#DDFF FF\", \n RadioButton['RB_left']('caption'=\"left\", 'gr oup'='BG_methods', \n 'background'=\"#DDFFFF\",\n \+ 'tooltip'=\"Left Riemann sum\"),\n RadioB utton['RB_mid']('caption'=\"midpoint\", 'group'='BG_methods', \n \+ 'background'=\"#DDFFFF\",\n 'tooltip'=\"M idpoint Riemann sum\", 'value'=true),\n RadioButton['RB _right']('caption'=\"right\", 'group'='BG_methods', \n \+ 'background'=\"#DDFFFF\",\n 'tooltip'=\"Right Riema nn sum\")\n ) # end BoxRow\n ), # end BoxColumn \n\n BoxColumn('inset'=0, 'spacing'=0, 'background'=\"#DDFFFF \", \n 'border'='true', 'caption'=\"Newton-Cotes' Formulae \",\n BoxRow('inset'=0, 'spacing'=0, 'background'=\"#DDFFFF \", \n RadioButton['RB_trap']('group'='BG_methods',\n \+ 'caption'=\"Trapezoidal Rule\", \n \+ 'background'=\"#DDFFFF\"),\n RadioButton['RB_sim p']('group'='BG_methods',\n 'caption'=\"Simpson's Rule \", \n 'background'=\"#DDFFFF\")\n \+ ), # end BoxRow\n \n BoxRow('inset'=0, 'spacing' =0, 'background'=\"#DDFFFF\", \n RadioButton['RB_simp38'] ('group'='BG_methods',\n 'caption'=\"Simpson's 3/8 Rule \", \n 'background'=\"#DDFFFF\"),\n \+ RadioButton['RB_bode']('group'='BG_methods',\n \+ 'caption'=\"Bode's Rule\", \n 'back ground'=\"#DDFFFF\")\n ), # end BoxRow \n \n \+ BoxRow('inset'=0, 'spacing'=0, 'background'=\"#DDFFFF\", \n \+ RadioButton['RB_newton']('group'='BG_methods',\n 'c aption'=\"Newton-Cotes' Formula\", \n \+ 'background'=\"#DDFFFF\"),\n Label(\"with order = \", 'ba ckground'=\"#DDFFFF\"), \n TextField['TF_order'](2, 'valu e'=5, \n 'background'=\"#EEFFFF\")\n ) # end BoxRow\n ), # end BoxColumn\n\n BoxColumn('inset'=0 , 'spacing'=0, 'background'=\"#DDFFFF\", \n 'border'='true' , 'caption'=\"Number of Partition\",\n Slider['SL_partition ']('lower'=1, 'upper'=46,\n 'background'=\"#DDFFFF\", 'fo reground'=\"#CCFFFF\", \n 'majorticks'=9, 'minorticks'=1, 'value'=10, \n 'tooltip'=\"Initial number of equally spa ced subintervals\" \n ) # end Slider\n ), # end B oxColumn\n\n BoxRow('inset'=0, 'spacing'=0, 'background'=\"#D DFFFF\", \n 'border'='true', 'caption'=\"Approximated Area \", \n Label(\"Area\", 'font'='F2', 'background'=\"#DDFFFF \"), \n Label(\" = \", 'font'='F1', 'background'=\"#DDFFFF \"), \n TextField['TF_area']('width'=18, 'background'=\"#EE FFFF\", \n 'editable'=false, 'tooltip'=\"Approximated int egral sum\",'value'=\" \"),\n TextField['way_plot']('value' =\"plot\",'visible'='false'), \n TextField['way_ animate']('value'=\"animation\",'visible'='false'),\n TextF ield['way_list']('value'=\"list\",'visible'='false') \n \+ ), # end BoxRow\n\n BoxColumn('inset'=0, 'spacing'=0, ' background'=\"#DDFFFF\", \n 'border'='true', 'caption'=\"An imation Options\",\n BoxRow('inset'=0, 'spacing'=4, 'backgr ound'=\"#DDFFFF\", \n Button[B_play](\"Play\", 'backgroun d'=\"#EEFFFF\", 'enabled'=false, \n SetOption(P('play' )=true)),\n Button[B_stop](\"Stop\", 'background'=\"#EEFF FF\", 'enabled'=false, \n SetOption(P('`stop`')=true)), \n Button[B_pause](\"Pause\", 'background'=\"#EEFFFF\", ' enabled'=false, \n SetOption(P('pause')=true))\n \+ ), # end BoxRow\n BoxRow('inset'=0, 'spacing'=4, ' background'=\"#DDFFFF\", \n Button[B_backward](\"Backward \", 'background'=\"#EEFFFF\", 'enabled'=false, \+ SetOption(P('frame_backwards')=true), ' tooltip'=\"Previous frame\", 'visible'='false'),\n Button [B_forward](\"Forward\", 'background'=\"#EEFFFF\", 'enabled'=false, \+ \n SetOption(P('frame_forward')=true), 'tooltip'=\"Next frame\", 'visible'='false') \n ), # end BoxRow\n \n \+ BoxRow('inset'=0, 'spacing'=0, 'background'=\"#DDFFFF\",\n \+ Label(\"Number of Frames: \", 'background'=\"#DDFFFF\"),\n \+ TextField['TF_iterations']('value'=4, 'width'=3, \n \+ 'background'=\"#EEFFFF\"), \n Label(\" \"), \+ \n CheckBox[CB_repeat]('value'=true, 'background'=\"#DDFF FF\", \n 'caption'=\"Repeat animation\", 'enabled'=fals e, \n 'onchange'=SetOption(target=P, `option`='contin uous', Argument(CB_repeat) )\n ) # end CheckBox \n \+ ), # end BoxRow\n \n BoxRow('inset'=0, 'spacing'=0, \+ 'background'=\"#DDFFFF\",\n Label(\"Subdivide Interval: \+ \", 'background'=\"#DDFFFF\"),\n RadioButton['RB_halve']( 'group'='BG_refinement',\n 'caption'=\"halve\", 'value' =true, \n 'background'=\"#DDFFFF\",\n 'tooltip'=\"Halve each interval\" ),\n Ra dioButton['RB_randomly']('group'='BG_refinement',\n 'ca ption'=\"random\", \n 'background'=\"# DDFFFF\",\n 'tooltip'=\"Randomly divide each interval\" )\n ), # end BoxRow\n \n BoxRow('inset'=0, 'spa cing'=0, 'background'=\"#DDFFFF\",\n Label(\"Subpartition : \", 'background'=\"#DDFFFF\"),\n RadioButton['RB_all']( 'group'='BG_subpartition',\n 'caption'=\"all \", 'value '=true, \n 'background'=\"#DDFFFF\", \n 'tooltip'=\"Divide all partitions\" ),\n \+ RadioButton['RB_width']('group'='BG_subpartition',\n \+ 'caption'=\"width\", \n 'background' =\"#DDFFFF\",\n 'tooltip'=\"Divide partition with the l ongest width\" ),\n RadioButton['RB_area']('group'='BG_su bpartition',\n 'caption'=\"area\", \n \+ 'background'=\"#DDFFFF\",\n 'tooltip'=\" Divide partition with the largest area\" )\n ) # end BoxRow \n ), # end BoxColumn \n\n BoxRow('inset'=0, 'spacin g'=1, 'background'=\"#DDFFFF\", \n Button['B_plot'](\"Plot \", 'background'=\"#EEFFFF\", \n 'onclick'='A_plot'),\n \+ Button(\"Animate\", 'background'=\"#EEFFFF\", \n \+ 'onclick'='A_animate'),\n Button(\"Compare\", 'background '=\"#EEFFFF\", 'onclick'='A_compare',\n 'tooltip'=\"Compa re values of each method\"),\n Button(\"Close\", 'onclick'= Shutdown(), 'background'=\"#EEFFFF\")\n ) # end BoxRow\n\n \+ ) # end Column\n \n ) # end BoxRow\n \n ) # end Bo xColumn\n\n ), # end Window\n\n###################################### ######################\n\n Window['helpWin']( 'resizable'='false',\n \+ 'title'=\"Using the Approximate Integration Maplet\",\n BoxColum n('border'='true', 'inset'=0, 'spacing'=10,\n 'background'=\"#CCF FFF\",\n BoxCell(\n TextBox('height'=20, 'width'=36,\n \+ 'background'=\"#EEFFFF\", 'foreground'=\"#333399\", \n \+ 'editable'='false', 'font'='F2', \n 'value'=helpStr\n \+ ) # end TextBox\n ), # end BoxCell\n BoxRow('inset'=0, 'spac ing'=0, 'background'=\"#CCFFFF\",\n Button(\"Close\", \n \+ CloseWindow('helpWin'), \n 'background'=\"#DDFFFF\")\n \+ ) # end BoxRow\n ) # end BoxColumn\n ), # end helpWin\n\n##### #######################################################\n\n Window['c ompWin']( 'resizable'='false',\n 'title'=\" Comparison of Approxima ted Values\",\n BoxColumn('inset'=0, 'spacing'=10, 'background'=\"# DDFFFF\",\n \n GridLayout('background'=\"#DDFFFF\", 'inset'= 0,\n 'border'=true, 'caption'=\"Riemann Sums\", \n Grid Row('halign'=left, \n GridCell(Label(\"Method \", 'font'='F 2')),\n GridCell(Label(\"Approximated Integral Value\", 'font '='F2'))\n ), # GridRow\n GridRow('halign'=left, \n \+ GridCell(\" Upper Sum \", 'halign'=l eft),\n GridCell(TextField['TF_up']('background'=\"#DDFFFF\", 'value'=\" \"))\n ), # GridRow\n GridRow('halign'=left , \n GridCell(\" Lower Sum \"), \n GridCell(TextField['TF_low']('background'=\"#DDFFFF\", 'va lue'=\" \"))\n ), # GridRow\n GridRow('halign'=left, \n GridCell(\" Left Sum \"),\n GridCell(TextField['TF_left']('background'=\"#DDFFFF\", 'val ue'=\" \"))\n ), # GridRow\n GridRow('halign'=left, \n \+ GridCell(\" Midpoint \"),\n \+ GridCell(TextField['TF_mid']('background'=\"#DDFFFF\", 'value' =\" \"))\n ), # GridRow\n GridRow('halign'=left, \n \+ GridCell(\" Right Sum \"),\n \+ GridCell(TextField['TF_right']('background'=\"#DDFFFF\", 'value'= \" \"))\n ) # GridRow\n ), # end GridLayout\n\n Grid Layout('background'=\"#DDFFFF\", 'inset'=0,\n 'border'=true, 'c aption'=\"Newton-Cotes' Formulae\", \n GridRow('halign'=left, \+ \n GridCell(Label(\"Order\", 'font'='F2')), \n GridC ell(Label(\"Method \", 'font'='F2')), \n GridCell(Label( \"Approximated Integral Value\", 'font'='F2')) \n ), # GridRow \n GridRow('halign'=left, \n GridCell(\"1\"), \n \+ GridCell(\"Trapezoidal Rule \"),\n GridCell(TextFiel d['TF_trap']('background'=\"#DDFFFF\", 'value'=\" \"))\n ), # G ridRow\n GridRow('halign'=left, \n GridCell(\"2\"), \+ \n GridCell(\"Simpson's Rule \"),\n GridCell( TextField['TF_simp']('background'=\"#DDFFFF\", 'value'=\" \"))\n \+ ), # GridRow\n GridRow('halign'=left, \n GridCell( \"3\"), \n GridCell(\"Simpson's 3/8 Rule \"),\n Grid Cell(TextField['TF_simp38']('background'=\"#DDFFFF\", 'value'=\" \")) \n ), # GridRow\n GridRow('halign'=left, \n Gr idCell(\"4\"), \n GridCell(\"Bode's Rule \"),\n \+ GridCell(TextField['TF_bode']('background'=\"#DDFFFF\", 'valu e'=\" \"))\n ), # GridRow\n GridRow('halign'=left, \n \+ GridCell(\"5\"), \n\n GridCell(\"\"),\n GridC ell(TextField['TF_order5']('background'=\"#DDFFFF\", 'value'=\" \"))\n ), # GridRow\n GridRow('halign'=left, \n GridC ell(\"6\"), \n GridCell(\"\"),\n GridCell(TextField[ 'TF_order6']('background'=\"#DDFFFF\", 'value'=\" \"))\n ), # G ridRow\n GridRow('halign'=left, \n GridCell(\"7\"), \n GridCell(\"\"),\n GridCell(TextField['TF_order7'](' background'=\"#DDFFFF\", 'value'=\" \"))\n ), # GridRow\n \+ GridRow('halign'=left, \n GridCell(\"8\"), \n Grid Cell(\"\"),\n GridCell(TextField['TF_order8']('background'=\" #DDFFFF\", 'value'=\" \"))\n ) # GridRow\n ), # end GridL ayout\n \n BoxRow('inset'=0, 'spacing'=0, 'background'=\"#D DFFFF\",\n Button(\"Close\", \n CloseWindow('compWin '), \n 'background'=\"#DDFFFF\", 'foreground'=\"#333399\")\n \+ ) # end BoxRow\n\n ) # end BoxColumn\n ), # end sumWin\n\n## ##########################################################\n\n Button Group['BG_methods'](),\n ButtonGroup['BG_refinement'](),\n ButtonGro up['BG_subpartition'](),\n\n########################################## ##################\n\n Action['A_compare']\n ( \n Evaluate\n \+ ( 'waitforresult'='false','function'='getApproxIntegral',\n Ar gument('way_list'),\n Argument('TF_fun',quotedtext='true'),\n \+ Argument('TF_a',quotedtext='true'),\n Argument('TF_b',quo tedtext='true'),\n Argument(RB_left),\n Argument(RB_righ t),\n Argument(RB_up),\n Argument(RB_low),\n Argu ment(RB_random),\n Argument(RB_trap),\n Argument(RB_simp ),\n Argument(RB_simp38),\n Argument(RB_bode),\n \+ Argument(RB_newton),\n Argument('TF_order',quotedtext='true'), \n Argument(CB_outline),\n Argument(CB_showarea),\n \+ Argument(CB_showfunction),\n Argument(CB_showpoints),\n \+ Argument('x1',quotedtext='true'),\n Argument('x2',quotedtext ='true'),\n Argument('y1',quotedtext='true'),\n Argument ('y2',quotedtext='true'),\n Argument('TF_iterations',quotedtext ='true'),\n Argument(RB_randomly),\n Argument(RB_width), \n Argument(RB_area),\n Argument('SL_partition',quotedte xt='true')\n ), \n Evaluate\n ('waitforresult'='false','targe t'='TF_up','function'='getupStr'\n ),\n Evaluate\n ('waitforr esult'='false','target'='TF_low','function'='getlowStr'\n ), \n \+ Evaluate\n ('waitforresult'='false','target'='TF_left','function'=' getleftStr'\n ), \n Evaluate\n ('waitforresult'='false','targ et'='TF_mid','function'=' getmidStr'\n ), \n Evaluate\n ('wai tforresult'='false','target'='TF_right','function'='getrightStr'\n \+ ), \n Evaluate\n ('waitforresult'='false','target'='TF_trap','fu nction'='gettrapStr'\n ), \n Evaluate\n ('waitforresult'='fal se','target'='TF_simp','function'=' getsimpStr'\n ), \n Evaluate \n ('waitforresult'='false','target'='TF_simp38','function'='getsim p38Str'\n ), \n Evaluate\n ('waitforresult'='false','target'= 'TF_bode','function'=' getbodeStr'\n ), \n Evaluate\n ('waitf orresult'='false','target'='TF_order5','function'='getorder5Str'\n \+ ), \n Evaluate\n ('waitforresult'='false','target'='TF_order6',' function'='getorder6Str'\n ), \n Evaluate\n ('waitforresult'= 'false','target'='TF_order7','function'='getorder7Str'\n ), \n E valuate\n ('waitforresult'='false','target'='TF_order8','function'= 'getorder8Str'\n ), \n RunWindow('compWin') \n ), # end A_comp \n\n\nAction['A_plot']\n ( Evaluate\n ( 'waitforresult'='false' ,'target'='P','function'='getApproxIntegral',\n Argument('way_p lot',quotedtext='true'),\n Argument('TF_fun',quotedtext='true') ,\n Argument('TF_a',quotedtext='true'),\n Argument('TF_b ',quotedtext='true'),\n Argument(RB_left),\n Argument(RB _right),\n Argument(RB_up),\n Argument(RB_low),\n \+ Argument(RB_random),\n Argument(RB_trap),\n Argument(RB _simp),\n Argument(RB_simp38),\n Argument(RB_bode),\n \+ Argument(RB_newton),\n Argument('TF_order',quotedtext='tru e'),\n Argument(CB_outline),\n Argument(CB_showarea),\n \+ Argument(CB_showfunction),\n Argument(CB_showpoints),\n \+ Argument('x1',quotedtext='true'),\n Argument('x2',quoted text='true'),\n Argument('y1',quotedtext='true'),\n Argu ment('y2',quotedtext='true'),\n Argument('TF_iterations',quoted text='true'),\n Argument(RB_randomly),\n Argument(RB_wid th),\n Argument(RB_area),\n Argument('SL_partition',quot edtext='true')\n ),\n\n Evaluate\n ('waitforresult'='fals e','target'='TF_area', 'function'='getSavedStr'\n ),\n SetOpti on( 'B_play'('enabled')='false'),\n SetOption( 'B_stop'('enabled') ='false'),\n SetOption( 'B_pause'('enabled')='false'),\n SetOp tion( 'B_backward'('enabled')='false'),\n SetOption( 'B_forward'(' enabled')='false'),\n SetOption( 'CB_repeat'('enabled')='false') \+ \n ),\n \n Action['A_animate']\n ( Evaluate\n ( 'wai tforresult'='false','target'='P','function'='getApproxIntegral',\n \+ Argument('way_animate'),\n Argument('TF_fun',quotedtext='tr ue'),\n Argument('TF_a',quotedtext='true'),\n Argument(' TF_b',quotedtext='true'),\n Argument(RB_left),\n Argumen t(RB_right),\n Argument(RB_up),\n Argument(RB_low),\n \+ Argument(RB_random),\n Argument(RB_trap),\n Argumen t(RB_simp),\n Argument(RB_simp38),\n Argument(RB_bode), \n Argument(RB_newton),\n Argument('TF_order',quotedtext ='true'),\n Argument(CB_outline),\n Argument(CB_showarea ),\n Argument(CB_showfunction),\n Argument(CB_showpoints ),\n Argument('x1',quotedtext='true'),\n Argument('x2',q uotedtext='true'),\n Argument('y1',quotedtext='true'),\n \+ Argument('y2',quotedtext='true'),\n Argument('TF_iterations',q uotedtext='true'),\n Argument(RB_randomly),\n Argument(R B_width),\n Argument(RB_area),\n Argument('SL_partition' ,quotedtext='true')\n ),\n SetOption( 'B_play'('enabled')='t rue'),\n SetOption( 'B_stop'('enabled')='true'),\n SetOption ( 'B_pause'('enabled')='true'),\n SetOption( 'B_backward'('enable d')='true'),\n SetOption( 'B_forward'('enabled')='true'),\n \+ SetOption( 'CB_repeat'('enabled')='true') \n ),\n\n Action[ 'A']()\n\n############################################################ \n\n): # end Maplet\n\n############################################### #############\n\nMaplets:-Display(maplet):\n\nend use: # end use\nend \+ proc: # end proc\n\n################################################## ##########\n\nend module: # end module\nApproxIntegralMaplet:-runAppro xIntegralMaplet();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{MARK "5" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }