tresnjo / lyapunov-diagram-generator

For a given recurrence relation and sequence, the code outputs the corresponding Lyapunov diagram which holds key information about the stability of the generated sequence.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lyapunov Diagram Generator

The Lyapunov-diagram-generator is a tool to be used to further study the stability of a dynamical system through the concept of Lyapunov exponents. This README will provide a brief overview of what Lyapunov exponents are, and how the code works and can be used.

Table of Contents

Lyapunov Exponents

The Lyapunov exponents are a quantity of a dynamical system that characterizes the rate of separation of infinitesimally close trajectories. If a dynamical system consists of only negative Lyapunov exponents, the system is stable. If it contains negative and zero Lyapunov exponents, it’s considered periodic. Finally, if it contains all the previously mentioned as well as positive exponents, the system is considered chaotic.

If two trajectories in phase space are seperated with an initial vector $\delta \boldsymbol{\mathrm{Z_0}}$, their trajectories divergence at a rate given by

$$ |\delta \boldsymbol{\mathrm{Z}}(t)| \sim e^{\lambda t}|\delta \boldsymbol{\mathrm{Z_0}}| $$

where $\lambda$ is the Lyapunov exponent. The lambdas vary with variations in orientation of the initial seperation vector which introduces a spectrum of Lyapunov exponents (with dimension equal to the dimensionality of the phase space). The Lyapunov exponents can be calculated using the following formula

$$ \lambda = \lim_{n\rightarrow \infty} \frac{1}{n} \sum_{i=0}^{n-1} \ln | f'(x_i) | $$

where $f(x)$ is the mapping used in the reccurence relation [1].

Lyapunov Diagram Generator

The Lyapunov Diagram Generator is a Python-based tool that allows you to visualize the behavior of a dynamic system by generating Lyapunov diagrams. These diagrams are two-dimensional plots where each point $(r_1, r_2)$ constitutes the values used within the user defined recurrence-relation. The corresponding output on this two-dimensional grid is the Lyapunov exponent of the dynamical system.

Installation

  1. Clone this repository to your local machine.
  2. Navigate to the project directory.
git clone https://github.com/yourusername/lyapunov-diagram-generator.git
cd lyapunov-diagram-generator

Parameters

  • N - number of iterations of the recurrence relation
  • resol - resolution of the grid along one axis
  • seq - user defined sequence for how the recurrence relation should alternate between the $r_i$'s
  • x0 - the initial value for the recurrence relation

Modify these parameters in the script to explore different system behaviours.

Usage

To generate a Lyapunov diagram, change the parameters and the given reccurence relation f(x_n,r) of your choice. Notice that it's important to also for hand calculate the derivative of the recurrence relation with respect to $x_n$, f_prime(x_n,r) too. Don't also forget to adjust the region of interest for your parameters $r_1$ and $r_2$ inside the lyapunov_diagram function. Thereafter, run the code and enjoy your result. In the next section, some examples will be presented to you.

Examples

Here are some examples using the logistic recurrence relation $x_{n+1} = r \cdot x_n \cdot (1-x_n)$ for some different sequences and resolutions. The parameters can be found in the title of each diagram. Notice the cool fractals that are formed!

Fig1 Fig1 Fig1

Observe that the predefined reccurence relation in the code is the logistic reccurence relation. You are of course free to change it to whatever system you want to study.

References

[1] Libretexts (2022) 9.3: Lyapunov exponent, Mathematics LibreTexts. Available at: https://math.libretexts.org/Bookshelves/Scientific_Computing_Simulations_and_Modeling/Book%3A_Introduction_to_the_Modeling_and_Analysis_of_Complex_Systems_(Sayama)/09%3A_Chaos/9.03%3A_Lyapunov_Exponent (Accessed: 08 August 2023).

About

For a given recurrence relation and sequence, the code outputs the corresponding Lyapunov diagram which holds key information about the stability of the generated sequence.


Languages

Language:Python 100.0%