{VERSION 2 3 "SGI IRIS UNIX" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }1 0 0 0 6 6 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 2" 3 4 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 4 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Bullet It em" 0 15 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 3 3 0 0 0 0 0 0 15 2 }{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }} {SECT 0 {PARA 18 "" 0 "" {TEXT -1 8 "Plotting" }}{PARA 0 "" 0 "" {TEXT -1 53 "This worksheet is designed to accompany Chapter 7 of " } {TEXT 256 87 "Introduction to Scientific Programming: Computational Pr oblem Solving Using Maple and C" }{TEXT -1 198 " by Joseph L. Zachary. In it, we will look at the plotting examples from Chapter 7 and show how to use optional parameters to embellish the plots. Be sure to e xperiment with the menus at the top " }}{PARA 0 "" 0 "" {TEXT -1 78 "o f the plot windows, as they can change the plot's appearance in variou s ways." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 15 "Getting Started" }}{PARA 0 "" 0 "" {TEXT -1 73 "We'll beg in by defining the horizontal, vertical, and duration functions." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 269 "( 7.9) We create a function \"horizontal\" that returns the horizonal p osition in meters of a projectile \"t\" seconds after it is fired with initial speed \"V\" m/sec and initial angle \"theta\" radians. This \+ function ignores what happens when the projectile hits the ground." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "hor izontal := (V, theta, t) -> V * t * cos(theta);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 268 "(7.10) We create a function \"vertical\" that returns the vertical position in meters \+ of a projectile \"t\" seconds after it is fired with initial speed \"V \" m/sec and initial angle \"theta\" radians. This function ignores w hat happens when the projectile hits the ground. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "vertical := (V, the ta, t) -> V * t * sin(theta) - 1/2 * g * t^2;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 194 "(7.11) We create a function \"duration\" that reports the time in seconds that elapses before a projectile fired with initial speed \"V\" m/sec and an initi al angle \"theta\" radians hits the ground." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "duration := (V, theta) -> 2 * V * sin(theta) / g;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 53 "The value of g, which is acceleration due to gravity." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "g := 9.8;" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 28 "Si mple Two-Dimensional Plots" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 189 "(7. 27) The first parameter to this form of \"plot\" must be a symbolic e xpression in the independent variable. This variable is identified, a nd its range specified, by the second parameter." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "plot(vertical(100, \+ Pi/4, t), t=0..20);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 220 "(7.28) The pl ot from (7.27) shows the height of the projectile as if it continues f alling even after it hits the ground. Here we specify bounds on \"tim e\" that correspond only to the duration of the projectile's flight." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "p lot(vertical(100, Pi/4, time)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 " \+ time=0..duration(100, Pi/4));" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 136 "( 7.29) We repeat (7.28), but use the \"labels\" and \"title\" options \+ to give better labels to the axes and to include a title in the plot. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "plot(vertical(100, Pi/4, time)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 33 " time=0..duration(100, Pi/4)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 " labels=[`sec`, `m`]," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 36 " \+ title=`45 degrees; 100 m/sec`);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{SECT 1 {PARA 4 "" 0 "" {TEXT -1 9 "Exercises" }}{EXCHG {PARA 15 "" 0 "" {TEXT -1 206 "Produce a two-dimensional plot that shows how the v ertical position at time 5 seconds of a projectile fired at 100 m/sec \+ depends on the initial angle, as that angle varies between 30 degrees \+ and 60 degrees." }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 15 " " 0 "" {TEXT -1 181 "Produce a two-dimensional plot that shows how the duration of a projectile fired at 45 degrees depends on the initial v elocity, as that velocity varies between 0 and 200 meters/sec." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }} }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 20 "Multiple-Curve Plots" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 254 "(7.30) We include three differen t curves in a single plot by specifying three different dependent expr essions as the first parameter to \"plot\". (The expressions are encl osed in braces.) Unfortunately, two of the height curves extend below the ground. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "plot(\{vertical(100, Pi/6, t)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 29 " vertical(100, Pi/4, t)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 " vertical(100, Pi/3, t)\}," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 " t=0..duration(100, Pi/3)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 " labels=[`sec`, `m`]," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 48 " title=`30, 45, and 60 degrees; 100 m/sec`);" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 135 "( 7.31) We repeat (7.30), but we modify the three dependent expressions by using \"max\" to ensure their values are never less than zero." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "plo t(\{max(0, vertical(100, Pi/6, t))," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 37 " max(0, vertical(100, Pi/4, t))," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 38 " max(0, vertical(100, Pi/3, t))\}," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 " t=0..duration(100, Pi/3)," }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 25 " labels=[`sec`, `m`]," }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 48 " title=`30, 45, and 60 degrees; 100 m/sec`);" } }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 133 "(7.32) On the same plot, we show the horizontal and vertical positio ns of a projectile fired at 100 m/sec at an angle of 45 degrees." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "plo t(\{horizontal(100, Pi/4, t)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 " \+ vertical(100, Pi/4, t)\}," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 " t=0..duration(100, Pi/4)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 29 " labels=[`sec`, `m`]," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 40 " title=`45 degrees; 100 m/sec`);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 9 "Exercises" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 15 "" 0 "" {TEXT -1 223 " Produce a multiple-curve plot showing how both the horizontal and vert ical positions at time five seconds of a projectile fired at 100 meter s/sec depends on the initial angle, as that angle varies between 30 an d 60 degrees." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 15 " " 0 "" {TEXT -1 203 "Produce a multiple-curve plot showing how the fli ght durations of two projectiles, one fired at 30 degrees and the othe r at 60 degrees, vary as their initial velocity varies between 0 and 1 00 meters/sec." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 16 "Parametric Plots" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 347 "(7.33) We create a par ametric plot using the dependent expressions from (7.32). We do this \+ by enclosing thetwo dependent expressions and the time range in square brackets. The horizontal position is plotted against the horizonal a xis, and the vertical position is plotted against the vertical axis. \+ Time does not appear explicitly in the plot." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "plot([horizontal(100, Pi/ 4, t)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 29 " vertical(100, Pi/4, t)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 32 " t=0..duration(100, Pi /4)]," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 " labels=[`m`, `m`]," } }{PARA 0 "> " 0 "" {MPLTEXT 1 0 36 " title=`45 degrees; 100 m/sec` );" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 227 "(7.34) On the same plot, we put three different parametric pl ots. We do this by enclosing three parametric specifications (as in ( 7.33)) in braces. We also constrain the plot so that the scales on th e two axes are identical." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 32 "plot(\{[horizontal(100, Pi/6, t)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 " vertical(100, Pi/6, t)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 33 " t=0..duration(100, Pi/6)]," }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 " [horizontal(100, Pi/4, t)," } }{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 " vertical(100, Pi/4, t)," }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 " t=0..duration(100, Pi/4)]," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 32 " [horizontal(100, Pi/3, t), " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 " vertical(100, Pi/3, t), " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 " t=0..duration(100, Pi/3) ]\}," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 " labels=[`m`, `m`]," }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 " title=`30, 45, and 60 degrees; 100 m/sec`," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 " scaling=constr ained);" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 9 "Exercises" }}{EXCHG {PARA 15 "" 0 "" {TEXT -1 262 "Produce a parametric plot with horizont al position on the horizontal axis and vertical position on the vertic al axis. It should show the position at time five seconds of a projec tile fired at 100 meters/sec as the initial angle varies between 30 an d 60 degrees." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 15 " " 0 "" {TEXT -1 279 "Produce a parametric plot with horizontal positio n on the horizontal axis and vertical position on the vertical axis. \+ It should show the position at time five seconds of a projectile fired at an angle of 45 degrees as the initial velocity varies between 100 \+ and 1000 meters/sec." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 15 "" 0 "" {TEXT -1 234 "Produce a plot with three parametric cu rves. Each curve should be like the one from (6) above, but one shoul d be for an initial angle of 30 degrees, one for an intitial angle of \+ 45 degrees, and one for an initial angle of 60 degrees." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 9 "Animation" }}{EXCHG {PARA 0 "" 0 " " {TEXT -1 75 "(7.35) Among other things, this gives us access to the \"animate\" function." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 12 "with(plots);" }}}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 387 "(7.36) We create an animatio n showing how the height of a projectile depends on both time and the \+ initial angle of its trajectory. In each frame of the animation, a pl ot of the height of the projectile against time for a particular initi al angle is shown. During the animation, the initial angle varies fro m 0 to 90 degrees. This animation produces a series of two-dimensiona l plots." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "animate(max(0, vertical(100, angle, t))," }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 33 " t=0..duration(100, Pi/2)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 " angle=0..Pi/2," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 28 " labels=[`sec`, `m`]," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 43 " title=`0...90 degrees; 100 m/sec`);" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 354 "( 7.37) We create an animation showing how the trajectory of a projecti le depends on both time and the the initial angle of its trajectory. \+ In each frame of the animation, a parametric plot of the projectile's \+ position is shown. During the animation, the initial angle varies fro m 0 to 90 degrees. This animation produces a series of parametric plo ts." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "animate([horizontal(100, angle, t)," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 41 " max(0, vertical(100, angle, t))," }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 35 " t=0..duration(100, Pi/2)]," }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 22 " angle=0..Pi/2," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 " labels=[`m`, `m`]," }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 42 " title=`0..90 degrees; 100 m/sec`);" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 9 "Exercises" }}{EXCHG {PARA 15 "" 0 "" {TEXT -1 318 "Produce an animation showing how the duration of a proje ctile's flight depends on both the initial velocity and angle. In eac h frame of the animation, a plot of the duration of the projectile's f light vs. initial velocity should be shown. During the animation, the initial angle should vary between 0 and 90 degrees." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}}{MARK "7" 0 }{VIEWOPTS 1 1 0 1 1 1803 }