MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: StoppingTest does not work ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9812] Re: [mg9769] StoppingTest does not work ?
  • From: David Withoff <withoff>
  • Date: Fri, 28 Nov 1997 05:35:26 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

>      Anyone could tell me why :
>
>      NDSolve[{y'[t]==1,y[0]==0},{y},{t,0,2},StoppingTest->(y[t]>1)]
>
>      does not stop for t=1 (it does not stop at all, in fact).
>      Of course, my problem is more complicated, but in all case
>      stoppingTest seems to stop when it wants...
>
>      Thanks for quick help, Please !!!
>
>      Gilles.

This particular example is a degenerate case, because the first step at
which the value of the StoppingTest option was True turned out to be
the endpoint of the integration.  If you tell NDSolve to use smaller
steps, then this effect can be made more conspicuous:

In[5]:= NDSolve[{y'[t]==1,y[0]==0},{y},{t,0,2},StoppingTest->(y[t]>1),
                                 MaxStepSize -> 0.1]

Out[5]= {{y -> InterpolatingFunction[{{0., 1.00179}}, <>]}}

A useful trick for analyzing NDSolve is to add to one of the equations a
function that evaluates to zero, and so does not affect the result, but
which has the useful side effect of recording the point at which the
derivative is being evaluated.  For example:

In[7]:= NDSolve[{y'[t]==1 +
f[t],y[0]==0},{y},{t,0,2},StoppingTest->(y[t]>1)] 0.
0.000894427
0.00178885
2.

Out[7]= {{y -> InterpolatingFunction[{{0., 2.}}, <>]}}

which provides another way of seeing what happened in your example.

Dave Withoff
Wolfram Research


  • Prev by Date: Control Systems with Mathematica
  • Next by Date: Re: Graphing Inequalities
  • Previous by thread: StoppingTest does not work ?
  • Next by thread: Re: StoppingTest does not work ?