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.

2.3. NUMERICAL SOLUTION OF ODES 95<br />

closed loop. The incorrect behavior is due to cumulative error arising from use<br />

of the Euler approximation (which has low accuracy) and the ¯nite step size.<br />

Keeping in mind the danger of round-o® error for a ¯xed number of digits, the<br />

growth of the spiral can in principle be reduced by reducing h. But in practice,<br />

the CPU time goes up so rapidly that the Euler method is not used for serious<br />

numerical calculations. In the next recipe, the classical fourth-order Runge{<br />

Kutta method is introduced, a much more accurate numerical scheme than the<br />

Euler method for a given step size.<br />

Finally, the CPU time for the forward Euler dial-up method is determined,<br />

> CPUtime2:=(time()-begin2)*seconds;<br />

CPUtime2 := 0:330 seconds<br />

and is actually slightly longer than for the ¯rst-principles calculation.<br />

PROBLEMS:<br />

Problem 2-21: Van der Pol equation<br />

By setting _x = y, the second-order Van der Pol (VdP) equation<br />

Äx ¡ ² (1 ¡ x 2 )_x + x =0<br />

may be written as a coupled system of two ¯rst-order ODEs. Choosing ² =5<br />

and x(0) = _x(0) = 0:1, solve the VdP system for h =0:01 and t =0to15using<br />

the ¯rst principles Euler method. Rotate your plot to produce a phase-plane<br />

portrait solution and compare the result with what would be obtained using<br />

the dial-up Euler option of the dsolve command.<br />

Problem 2-22: White dwarf equation<br />

In his theory of white dwarf stars, Chandrasekhar [Cha39] introduced the nonlinear<br />

equation<br />

x (d 2 y=dx 2 )+2(dy=dx)+x (y 2 ¡ C) 3=2 =0;<br />

with the boundary conditions y(0) = 1 and y 0 (0) = 0. Write the second-order<br />

equation as two ¯rst-order equations and solve the system using the ¯rst principle's<br />

Euler method. Take h =0:01 and 10-digit accuracy, and numerically<br />

compute y(x) over the range 0 · x · 4withC =0:1 and plot the result. (Hint:<br />

Start at x =0:01 to avoid any problem at the origin.)<br />

Problem 2-23: Baleen whales<br />

May [May80] has discussed the solution of the following normalized equation<br />

describing the population of sexually mature adult baleen whales:<br />

_x(t) =¡ax(t)+bx(t ¡ T )(1 ¡ (x(t ¡ T )) N ):<br />

Here x(t) is the normalized population number at time t, a and b are the<br />

mortality and reproduction coe±cients, T is the time lag necessary to achieve<br />

sexual maturity, and N is a positive parameter. If the term 1 ¡ (x(t ¡ T )) N is<br />

negative, then this term is to be set equal to zero. Taking a =1,b =2,T =2,<br />

step size h =0:01, and 4000 time steps, use the ¯rst principles Euler method to<br />

solve numerically for x(t ¡ T )versusx(t) andforx(t) for(a)N =3:0, and (b)<br />

N =3:5. Plot your results. For (a) you should observe a period-one solution,

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

Saved successfully!

Ooh no, something went wrong!