# Chaos indicators

REBOUND supports different chaos indicators. All of these make use of variational equations, but most of the complexity is hidden.

## Initialization

If you want to use a chaos indicator in REBOUND, first add all the particles to your simulations. Then, initialize the variational particles and MEGNO variables with

struct reb_simulation* r = reb_create_simulation();
reb_tools_megno_init(r);

sim = rebound.Simulation()
sim.init_megno()


REBOUND uses random numbers to initialize the variational particles. The initial seed is chosen based on the current time and the process id. This ensures the seed is different every time you run the simulation. See the discussion on random sampling for more details.

If you want to have reproducible result, you can specify the seed manually:

struct reb_simulation* r = reb_create_simulation();
reb_tools_megno_init_seed(r, 0); // 0 is the initial seed

sim = rebound.Simulation()
sim.init_megno(seed=0) # 0 is the initial seed


## Accessing chaos indicators

Once you've initialized the chaos indicators, you can integrate the simulation normally. To print out the MEGNO value or the largest Lyapunov characteristic number (LCN), use the following syntax:

struct reb_simulation* r = reb_create_simulation();
reb_tools_megno_init_seed(r);
// ... integrate ...
printf("MEGNO = %f\n", reb_tools_calculate_megno(r));
printf("LCN = %f\n", reb_tools_calculate_lyapunov(r));

sim = rebound.Simulation()