# Delay differential equations (DDEs)

## Introduction

Delay differential equations (DDEs) can be implemented in a block EQUATION: of the section [LONGITUDINAL]. For that, the function delay() is proposed. This function allows to delay a dynamical variable by a constant time (which can be estimated). One can also build a model with several delays. Noe that delays in the absorption after drug administration represent a different process and must be implemented using the keyword Tlag in the administration macros.

The solver used for delayed differential equations is described in Kuate et al. “A delay differential equation solver for MONOLIX & MLXPLORE”.

https://www.youtube.com/watch?v=oliKcm849WcSince the DDE solver is slower than the ODE solver, we recommend the alternative implementation using ODEs only and presented in the following video, when possible, as it leads to greatly shorter run times.

https://www.youtube.com/watch?v=r8aCDkcXRFo**Example**

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

This DDE is typically an accumulation process with a delayed linear elimination treatment.

```
DESCRIPTION: Model description with a delay
[LONGITUDINAL]
input = {x0, ka, k, tau}
EQUATION:
t0 = 0
x_0 = x0
ddt_x = ka*x-k*delay(x,tau)
```

The simulation of this model using (x0=10, k=0.5, k=0.25, tau=2) is shown on the following figure. The interesting part in this example is that the delay leads to oscillations.

**Rules **

The delay function can delay a “pure” component in a dynamical equation. There are three main things to point out and we will discuss the three of them:

By pure, we mean that the function can not take state calculations into account. In the previous example, if we had used delay(k*x,tau) instead of k*delay(x,tau), this would have generated an error.

By component, we mean that the delay function can only delay variable with a dynamic behavior (defined by a derivative equation). In the previous example, using the delay function with anything else than x would lead to an error.

By dynamical equation, we mean that the delay function should be called directly in a ddt_ equation. For example, if we have in addition a DDE of the form , one could be tempted to implement it in Mlxtran under the following incorrect form:

CODE`z = delay(x,1) ddt_y = z-y`

It should be defined directly as

CODE`ddt_y = delay(x,1)-y`

The first implementation would lead to an error.

The delay must remain constant over the time.

It is good practice to define the initial conditions of the DDE system (t0 and initial values for the variables). If the initial condition is not defined, then it is set to the default value 0. Notice that you can have varying initial conditions. Note also that an initialization can be performed if the values can be analytically computed. For example, we can define , and it would be translated in Mlxtran under the form

CODE`x_0 = V*(1+t)`