is an option for NDSolve and other functions that specifies the list of all objects that should be considered as dependent variables in equations that have been supplied.


DependentVariables
is an option for NDSolve and other functions that specifies the list of all objects that should be considered as dependent variables in equations that have been supplied.
Details

- With DependentVariables->Automatic, the dependent variables are determined from the equations.
- DependentVariables->{u1,u2,…} specifies a complete list of dependent variables ui representing functions that should be solved for, even if the solutions are not eventually returned.
- DependentVariables->{uspec1,uspec2,…} can be used to specify ranges for dependent variables.
- Possible forms for uspeci are:
-
u u has range Reals or Complexes Element[u,Reals] u has range Reals Element[u,Complexes] u has range Complexes Element[u,{v1,…}] u has discrete range {v1,…} {u,umin,umax} u has range uspeciactioni perform actioni when uspeci is no longer satisfied
Examples
open all close allBasic Examples (2)
Scope (4)
Multiple range specifications can be enforced for a single dependent variable:


Perform a custom action when a dependent variable goes out of range:
The event action each time the variable leaves the specified range:
Print a message and stop the integration the first time a variable goes out of range:
Applications (2)
Set up a very large system of equations:
Solve for all of the dependent variables, but save only the solution for x1:
This saves a lot of memory versus saving all the solutions:
Model an unstable inverted pendulum with oscillating base:
Stop the simulation if θ[t] goes outside the range :

At a stable amplitude, the inverted pendulum with oscillating base will not fall out of range:
Properties & Relations (1)
Variable range checking can also be achieved with WhenEvent:
An equivalent range check with DependentVariables is more direct and comprehensible:

WhenEvent is useful for more complicated range checking:
Possible Issues (3)
A variable cannot be specified as both dependent and discrete:

A dependent variable cannot have a discrete range:

The variables in a range specification must be valid dependent variables:

Use conditions directly for the dependent variable:

Or use a WhenEvent expression in the equation:
Related Guides
History
Introduced in 2003 (5.0) | Updated in 2012 (9.0)
Text
Wolfram Research (2003), DependentVariables, Wolfram Language function, https://reference.wolfram.com/language/ref/DependentVariables.html (updated 2012).
CMS
Wolfram Language. 2003. "DependentVariables." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/DependentVariables.html.
APA
Wolfram Language. (2003). DependentVariables. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DependentVariables.html
BibTeX
@misc{reference.wolfram_2025_dependentvariables, author="Wolfram Research", title="{DependentVariables}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/DependentVariables.html}", note=[Accessed: 11-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_dependentvariables, organization={Wolfram Research}, title={DependentVariables}, year={2012}, url={https://reference.wolfram.com/language/ref/DependentVariables.html}, note=[Accessed: 11-August-2025]}