# Question:Trapping the stop button

## Question:Trapping the stop button

Maple 18

This Question involves using dsolve(..., numeric) for an IVP specifed by a procedure. This is based on a Question asked earlier today. In this Question, I have no interest in how to solve this IVP or in why this solution technique fails. In the worksheet below, the odeplot command seems to get stuck in an infinite loop (I am not interested in why that happens), and I press the stop button (in the Standard GUI). Then, instead of the usual Warning, computation interupted message followed by a return to the command prompt, I get an informative message and the plot that has been computed so far. This seems like a very useful feature: to return the results computed so far after an interuption. Furthermore, those results are programmatically accessible. My Question is How is this done? How do you trap the stop button and return the results?

 restart: Sys:= proc(N,t,Y,YP) local eqs,yp2,yp4;      YP[1]:= Y[2];      YP[3]:= Y[4];      eqs:= [           yp2*Y[3]+yp4*Y[2]*sin(Y[1]^2)+cos(yp4*Y[3]) = sin(t),           Y[2]*yp4*sin(Y[1]*Y[3])+5*yp2*Y[4]*cos(Y[1]^2)+t^2*Y[1]*Y[3]^2 = exp(-Y[3]^2)      ];      YP[2],YP[4]:= op(subs(fsolve(eqs,{yp2=1,yp4=2}),[yp2,yp4])) end proc: res:= dsolve(      numeric, procedure= Sys, initial= Array([1,1,2,2]),      number= 4, procvars= [x1(t),diff(x1(t),t),x2(t),diff(x2(t),t)],      start= 0, maxfun= 0 ):   plots:-odeplot(res, [t,x1(t)], 0..0.27); #After 10 seconds or so, (I did)/(you should) hit the stop button. Warning, cannot evaluate the solution further right of .25109286, cannot downgrade delay storage for problems with delay derivative order > 1, try increasing delaypts #Note that the command's result is still programmatically accessible: P:= %;