**Introduction**

Ordinary differential equations (ODEs) can be implemented in the EQUATION: block of the [LONGITUDINAL] section. The ODEs describe a dynamical system and are defined by a set of equations for the derivative of each variable, the initial conditions, the starting time and the parameters.

*Derivatives*

The keyword ddt_ in front of a variable name, as ddt_x and ddt_y, defines the derivative of the ODE system. The variable names denote the components of the solution. These variables are defined at the whole [LONGITUDINAL] section level through their derivatives. The derivatives themselves aren’t variables but keywords, and cannot be referenced by other equations nor be defined under a conditional statement.

*Initial conditions*

The keyword t0 defines the initial time of the differential equation, while the variable names with suffix _0 define the initial conditions of the system. More precisely, in a differential equation for the variable **x**, **x** is defined at by the initial condition , i.e. and by the differential equation after .

*Linking administration with ODEs
*Mlxtran provides the PK macro depot() that can be used to link the administration from a data set with the model. Details and examples how to use depot() for the administration are given here.

**Example**

We consider in this example a first order differential equation on defined by:

where (V,k)=(10,.05), this ODE is typically a linear elimination process of a volume. This model is implemented in the file `mlxt_ode.txt`

:

DESCRIPTION: Model description with a simple ODE representing a linear elimination precess of a volume [LONGITUDINAL] input = {V, k} EQUATION: t0 = 10 x_0 = V ddt_x = -k*x

Here, the Mlxtran model define above is used with `Mlxplore`

with the parameters (V,k)=(10,.05). The simulation result is shown in the figure below. One can see the evolution of **x** w.r.t. time, one can clearly see the impact of the initialization and its timing.

**Rules and Best Practices **

- We encourage the users to define the initial conditions explicitly, although the default initial value is x_0=0.
- When no starting time t0 is defined in the Mlxtran model for Monolix then by default t0 is selected to be equal to the first dose or the first observation, whatever comes first.
- If t0 is defined and no differential equation is used, an error will raise.
- Initial conditions can depend on time
- Initial conditions can depend on an input parameter. Therefore, initial condition values can also be estimated in Monolix.
- Only first order differential equation can be used with Mlxtran. If you want to use a differential equation of the form , you need to transform the higher order differential equation into a first order differential equations by defining
*n*successive differential equations as proposed in the following “Best Practices Ex. 1: Second order differential equation”. - The derivatives of a ODE system cannot be conditional, i.e. ddt_ cannot be used within an if statement. Instead, conditional intermediate variables for the values of the derivatives should be used as shown in “Best Practices Ex. 2: IF statement”. A conditional statement can be built by combining the keywords if, elseif, else and end. Several elseif keywords can be chained, and the conditions are exclusive in sequence. A default value can be provided using the keyword else, but also as a simple definition preceding the conditional structure. An unspecified conditional value is null. The enclosed variables are not local variables, which means that a variable with remaining conditional definitions is still incomplete and cannot be referenced into another definition, even under the same condition.

**Best Practices Ex. 1: Second order differential equation**

If you want to use a second order differential equation of the type , with , the structural model in `Mlxtran`

writes

[LONGITUDINAL] input = {a, b} EQUATION: t0 = 0 x_0 = a dx_0 = b ddt_x = dx ddt_dx = -x-dx

**Best Practices Ex. 2: IF statement**

If a parameter value depends on a condition, it can be written with in `Mlxtran`

with the usual if-else-end syntax. For example, if a parameter c should be 1 if and 2 otherwise, write

if t<=10 c = 1 else c = 2 end

Derivatives cannot be written within an if-else-end structure. Instead, intermediate variables should be used. For example, if a derivative should be 1 if and 2 otherwise, write

if t<=10 dx = 1 else dx = 2 end ddt_x = dx