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.

4.2. SECOND-ORDER MODELS 165<br />

> restart:<br />

> eq:=diff(y(x),x)=(h-y(x))/(0-x);<br />

eq := d<br />

¡ y(x)<br />

y(x) =¡h<br />

dx x<br />

We solve eq for Heather's vertical coordinate h.<br />

> h:=solve(eq,h);<br />

μ<br />

d<br />

h := ¡<br />

dx y(x)<br />

<br />

x + y(x)<br />

Heather's speed is r times that of Patches, so dh=dt = r (ds=dt), where t is time<br />

and ds = p 1+(dy=dx) 2 dx is an element of arclength along Patches' path.<br />

But then dh = rds,ordh=dx = r (ds=dx) =r p 1+(dy=dx) 2 . Entering this<br />

last relation yields the relevant second-order nonlinear ODE for y(x),<br />

> ode:=diff(h,x)=r*sqrt(1+diff(y(x),x)^2);<br />

μ <br />

s<br />

μ 2 d d<br />

ode := ¡ y(x) x = r 1+<br />

dx2 dx y(x)<br />

2<br />

the expression for h having been automatically substituted. Although ode is<br />

nonlinear, it can be analytically solved. Patches is initially at x =1;y=0and<br />

the tangent line there has zero slope. These starting conditions are used in the<br />

dsolve command.<br />

> sol:=dsolve(fode,y(1)=0,D(y)(1)=0g,y(x));<br />

x xxr<br />

sol := y(x) =¡<br />

¡<br />

2(¡1+r) xr 2(1+r) +<br />

r<br />

;<br />

¡1+r2 x xxr<br />

y(x) =<br />

+<br />

2(¡1+r) xr 2(1+r) ¡<br />

r<br />

¡1+r2 Two forms of the solution are generated, the ¯rst corresponding to Heather<br />

moving downward (in the negative y direction) along the x = 0 line, the second<br />

corresponding to moving upward. The upward (second one here) solution is<br />

selected and simpli¯ed with respect to powers of x.<br />

> y:=simplify(rhs(sol[2]),power);<br />

y := x(1¡r) x(1+r)<br />

+<br />

2(¡1+r) 2(1+r) ¡<br />

r<br />

¡1+r2 Evaluating y at x = 0 yield's Heather's vertical coordinate when Patches reaches<br />

her. Notice that as r approaches 1 from below, Y goes to in¯nity, i.e., Patches<br />

cannot catch Heather in a ¯nite distance. Obviously, Patches must run faster<br />

than Heather can walk to catch her.<br />

> Y:=eval(y,x=0);<br />

r<br />

Y := ¡<br />

The given ratio r = 3<br />

8<br />

> r:=3/8: y:=y; Y:=evalf(Y);<br />

¡1+r 2<br />

is entered, and y and Y are automatically evaluated.

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

Saved successfully!

Ooh no, something went wrong!