16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INTRODUCTORY RECIPE 5<br />

tf := 4 1<br />

3 cos(Á)<br />

A comment, pre¯xed by the pound sign #, has been added to the command<br />

line. Short comments are useful for later reference or for others to read and<br />

understand the purpose of a Maple command. 1<br />

A transcendental equation eq for Á results on evaluating y at t = tf and<br />

equating the result to yf:<br />

> eq:=eval(y,t=tf)=yf;<br />

20 sin(Á) 8:711111111<br />

eq := 2 + ¡<br />

cos(Á) cos(Á) 2 =3:5<br />

The transcendental equation is solved for Á, the result being labeled ©.<br />

> Phi:=solve(eq,phi); #angles in radians<br />

©:=0:9917653601; 0:6538908144; ¡2:149827293; ¡2:487701839<br />

Four angles, expressed in radians, are generated in the above output ©, the<br />

default accuracy being 10 digits. Since the initial angle must be above the horizontal,<br />

only the positive answers are acceptable as solutions for this problem.<br />

Since there are two positive results, this means that Daniel could throw the ball<br />

at two di®erent angles to just clear the fence. To proceed, we shall select one of<br />

the positive answers, say the second one in ©. This is done by entering Phi[2].<br />

You can look at the ¯rst positive angle by changing this entry to Phi[1]. Ifdesired,<br />

the angle Á ¼ 0:65 radians can be converted to degrees using the convert<br />

command with units as the second argument.<br />

> phi:=Phi[2]; theta:=convert(phi,units,radian,degree);<br />

Á := 0:6538908144 μ := 37:46518392<br />

In this case, Daniel throws the ball at an angle μ ¼ 37 1 degrees to the horizontal.<br />

2<br />

It should be mentioned that the convert command is very useful for converting<br />

an expression from one form to another, the form of conversion being dictated<br />

by the choice of second argument. To see the types of conversions possible with<br />

Maple, click on the convert command in the worksheet, then on Help in the<br />

tool bar, and ¯nally on Helponconvert.<br />

Using the °oating-point evaluation command, evalf, we numerically evaluate<br />

the time to reach the fence, which is found to be about 1.68 seconds.<br />

> tf:=evalf(tf); #time to reach fence<br />

tf := 1:679846933<br />

To plot the entire trajectory, the time T for the ball to hit the ground must<br />

be determined. This is accomplished by setting y = 0 and solving for t, which<br />

produces two answers.<br />

> T:=solve(y=0,t);<br />

T := ¡0:1981184874; 2:060197767<br />

1 Longer or more detailed comments may be inserted into a worksheet by clicking on<br />

Insert in the tool bar at the top of the computer screen, then on Execution Group, on<br />

either Before Cursor or After Cursor, onText, and ¯nally typing in the comments.

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

Saved successfully!

Ooh no, something went wrong!