# User:Johnsy/Advanced Modelling in Biology/Discrete Systems

## Discrete Systems

Discrete systems are systems with non-continuous outputs with the result for each time step being determined by the previous time step. The equivalent to differential equations (continuous systems) in discrete system are known as difference equations such as the one shown below. Since the difference equation tells us about the next time step, it is known as a 1st order difference equation.

$x_{t+1} = rx_t \,$

This is the discrete equivalent of the differential equation:

$\frac{dx}{dt} = rx$

Discrete systems are found in nature, for example in biology where reproduction occurs at discrete time steps. Also, sampling at discrete time intervals of a continuous system gives us discreteness.

### How do we solve these difference equations?

1) By guessing (ansatz - German for "guess")

Let us assume that the solution is in the form

$x_t = A \beta ^t \,$

Then substituting into the difference equation, we get

$A \beta ^{t+1} = rA \beta ^t \,$
$r = \beta \,$

And hence the solution to the difference equation is

$x_t = x_0 r^t \,$

2) Z-transform - the discrete equivalent to the Laplace transform, an organized way to find solutions

### What are the behaviors of the solution $x_t = x_0 r^t \,$?

There are 4 different regimes, depending on the value of r.

If r > 1, then xt approaches infinity.
If 0 < r < 1, then xt approaches zero.
If -1 < r < 0, then xt approaches zero in an oscillatory manner.
If r < -1, then xt approaches infinity in an oscillatory manner.

Remember that if we have non-linear systems, it is difficult to obtain the global stability analysis of the problem, however, we can see from the above different behaviors that we can generalize it into stable and unstable behaviors as shown in the table below.

Stability Analysis

r States Stability
$|r| < 1 \,$ Stable
$|r| > 1 \,$ Unstable
$|r| = 1 \,$ Liapunov Stable

What does Liapunov stability imply? The fixed point is neither stable (goes towards the fixed point) nor unstable (goes away from the fixed point), but the trajectory is bounded. This is similar to a limit cycle or a center in continuous differential equations.

### Higher Order Difference Equations

A second order difference equations would tell us about the state of the system two time steps away, for example:

$x_{t+2} = ax_{t+1} + bx_t \,$

How do we go about solving this system? We again solve by guessing for the correct solution. We have our initial guess again as xt = Art. Substituting into our original equation, we get:

$Ar^{t+2} = aAr^{t+1} + bAr^t \,$

The characteristic equation for this system is

$r^2 - ar - b = 0 \,$

Solving for r

$r_{\pm} = \frac{a \pm \sqrt{a^2+4b}}{2}$

Hence, our general solution will be the sum of all possible solutions, just like in second order differential equations

$x_t = Ar_{+}^t + Br_{-}^t$

We can then solve for A and B with our initial conditions.

For the stability of the system, we know that for the system not to blow up to infinity, | r + | , | r | < 1. For this condition to be met, the following condition must be satisfied (can be solve for by setting r = 1).

$b < 1 - a \,$

Furthermore, we can generalize this solution for an N-dimensional system:

$a_0 x_{t+N} + a_1 x_{t+N-1} + \dots + a_N = 0$

We again make the guess that our solution is in the form xt = Art, substitute, and obtain our characteristic polynomial to be:

$\alpha_0 r^N + \alpha_1 r^{N-1} + \dots + \alpha_N = 0$

The roots of our polynomial give the values of r and they must all satisfy | r | < 1 for the entire system to be stable. With the root of the equation being: $\{r_1^*, \dots, r_N^*\}$, our general solution becomes:

$x_t = \sum_{i = 1}^N A_i(r_i^*)^t$

Solving these difference equations is non-trivial and computationally difficult. There are criteria (see Schur or Jury) to check to see if the parameters will lead to a stable conditions (which check to see if the roots are within the unit circle). We can only solve by hand to a maximum of 4 dimensions. With higher order dimensions, a computer becomes necessary to establish the roots of the equation.

### Fourier Analysis and Linear Discrete Time Analysis

We can first motivate this by an example. Let us consider a single sinusoid in the time domain.

$y(t) = Asin(\omega t) \,$

Is it possible to write this function in terms of a difference equation? Consider the time steps t and t+1 for a sinusoidal function:

