# Calculus Exploration 11: Arc Length # # The following is the Maple code for the Arc Length Maplet and the Approximate Integration Maplet. Note that arc length (curve length) problems often give rise to integrals with difficult (or nonexistent) primitive antiderivatives expressible in terms of elementary functions. This means that we will be developing new techniques of integration in order to find some of the new antiderivatives that arise from various arc length problems. # # In this exploration, you should use the Arc Length Maplet below to explore the arc length of various curves that you are familiar with. In doing this, you will see new antiderivatives displayed that you are not familiar with. So, currently, you won't be able to find these yourself. However, in these cases you can use the Approximate Integration Maplet to estimate the arc length integral and compare it to that given by the Arc Length Maplet. The point of this exploration is to motivate the new techniques for finding antiderivatives that we will be developing in the weeks ahead. # # Arc Length # Click in red area and press [Enter]. # Arc Length Maplet # Copyright 2002 Waterloo Maple Inc. # # The Arc Length maplet computes and graphically displays the arc length # of a function f(x) over an interval [a, b]. # The arc length of the curve y = f(x) from x = a to x = b is given by # Int(sqrt(1+Diff(f(x),x)^2),x = a .. b);. # # # The user enters the function f(x) and the range [a, b]. The maplet # displays the arc length of f(x) over [a, b], and plots the graphs of # f(x), g(x) = sqrt(1+diff(f(x),x)^2), and # Int(g(t),t = a .. b); # # To run this maplet, click the Execute (!!!) button in the context bar. # restart; ArcLengthMaplet := module() ############################################################ export iniMathML, addMathML, checkBoxes, getArcLength, runArcLengthMaplet: local helpStr, defStr: ############################################################ ############################################################ helpStr := "The Arc Length maplet computes and graphically displays the arc length of a function f(x) over an interval [a, b]. Enter the function f(x) and the range [a,b]. Click the 'Plot' button. The arc length of f(x) over [a, b] is displayed, and the graphs of f(x), g(x) = sqrt(1+diff(f(x),x)^2) and Int( g(t), t = a..b) are plotted.": ############################################################ ############################################################ defStr := " Arc Length The arc length s of the curve y = f(x) from x=a to x=b is given by ab1+xfx2x ": ############################################################ ############################################################ # pre: iniEqn :: algebraic expression # post: returns the Presentation MathML of iniEqn iniMathML := proc(iniEqn) local mathhead, mathtail, iniStr: mathhead := "": mathtail := "": iniStr := substring(MathML:-ExportPresentation(iniEqn),50..-8): cat(mathhead,iniStr,mathtail): end proc : # end iniMathML ############################################################ ############################################################ # pre: mathMLStr :: string, in form of Presentation MathML # addEqn :: algebraic expression addMathML := proc(mathMLStr,addEqn) local startStr, inter_tag, addStr, mltail: startStr := substring(mathMLStr,1..-15): inter_tag := " =": addStr := substring(MathML:-ExportPresentation(addEqn),50..-8): mltail := "": cat(startStr,inter_tag,addStr,mltail): end proc : # end addMathML ############################################################ getArcLength := proc(boo1, boo2, boo3) local temp, temp2, str, view, value: use Maplets:-Tools, Student:-Calculus1, StringTools in str:=Trim(Get('TF_fun')): if str="" then Set('ML'=""): return plots[textplot]([1,1,"Input a valid function"]): end if: temp:=Trim(Get('TF_a')): temp2:=Trim(Get('TF_b')): if temp="" or temp2="" then Set('ML'=""): return plots[textplot]([1,1,"Input end points/domain"]): end if: str:=cat(str, ", ", temp, "..", temp2): temp := iniMathML( ArcLength(parse(str), output=integral) ): value := ArcLength(parse(str)): temp := addMathML( addMathML(temp,value), Re(evalf(value)) ): Set('ML' = temp): if not boo1 then str := cat(str, ", showfunction=false") end if: if not boo2 then str := cat(str, ", showintegral=false") end if: if not boo3 then str := cat(str, ", showintegrand=false") end if: if not(boo1 or boo2 or boo3) then return plots[textplot]([1,1,"Select function, integral, or integrand"]): end if: view := ["DEFAULT","DEFAULT"]: temp:=Trim(Get('x1')): temp2:=Trim(Get('x2')): if temp<>"" and temp2<>"" then view[1]:=cat(temp, "..", temp2): end if: temp:=Trim(Get('y1')): temp2:=Trim(Get('y2')): if temp<>"" and temp2<>"" then view[2]:=cat(temp, "..", temp2): end if: temp:=cat(", view=[", view[1], ", ", view[2], "]"): str := cat(str, temp): ArcLength(parse(str), output=plot, functionoptions=[thickness=3]): end use: end proc: ############################################################ ############################################################ runArcLengthMaplet := proc() local maplet, b, s, c, dc, lc: b := 'border'=true: s := 'inset'=0, 'spacing'=0: c := 'background'="#DDFFFF": dc := 'background'="#CCFFFF": lc := 'background'="#EEFFFF": 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'=Evaluate('P'='getArcLength(CB1,CB2,CB3)')), MenuSeparator(), MenuItem("Close", 'onclick'=Shutdown()) ), # end Menu/File Menu("Help", MenuItem("Arc Length Definition", 'onclick'=RunWindow('defWin')), MenuSeparator(), MenuItem("Using this Maplet", 'onclick'=RunWindow('helpWin')) ) # end menu/Help ), # end MenuBar ############################################################ Window['mainWin']('resizable'='false', 'title'="Calculus 1 - Arc Length", 'menubar'='MB', BoxRow(s, c, BoxColumn(s, c, b, 'caption'="Plot Window", Plotter['P'](lc) ), # end BoxColumn BoxColumn(s, c, BoxRow(s,c,b,'caption'="Enter a function and the end points of the curve", Label("Function ", 'font'='F2', c), TextField['TF_fun']('width'=10, lc, 'value'=1-x^2, 'tooltip'="enter a function"), Label(" a ", 'font'='F2', c), Label(" = ", 'font'='F1', c), TextField['TF_a']('value'=-1, 'width'=2, lc), Label(" b ", 'font'='F2', c), Label(" = ", 'font'='F1', c), TextField['TF_b']('value'=1, 'width'=2, lc) ), # end BoxRow BoxRow(s, c, b, 'caption'="Arc Length", MathMLViewer['ML']('height'=240, 'width'=320, lc) ), # end BoxRow for MathMLViewer BoxRow(s, c, BoxColumn(s, c, b, 'caption'="Display Options", BoxRow(s, c, b, 'border'='false', CheckBox['CB1'](true, c, 'caption'="Show function"), # end CheckBox CheckBox['CB2'](true, c, 'caption'="Show integral"), # end CheckBox CheckBox['CB3'](true, c, 'caption'="Show integrand") # end CheckBox ), # end BoxRow BoxRow(s, c, Label("x", 'font'='F2', c), Label(" = ", 'font'='F1', c), TextField['x1'](2, lc), Label(" .. ", 'font'='F2', c), TextField['x2'](2, lc), Label(" y", 'font'='F2', c), Label(" = ", 'font'='F1', c), TextField['y1'](2, lc), Label(" .. ", 'font'='F2', c), TextField['y2'](2, lc) ) # end BoxRow ), # end BoxColumn of Options BoxColumn('inset'=0, 'spacing'=4, c, 'halign'=right, 'valign'=center, Button['B_plot'](" Plot ", dc, 'onclick' = Evaluate( 'P' = 'getArcLength(CB1,CB2,CB3)' ) ), # end Button Button("Close", dc, Shutdown()) ) # end BoxColumn for Buttons ) ) # end BoxRow for Buttons and Options ) ), # end Window ############################################################ Window['defWin']( 'resizable'='false', 'title'="Arc Length Definition", BoxColumn(b, 'inset'=0, 'spacing'=4, c, BoxRow(s, c, MathMLViewer['ML_def']('height'=200, 'width'=320, 'value'=defStr, lc) ), # end BoxRow BoxRow(s, c, Button("Close", dc, CloseWindow('defWin')) ) # end BoxRow ) # end BoxColumn ), # end defWin ############################################################ Window['helpWin']( 'resizable'='false', 'title'="Using the Arc Length Maplet", BoxColumn(b, c, 'inset'=0, 'spacing'=4, BoxRow(s, c, TextBox('height'=7, 'width'=36, c, 'font'='F2', 'editable'='false', 'value'=helpStr, 'foreground'="#333399" ) # end TextBox ), # end BoxRow BoxRow(s, c, Button("Close", dc, CloseWindow('helpWin') ) ) # end BoxRow ) # end BoxColumn ), # end helpWin ############################################################ Action['A']() ############################################################ ): # end Maplet ############################################################ Maplets:-Display(maplet): end use: # end use end proc: # end proc ############################################################ end module: # end module ArcLengthMaplet:-runArcLengthMaplet(); # Approximate Integration