# "Warning: Instability detected. Aborting" while using lyapunovspectrum

**URL:** <https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536>\
**Category:** Numerics\
**Tags:** dynamical-systems\
**Created:** [December 12, 2023, 11:31pm UTC](https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536 "2023-12-12T23:31:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Montesinos\_Ca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel_montesinos_ca/32/205425_2.png) [@Daniel\_Montesinos\_Ca](https://discourse.julialang.org/u/Daniel_Montesinos_Ca)\
**Post date:** [December 12, 2023, 11:31pm UTC](https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536/1 "2023-12-12T23:31:21Z")

</div>

Hey, I’m trying to study the lyapunov spectrum for a 4D dynamical system using the lyapunovspectrum function from DynamicalSystem.jl but depending on the parameters I get “Warning: Instability detected. Aborting” and I don’t know how to solve this. I’ve tried to search and found that this could be related to special singularities of the system or the solver. This is the code that I am using:

> Blockquote  
> function mem\_system(du, u, p, t)  
> x, y, z, v = u  
> a, b, c, d, e, α, β = p  
> du[1] = -(a_y^2 - b)x - (αv + β)z  
> du[2] = -cx - d_y + e_y_x^2  
> du[3] = x  
> du[4] = z  
> return nothing  
> end  
> u0 = [-1, -0.5, -0.5, -3] # Initial condition  
> p1 = [0.1, 0.5, 0.5, 10, 4, 0.1, 1] # a, b, c, d, e, α, β  
> integrationMethod = (alg = Tsit5(), adaptive = false, dense = false, dt = 0.01, reltol=1e-9, abstol=1e-9)  
> syst\_1 = CoupledODEs(mem\_system, u0 , p1, diffeq =integrationMethod)  
> lya\_spec = lyapunovspectrum(syst\_1, 10^5; Ttr = 10^3, show\_progress = true) # Works fine  
> set\_parameter!(syst\_1, 1, 0.41)  
> set\_parameter!(syst\_1, 2, 0.91)  
> lya\_spec = lyapunovspectrum(syst\_1, 10^5; Ttr = 10^3, show\_progress = true) # Instability warning

I get the warning when I change the value of the parameters.

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [December 13, 2023, 10:10am UTC](https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536/2 "2023-12-13T10:10:32Z")

</div>

Hi there welcome to the community!

Well this warning means that the ODE solution is unstable. It does not have any direct relation to Lyapunov exponents, you would get the same error if you tried to just evolve the system with `trajectory` or directly with `solve` of DifferentialEquations.jl.

There isn’t much help I can provide unfortunately ☹ Try different solvers, or solvers of higher precision by increasing the tolerances. But in the end of the day, it may well be that for these parameters the system is unstable and/or ill-defined. Sorry!

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [December 13, 2023, 1:22pm UTC](https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536/3 "2023-12-13T13:22:49Z")

</div>

> **[Frequently Asked Questions · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/basics/faq/#faq_stability)**
>
> Documentation for DifferentialEquations.jl.

I’d start by changing the integration method around, and then double check so that there is not an error with your model

---

<div class="post-metadata">

**Author:** ![Daniel\_Montesinos\_Ca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel_montesinos_ca/32/205425_2.png) [@Daniel\_Montesinos\_Ca](https://discourse.julialang.org/u/Daniel_Montesinos_Ca)\
**Post date:** [December 13, 2023, 5:47pm UTC](https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536/4 "2023-12-13T17:47:00Z")

</div>

Thank you for your response. I’ve tried to use other methods to see the trajectory and it seems that it diverges for that parameters. The funny thing is that I was trying to reproduce some results from a paper where they don’t specify anything about how did they solve the equations. For these parameters, it was suppose to have chaotic behaviour or something like that but not divergence.

Anyway, when I try to compute the lyapunov spectrum and the warning comes up, it seems that Julia stays infinetly in the process instead of finishing it. Do you know how could I make it stop in case of a warning?

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [December 13, 2023, 6:23pm UTC](https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536/5 "2023-12-13T18:23:36Z")

</div>

unfortunately this is a downside of Julia… in many situations you can’t stop the process. You can only restart the whole Julia. Solving differential equations appears to be one such case. At least to me it happens all the time and I found no reliable way to just “stop” the process, only to restart Julia.

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [December 13, 2023, 6:25pm UTC](https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536/6 "2023-12-13T18:25:54Z")

</div>

> [@Daniel\_Montesinos\_Ca](#):
>
> I’ve tried to use other methods to see the trajectory and it seems that it diverges for that parameters. The funny thing is that I was trying to reproduce some results from a paper where they don’t specify anything about how did they solve the equations. For these parameters, it was suppose to have chaotic behaviour or something like that but not divergence.

hahaha Not being able to reproduce people’s work in nonlinear dynamics is the whole “character arc” of DynamicalSystems.jl 😃 One of the main reasons it exists is to bring reproducibility reliability and accessibility in computational nonlinear dynamics. Happy to see you come on board!

---

<div class="post-metadata">

**Author:** ![Daniel\_Montesinos\_Ca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel_montesinos_ca/32/205425_2.png) [@Daniel\_Montesinos\_Ca](https://discourse.julialang.org/u/Daniel_Montesinos_Ca)\
**Post date:** [December 13, 2023, 7:12pm UTC](https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536/7 "2023-12-13T19:12:46Z")

</div>

Oh, that’s quite a pain. Thank you, I wont waste my time on trying to find a way to do something impossible 😂

---

<div class="post-metadata">

**Author:** ![Daniel\_Montesinos\_Ca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel_montesinos_ca/32/205425_2.png) [@Daniel\_Montesinos\_Ca](https://discourse.julialang.org/u/Daniel_Montesinos_Ca)\
**Post date:** [December 13, 2023, 7:15pm UTC](https://discourse.julialang.org/t/warning-instability-detected-aborting-while-using-lyapunovspectrum/107536/8 "2023-12-13T19:15:30Z")

</div>

I understand, it is quite a good reason. I’ll try my best to use it wisely.
