16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

INTRODUCTORY RECIPE 7<br />

plotting options available can be found by clicking on the underlined hyperlink<br />

plot/details that appears on the help page, and then on plot[options]. Try<br />

including some other options in the plot command. For example, change the<br />

color of the ball's trajectory from the default red to, say, blue.<br />

The ¯nal part of the problem is to animate the trajectory of the ball with<br />

the vertical fence included. The fence is now plotted, but not displayed, being<br />

assigned the name fence. The coordinates of the bottom and the top of the<br />

fence are entered as Maple lists and then formed into another list, i.e., one has<br />

a \list of lists." The fence will be plotted as a vertical (default red) line.<br />

> fence:=plot([[xf,0],[xf,yf]]):<br />

To produce specialized plots, such as an animated one, we must access the plots<br />

library package. This is done by entering the command with(plots). The<br />

preface with always indicates a Maple library package is being \loaded" into<br />

the worksheet. Library packages are extremely important, since they contain<br />

approximately 90% of Maple's mathematical knowledge. Normally, we would<br />

end the command with a colon, but here a semicolon is used to see what plot<br />

commands are contained in the plots library. 5<br />

> with(plots);<br />

Warning, the name changecoords has been redefined<br />

[Interactive; animate; animate3d; animatecurve; arrow; changecoords;:::]<br />

The animate command, appearing in the above list, will be used to animate the<br />

motion of the ball. The syntax is animate(plot command,[plot arguments],<br />

time range,options). Thepointplot command will plot the ball as a point.<br />

The plot arguments symbol=circle and symbolsize=14 instruct Maple to plot<br />

the point as a size-14 circle. 6 Included in the plot arguments list are the ball's<br />

x- andy-coordinates given as a list of lists. The time range is t =0toT2 .In<br />

the options, the number7 of frames is taken to be 200, the frames being equally<br />

spaced in time. The option background=fence causes the fence to appear as<br />

background in each time frame. Finally, the scaling is constrained.<br />

> animate(pointplot,[[[x,y]],symbol=circle,symbolsize=14],<br />

t=0..T2,frames=200,background=fence,scaling=constrained);<br />

When the animate command line is executed on the computer, the initial frame<br />

of the animation will appear on the screen. Clicking on the picture with the left<br />

mouse button places the picture in a viewing box and opens up an animation bar<br />

at the top of the screen. The animation is started by clicking on the arrowhead<br />

( ¤ ) and stopped by clicking on the square ( 2 ).<br />

5 Only a partial list of plot commands is shown here in the text, as indicated by the dots.<br />

Note that a warning message is also produced that informs us that the name changecoords<br />

has been rede¯ned in the current release of Maple. If desired, warnings can be removed by<br />

inserting the command interface(warnlevel=0) prior to loading the library package. From<br />

now on, all such warnings will generally be arti¯cially removed in the text.<br />

6 The default symbol is a diamond and the default size is 10.<br />

7 The default number is 25 frames. 200 frames produces a smoother animation.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!