{VERSION 6 0 "IBM INTEL NT" "6.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 1 12 255 0 0 1 2 1 2 2 1 2 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 2 0 2 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "with(Maplets[Tools]): with(Maplets[ Elements]):\nStartEngine();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "randomize():" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "functio ns:=[1/x, sqrt(1+x^3), x, x^2]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "randfunc:=rand(1..nops(functions)):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "randa:=rand(0..2):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "randn:=rand(3..6):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "rand12:=rand(1..2):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "dxs:=[1/3, 1/2, 1, 2]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "randdx:=rand(1..nops(dxs)):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1872 " New_Integral:=proc()\nglobal functions, randfunc,randa,randn,dxs,randd x, a,b, n, func, dx, Tn;\nfunc:=functions[randfunc()];\na:=randa();\nw hile func=1/x and a=0 do\n a:=randa();\nend do;\ndx:=dxs[randdx()];\n if dx=1/3 then\n n:=3*rand12();\nelse\n n:=randn();\nend if;\nb:=a+n *dx;\nTn := dx/2*(eval(func, x=a) + 2*sum(eval(func, x=a+i*dx),i=1..n- 1)+ eval(func, x=b));\nSet(MMLIntegral(value) = MathML[Export](Int(fun c, x=a..b)));\nSet(nvalue(value) = n);\nif n=3 then\nSet(Ln4(visible) \+ = false);\nSet(Ln5(visible) = false);\nSet(Ln6(visible) = false);\nSet (TFx4(visible) = false);\nSet(TFx5(visible) = false);\nSet(TFx6(visibl e) = false);\nSet(TFfx4(visible) = false);\nSet(TFfx5(visible) = false );\nSet(TFfx6(visible) = false);\nend if;\nif n=4 then\nSet(Ln4(visibl e) = true);\nSet(Ln5(visible) = false);\nSet(Ln6(visible) = false);\nS et(TFx4(visible) = true);\nSet(TFx5(visible) = false);\nSet(TFx6(visib le) = false);\nSet(TFfx4(visible) = true);\nSet(TFfx5(visible) = false );\nSet(TFfx6(visible) = false);\nend if;\nif n=5 then\nSet(Ln4(visibl e) = true);\nSet(Ln5(visible) = true);\nSet(Ln6(visible) = false);\nSe t(TFx4(visible) = true);\nSet(TFx5(visible) = true);\nSet(TFx6(visible ) = false);\nSet(TFfx4(visible) = true);\nSet(TFfx5(visible) = true); \nSet(TFfx6(visible) = false);\nend if;\nif n=6 then\nSet(Ln4(visible) = true);\nSet(Ln5(visible) = true);\nSet(Ln6(visible) = true);\nSet(T Fx4(visible) = true);\nSet(TFx5(visible) = true);\nSet(TFx6(visible) = true);\nSet(TFfx4(visible) = true);\nSet(TFfx5(visible) = true);\nSet (TFfx6(visible) = true);\nend if;\nSet('c'=\"\");\nSet('c0'=\"\");\nSe t('c1'=\"\");\nSet('c2'=\"\");\nSet('cn1'=\"\");\nSet('cn'=\"\");\nSet ('Deltax'=\"\");\nSet('TFx0'=\"\");\nSet('TFx1'=\"\");\nSet('TFx2'=\" \");\nSet('TFx3'=\"\");\nSet('TFx4'=\"\");\nSet('TFx5'=\"\");\nSet('TF x6'=\"\");\nSet('TFfx0'=\"\");\nSet('TFfx1'=\"\");\nSet('TFfx2'=\"\"); \nSet('TFfx3'=\"\");\nSet('TFfx4'=\"\");\nSet('TFfx5'=\"\");\nSet('TFf x6'=\"\");\nSet('Approx'=\"\")\nend proc:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1216 "che ckDeltax:=proc()\nglobal dx;\nlocal userdx, userc, userc0, userc1, use rc2, usercn1, usercn, correct;\n\nuserc:=Get('c'::'realcons'):\nif use rc<>1/2\n then Set('reply'=\"Incorrect coefficient of Delta x. I thin k you need more practice.\");\n return;\nend if;\nuserc0:=Get('c0'::' realcons'):\nif userc0<>1\n then Set('reply'=\"Incorrect coefficient \+ of f(x0). I think you need more practice.\");\n return;\nend if;\nuse rc1:=Get('c1'::'realcons'):\nif userc1<>2\n then Set('reply'=\"Incorr ect coefficient of f(x1). I think you need more practice.\");\n retur n;\nend if;\nuserc2:=Get('c2'::'realcons'):\nif userc2<>2\n then Set( 'reply'=\"Incorrect coefficient of f(x2). I think you need more practi ce.\");\n return;\nend if;\nusercn1:=Get('cn1'::'realcons'):\nif user cn1<>2\n then Set('reply'=\"Incorrect coefficient of f(xn-1). I think you need more practice.\");\n return;\nend if;\nusercn:=Get('cn'::'r ealcons'):\nif usercn<>1\n then Set('reply'=\"Incorrect coefficient o f f(xn). I think you need more practice.\");\n return;\nend if;\n\nus erdx:=Get('Deltax'::'realcons'):\nif userdx<>dx\n then Set('reply'=\" Incorrect Delta x. I think you need more practice.\");\n return;\nend if;\n\nSet('reply'=\"Correct coefficients and Delta x! Great job!!\") \nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 137 "showDeltax: =proc()\nglobal dx;\nSet('c'=1/2);\nSet('c0'=1);\nSet('c1'=2);\nSet('c 2'=2);\nSet('cn1'=2);\nSet('cn'=1);\nSet('Deltax'=dx);\nend proc:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 939 "checkTable:=proc()\nglobal n,a,dx,func;\nlocal use rx, i, correct, userfx, correct2;\n\nuserx[0]:=Get('TFx0'::realcons); \nuserx[1]:=Get('TFx1'::realcons);\nuserx[2]:=Get('TFx2'::realcons);\n userx[3]:=Get('TFx3'::realcons);\nuserx[4]:=Get('TFx4'::realcons);\nus erx[5]:=Get('TFx5'::realcons);\nuserx[6]:=Get('TFx6'::realcons);\nfor \+ i from 1 to n do\nif userx[i]<>a+i*dx\n then Set('reply'=cat(\"Incorr ect x\",convert(i, string),\". Fix it and check again.\"));\n return ;\nend if;\nend do;\n\nuserfx[0]:=Get('TFfx0'::realcons);\nuserfx[1]:= Get('TFfx1'::realcons);\nuserfx[2]:=Get('TFfx2'::realcons);\nuserfx[3] :=Get('TFfx3'::realcons);\nuserfx[4]:=Get('TFfx4'::realcons);\nuserfx[ 5]:=Get('TFfx5'::realcons);\nuserfx[6]:=Get('TFfx6'::realcons);\nfor i from 1 to n do\nif userfx[i]<>eval(func,x=a+i*dx)\n then Set('reply' =cat(\"Incorrect f(x\",convert(i, string),\"). Fix it and check again .\"));\n return;\nend if;\nend do;\n\nSet('reply'=\"Correct Table! Gr eat job!!\")\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 411 "showTable:=proc()\nglobal n,a,dx,func;\nSet('TFx0'=a);\nSet('TFx1'=a+ dx);\nSet('TFx2'=a+2*dx);\nSet('TFx3'=a+3*dx);\nSet('TFx4'=a+4*dx);\nS et('TFx5'=a+5*dx);\nSet('TFx6'=a+6*dx);\nSet('TFfx0'=eval(func,x=a)); \nSet('TFfx1'=eval(func,x=a+dx));\nSet('TFfx2'=eval(func,x=a+2*dx));\n Set('TFfx3'=eval(func,x=a+3*dx));\nSet('TFfx4'=eval(func,x=a+4*dx));\n Set('TFfx5'=eval(func,x=a+5*dx));\nSet('TFfx6'=eval(func,x=a+6*dx));\n end proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 263 "checkApprox:=proc()\nglobal Tn;\nl ocal userapprox;\n\nuserapprox:=Get('Approx'::'realcons'):\nif userapp rox=Tn\n then Set('reply'=\"Correct trapezoidal approximation! Great \+ job!\");\n else Set('reply'=\"Incorrect trapezoidal approximation. Tr y again.\");\nend if;\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "showApprox:=proc()\nglobal Tn;\nSet('Approx'=Tn)\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3879 "TrapezoidRule:=Maplet(onstartup = RunWi ndow(MAIN), Font[helv10](\"helvetica\",10),\n Window[MAIN]('title'=\" Trapezoid Rule\",\n [ [ Button(\"New Integral\", Evaluate('function ' = \"New_Integral\")),\n \" \",\n Button(\"Qui t\", Shutdown())\n ],\n [ [ BoxColumn( border=true, halign=n one, caption=\"Approximate the integral \",\n MathMLViewer[MM LIntegral]('value' = MathML[Export](Int(\"f(x)\", x='a'..'b')),width=1 50, height=100),\n [ \"using the Trapezoid Rule with\", \"n = \", TextField['nvalue']('width'=3), \"intervals.\", HorizontalGlue() \n ]\n ),\n BoxColumn( border=true, caption =\"Fill in the coefficients and compute Delta x.\",\n [ \"Tn \+ = Delta x *\",\n TextField['c']('width'=3),\n \" [\",\n TextField[c0](width=3),\n \"f(x0) +\",\n \+ TextField[c1](width=3),\n \"f(x1) +\",\n \+ TextField[c2](width=3),\n \"f(x2) + ... +\",\n \+ TextField[cn1](width=3),\n \"f(x(n-1)) +\",\n \+ TextField[cn](width=3),\n \"f(x(n)) ]\"\n ],\n \+ [ \"Delta x =\",\n TextField[Deltax](width=3),\n \+ HorizontalGlue(), \" \",\n Horizontal Glue(),\n Button(\"Check\", Evaluate('function' = \"checkD eltax\")), \"\",\n Button(\"Show\", Evaluate('function' = \+ \"showDeltax\")), \" \"\n ]\n ),\n BoxColum n( border=true, halign=none,\n [ \"Fill in the table at the r ight. \",\n HorizontalGlue(), \" \",\n \+ HorizontalGlue(),\n Button(\"Check\", Evaluate('function ' = \"checkTable\")), \" \",\n Button(\"Show\", Evaluate(' function' = \"showTable\")), \"\"\n ],\n\n [ \"Appr oximate The Integral:\",\n TextField[Approx](width=10),\n \+ HorizontalGlue(),\n Button(\"Check\", Evaluate ('function' = \"checkApprox\")), \" \",\n Button(\"Show \", Evaluate('function' = \"showApprox\")), \" \"\n ]\n \+ ),\n [ TextField['reply']('width'=60, 'editable'='false' , background=white)\n ]\n ],\n [ border=true,\n [ Label(\"n\"),\n Label(\"x_n\"),\n La bel(\" f(x_n) \")\n ],\n [ Label[Ln0](\"0\", v isible = true),\n TextField[TFx0](\"\", width=3, visible = \+ true),\n TextField[TFfx0](\"\", width=6, visible = true)\n \+ ],\n [ Label[Ln1](\"1\", visible = true),\n \+ TextField[TFx1](\"\", width=3, visible = true),\n TextFi eld[TFfx1](\"\", width=6, visible = true)\n ],\n [ L abel[Ln2](\"2\", visible = true),\n TextField[TFx2](\"\", w idth=3, visible = true),\n TextField[TFfx2](\"\", width=6, \+ visible = true)\n ],\n [ Label[Ln3](\"3\", visible = true),\n TextField[TFx3](\"\", width=3, visible = true),\n TextField[TFfx3](\"\", width=6, visible = true)\n \+ ],\n [ Label[Ln4](\"4\", visible = true),\n TextF ield[TFx4](\"\", width=3, visible = true),\n TextField[TFfx 4](\"\", width=6, visible = true)\n ],\n [ Label[Ln5 ](\"5\", visible = true),\n TextField[TFx5](\"\", width=3, \+ visible = true),\n TextField[TFfx5](\"\", width=6, visible \+ = true)\n ],\n [ Label[Ln6](\"6\", visible = true), \n TextField[TFx6](\"\", width=3, visible = true),\n \+ TextField[TFfx6](\"\", width=6, visible = true)\n ],\n \+ [ \"If boxes disappear, resize the window.\"\n ]\n \+ ]\n ],\n BoxRow('background'=\"#DDFFFF\", 'inset'=0, 's pacing'=0,\n Label(\"Programmers: Eleanor Hobaugh / Brian Sche pp\", 'font'=helv10),\n HorizontalGlue(),\n Label(\"Copy right 2006, D.B. Meade and P.B. Yasskin\", 'font'=helv10),\n Ho rizontalGlue(),\n Label(\"v. 1.2a May 2006\", 'font'=helv10)\n \+ )\n ]\n )\n):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "M aplets[Display]( TrapezoidRule );" }}}{EXCHG }{EXCHG }}{MARK "0 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }