BUILT-IN MATHEMATICA SYMBOL

# DiscreteVariables

DiscreteVariables
is an option for NDSolve and other functions that specifies variables that only change at discrete times in a temporal integration.

## DetailsDetails

• DiscreteVariables->{v1, v2, ...} specifies that , , ... should be treated as variables that only change at discrete times.
• The value of a discrete variable v can be changed through WhenEvent[event, v->val] or WhenEvent[event, v->"DiscontinuitySignature"].
• The discrete variable solution v can be returned by using NDSolve[eqn, {v, ...}, ...].
• DiscreteVariables->{vspec1, vspec2, ...} can be used to specify the ranges for discrete variables.
• Possible forms for are:
•  v v has range Reals or Complexes Element[v,Reals] v has range Reals Element[v,Complexes] v has range Complexes Element[v,Integers] v has range Integers Element[v,{n1,...}] v has discrete range {v,vmin,vmax} v has range vspeci⧴actioni perform when is no longer satisfied
• Derivatives with respect to time of discrete variables are zero almost everywhere and should not appear in the equations.
• For partial differential equations, discrete variables can depend only on the temporal independent variable in a method of lines semi-discretization.

## ExamplesExamplesopen allclose all

### Basic Examples (2)Basic Examples (2)

Solve for with , a discrete variable that changes at regular intervals in time:

 Out[1]=
 Out[2]=

Solve for with , a discrete variable that changes whenever crosses 0:

 Out[1]=
 Out[2]=
 Out[3]=