\begin{alignat}{2} y_t & = A sin(\omega t) \\ y_{t \pm 1} & = A sin(\omega (t \pm 1)) \\ & = A[sin(\omega t)cos(\omega) \pm sin(\omega)cos(\omega t)] \end{alignat}

If we now add $y_{t+1} \,$ and $y_{t-1} \,$ we obtain:

\begin{alignat}{2} y_{t+1} + y_{t-1} & = 2A cos(\omega)sin(\omega t) \\ & = 2 cos(\omega)y_t \end{alignat}

Hence we can conclude that:

$y_{t+1} = 2cos(\omega)y_t - y_{t-1} \,$

We can see that a sinusoid function in the time domain can be expressed in terms of a second order difference equation. In general, if we have a sum of N sinusoidal waves making up our function, we can write this as a difference equations with 2N terms. In mathematical terms, this can be expressed as:

\begin{alignat}{2} y_t & = \sum_{m=1}^N a_m sin(m \omega t + \phi_m) \\ & \equiv \\ y_{t+2N} & = \sum_{m = 0}^{2N-1} b_m y_{t-m} \end{alignat}

Recall that the first equation above is just the Fourier transform of a function in time domain. Hence, for any function in the time domain, this can be written as either a series of sinusoids using Fourier transform or as a difference equation with two terms to each Fourier term. We can also see that the coefficients obtained from performing the Fourier transform are directly related to the coefficients of the difference equation that is generated.

The process of going from the time domain to the difference equation is known as Linear Discrete Time Analysis, since we can see that we obtain a linear difference equation from a sinusoidal function. This is analogous to getting a linear second order differential equation when we are considering the same sinusoid when we do continuous differentiation.

### Logistic Map

Let us now consider the logistic map equation as an example of how linear stability analysis is preformed on difference equations/systems.

$x_{t+1} = rx_t(1-x_t) \,$

Where 0 < r < 4 are the boundaries set.

First, to find the fixed points, we set xt + 1 = xt to obtain the two fixed points:

$x_t^* = 0, 1-\frac{1}{r}$

For linear stability analysis, we need that $\left | \frac{df}{dx_t} \right | < 1$

$f(x_t) = x_{t+1} = rx_t(1-x_t) \,$
$\frac{df}{dx_t} = r - 2rx_t$

Now evaluating at the fixed points

$f'(x_t^* = 0) = r$
$f'(x_t^* = 1 - \frac{1}{r}) = -r + 2$

Hence, the stability of the $x_t^* = 0$ fixed point is stable if 0 < r < 1 (recall that we are bounded between 0 < r < 4 for our system). The stability of the $x_t^* = 1 - \frac{1}{r}$ fixed point is stable for 1 < r < 3.

After r = 3, we see that the system is unstable and that there are no fixed points. In fact, we will oscillate between fixed points and observe what is known as period doubling in our system. How do we calculate these fixed points analytically? If we have a period 2 oscillation, that means that

$x_{t+2} = x_t \,$

And from our function, we know that

$x_{t+1} = f(x_t) \,$

And by substitution

$x_{t+2} = f(x_{t+1}) = f(f(x_t)) \,$

In general, to solve for p period solutions, we want that

$x_{t+p} = x_t \,$

And we can solve

$x_{t+p} = f(f...f(f(x_t)))_p \,$

Returning back to our period-2 oscillations, we substitute our logistic equation into the xt + 2 equation

$x_{t+2} = f(f(x_t)) = r[rx_t(1-x_t)][1-rx_t(1-x_t)]\,$

We now set this equal to xt and solve for the fixed points. As it can be seen that both our initial fixed points are fixed points of this system with two further fixed points being added. The two new fixed points are the points around which the system oscillates.

The bifurcations occur when the looking at the difference plot and seeing when you get more crossings on the graph. As the value of r is increased, the bifurcations occur more closely. After a certain value of r, you can get a point where there are no period solutions exist and this is the point where chaos emerges. Within the chaotic region, numerical analysis has yielded windows of periodicity such as period-3 oscillations, but quickly become chaotic again as r is changed.

With the analysis above, we can easily see that a fixed point is actually a period-1 solution to our system.