Wolfram ResearchProductsPurchasingServices & ResourcesAbout UsOur Sites
Mathematica Technical FAQs Services & Resources / Mathematica / Kernels & Programming
-----
 /
Symbols
*Mathematica
*Network Mathematica
*webMathematica
*gridMathematica
*Personal Grid Edition
*Wolfram Workbench
*Wolfram Education Group
*Application Packages
*Mathematica for Students
*Mathematica CalcCenter
*Publicon
*A New Kind of Science Explorer
*Mathematical Explorer
*Mathematica Teacher's Edition
*Calculus WIZ
*Mathematica Player
*Ask about this page
*Print this page
*Email this page
*Give us feedback
*
Sign up for our newsletter:

StoppingTest


Usage Message:

StoppingTest is an option for NDSolve that can be used to stop the integration of the ode when a certain condition is found to be True. The condition can evaluate to True/False only and should contain the dependent and independent variables explicitly. This option cannot be used for linear boundary value problems.

Attributes[StoppingTest] = {Protected}


Notes:

The StoppingTest option can be used when you want NDSolve to stop as soon as the solution reaches a certain value.

Here is a simple example in which NDSolve stops when the condition f[x] < 0 evaluates to True . Without the StoppingTest option, the calculation would have continued through the range {x, 0, 10}

In[1]:= NDSolve[{f''[x] + f[x] == 0, f[0] == 0, f'[0] == 1},  
                    f, {x, 0, 10}, StoppingTest -> (f[x] <  0)]

Out[1]= {{f ->  InterpolatingFunction[{{0., 3.15464}}, <>]}}
The value of the StoppingTest option is expected to evaluate to either True or False . Indeterminate values will cause the calculation to terminate just as if the value had been True , but you will also get a warning message advising you that the value of the StoppingTest option was neither True nor False .

Since NDSolve may step beyond the point where the value of StoppingTest evaluates to True , the solution may also extend beyond that point. You can use the MaxStepSize and MaxRelativeStepSize options to limit the size of steps using by NDSolve .

Known Bugs:

The StoppingTest option in Version 3.0 of Mathematica does not correctly use the independent variable. You can avoid this problem by introducing a trivial function for which the independent variable is the solution. For example:
In[1]:= NDSolve[{f'[t] == f[t], f[1] == 1,
            var'[t] == 1, var[1] == 1}, {f, var}, {t, 1, 100},
                    StoppingTest ->  (var[t ]> 5)]

Out[1]= {{f ->  InterpolatingFunction[{{1., 5.01945}}, < >], 
 
>     var ->  InterpolatingFunction[{{1., 5.01945}}, < >]}}







 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy