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.

3.2. SECOND-ORDER MODELS 119<br />

> tf:=solve(x=xf,t);<br />

μ <br />

xb k + V cos(Á) ¡ xf k<br />

ln<br />

V cos(Á)<br />

tf := ¡<br />

k<br />

In the y direction, the gravitational force on the ball must be included as well<br />

as air resistance. Newton's second law yields the ODE given in yeq.<br />

> yeq:=diff(y(t),t,t)=-k*diff(y(t),t)-g;<br />

yeq := d2<br />

μ<br />

d<br />

y(t) =¡k<br />

dt2 dt y(t)<br />

<br />

¡ g<br />

Solving yeq with the dsolve command, subject to the initial condition y(0) =<br />

yb, _y(0) = V sin(Á), where yb is the ball's initial y-coordinate, and taking the<br />

rhs, yields y.<br />

> y:=rhs(dsolve(fyeq,y(0)=yb,D(y)(0)=V*sin(phi)g,y(t)));<br />

y := ¡ e(¡kt) (V sin(Á) k + g)<br />

¡ gt<br />

k 2<br />

k + yb k2 + V sin(Á) k + g<br />

k2 Evaluating y at t=tf , and equating to the fence height yf , yields the following<br />

formidable looking transcendental equation eq for the unknown angle Á.<br />

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

(xb k + V cos(Á) ¡ xf k)(V sin(Á) k + g)<br />

eq := ¡<br />

k2 V cos(Á)<br />

μ <br />

xb k + V cos(Á) ¡ xf k<br />

g ln<br />

V cos(Á)<br />

+<br />

+ yb k2 + V sin(Á) k + g<br />

k 2<br />

k 2<br />

= yf<br />

To solve the transcendental equation for Á, thegivenvaluesxb =0m,yb =2m,<br />

xf =20m,yf =3:5m, V =15m/s,andg =9:8m/s 2 , are entered. The drag<br />

coe±cient is taken to be k =0:01 s ¡1 .<br />

> xb:=0: yb:=2: xf:=20: yf:=3.5: V:=15: g:=9.8: k:=0.01:<br />

The transcendental equation must be solved numerically. This is done in the<br />

following two command lines, two di®erent search ranges (in radians) being<br />

speci¯ed for Á to determine the two possible angles, ©1 and ©2, atwhichthe<br />

ball can be thrown to just clear the fence. Making use of the ditto operator, we<br />

convert the ¯rst angle to degrees.<br />

> Phi[1]:=fsolve(eq,phi,0..0.8); evalf(convert(%,degrees));<br />

©1 := 0:6696475750 38:36797980 degrees<br />

> Phi[2]:=fsolve(eq,phi,0.8..Pi/2);<br />

©2 := 0:9693759172<br />

Without air resistance, it was previously found that the smaller of the two<br />

possible angles was 37.47 degrees, about 1 degree less than the value found<br />

above. It is left as an exercise for you to compare the values for the upper<br />

angle, with and without air resistance.<br />

To animate the ball, the ¯rst angle ©1 will be selected.

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

Saved successfully!

Ooh no, something went wrong!