animation problem (15.5.00)

Aldrovando Azeredo Araujo

I’ve listed the code of a simple program I’ve been dealing with. I am trying to show my students simple models like the one below that treats chasing situations. Here we have a dog that chases a jogger. The first problem deal with the right time I should stop computations since when the dog catches up the jogger we have a singularity in the differential equation.

So I would like to know the time the dog reach the jogger to plot the two trajectories using insequence=true. I want to put all this comands in a procedure. How do I do that?

As anyone can see I had to make a sequence of plots that take a lot of time to be generated. Is it possible to get this animation faster? I can do that in matlab quite fast.

Willard, Daniel Dr (17.5.00)

There is a book on differential gaming that you might wish to read: ”Advances in Missile Guidance” purchased from AIAA Publications, 9 Jay Gould Court, Waldorf, MD 20602. It treats such problems and also ones where the dog tries to escape, and gives some Maple programs to go along with it.

John Reinmann (19.5.00)

In answer to your question ”how can I find the time (T_catchup) when the dog catches up with the jogger?”, I propose the following approach:

When you obtain the numerical solutions for xt and yt, you find that when the time exceeds the T_catchup, Maple gives the error messages "sqrt of a negative number" or ”division by zero”.

Thus, you can use this error message to signal when you have overestimated the value of T_catchup. You use Maple’s ”traperror” command.

Taking both error messages into account and improving the way I change ”del” in the ”for” loop, I now recommend the following Maple code to determine q = T_catchup (where, q denotes the time):

The result depends on the number of Digits used. The following results are for Digits=12.

for n=4, q=1989331/1000000 
for n=5, q=19833319891/10000000000

In either case, if you increase the last digit in the numerator by 1, you get the error message above; so these results are very good.

The test I used to see if the value of T_catchup was good, was to evaluate the expression for the distance between the jogger and the dog, which is

When I plotted distance versus time, I got the interesting result that at first the distance closed and then opened up for a while and finally the distance closed again and the dog caught up with the jogger.

For an animation that can be generated quickly, I suggest using ”pointplot”, which can show the position of the dog and the jogger simultaneously as symbols (say a blue circle for the jogger and a red diamond for the dog).

Actually, this is a lot of fun to observe. Here’s the code:

let q be the time at which the dog catches up with the jogger, and xt(t), yt(t), X(t), Y(t) be the same as in your code.

I used q*j/40.0001 rather than q*j/40 to avoid the possibility of roundoff errors causing q*40/40 to slightly exceed q, in which case you would get an error message.