Preben Alsholm July 6 2020. The following example is taken directly from the help page for stop_cond in Maple 8.'stop_cond' has long ago been replaced with the more versatile 'events', but it still works in Maple 2020.I have inserted the events version and commented out the stop_cond version. Plots are added. restart; #The Dog Example (contributed by Paolo Panarese) #We have a jogger, with position (jogX(t),jogY(t)), and a dog, with position (dogX(t),dogY(t)). The dog runs with a constant speed 5 km/hr towards a #jogger, so the change of position of the dog is governed by: eq1 := diff(dogX(t),t)^2+diff(dogY(t),t)^2 = 5^2; eq2 := diff(dogX(t),t)=lambda(t)*(jogX(t)-dogX(t)); eq3 := diff(dogY(t),t)=lambda(t)*(jogY(t)-dogY(t)); #We can isolate lambda(t) as eq1 := subs({eq2,eq3},eq1); solve(eq1,lambda(t)); #Assuming a positive value of lambda (the dog is moving towards the jogger), we obtain: eq1 := lambda(t) = 5/ sqrt(jogX(t)^2-2*jogX(t)*dogX(t)+dogX(t)^2+ jogY(t)^2-2*jogY(t)*dogY(t)+dogY(t)^2); eq2 := subs(eq1,eq2); eq3 := subs(eq1,eq3); #Now if we assume the jogger runs along a circular track with a 1 km diameter at 4 km/hr, we obtain: jog := {jogX(t) = sin(8*t)/2, jogY(t) = cos(8*t)/2}; eq2 := subs(jog,eq2); eq3 := subs(jog,eq3); #Now we specify a stop condition that is satisfied when the dog is sufficiently close to the jogger as: scond := [subs(jog,(jogX(t)-dogX(t))^2+ (jogY(t)-dogY(t))^2-(1e-7))]; #We can now use the stop condition to determine when the dog will catch up to the jogger. So assuming the dog starts at the opposite end of the track #from the jogger, we have: ics := {dogX(0)=0, dogY(0)=-1}; #dsn := dsolve({eq2,eq3} union ics, numeric,stop_cond=scond); # commented out, but works event1:=[op(scond),halt]; dsn := dsolve({eq2,eq3} union ics, numeric,events=[event1]); dsn(10); # plots:-odeplot(dsn,[[dogX(t),dogY(t)],eval([jogX(t),jogY(t)],jog)],0..0.25,view=[0..0.5,-1..0.5],scaling=constrained,frames=50); #So we see that the dog catches up to the jogger shortly before 15 minutes. #If instead the dog started 1/4 lap behind the jogger we have: ics := {dogX(0)=-1, dogY(0)=0}; #dsn := dsolve({eq2,eq3} union ics, numeric,stop_cond=scond); dsn := dsolve({eq2,eq3} union ics, numeric,events=[event1]); dsn(10); #So in this case it takes a little longer. plots:-odeplot(dsn,[[dogX(t),dogY(t)],eval([jogX(t),jogY(t)],jog)],0..0.50,view=[-1..0.5,-0.5..0.5],scaling=constrained,frames=50);