Suppose you are solving a system of equations numerically that possesses an attractor (no matter the initial conditions set, all the different solutions will approach a specific set of values that comprise the so-called attractor). The numerical method employed is a fourth-order Runge-Kutta one.

Now suppose you take the end values of your attractor solution and integrate backwards in time. Is it normal that the resulting curve deviate from the original attractor trajectory and ends up ''diverging''?

In principle my guess is that it shouldn't have to follow the original attractor solution because of the different solutions that converged to it. However, the fact that it eventually diverges is what makes me think that the code I am using is wrong.


At the request of a user, I write the equations:

$\dot x = y$

$\dot y = -\frac{\sqrt{3}}{2}y\sqrt{y^2+\frac{1}{2}x^4}-x^3$

dot denotes time derivative.

The code is:

def rk4trial(f,v0,t0,tf,n,V):
    for j in range(n):
    return V, t, h

When integrating backwards, I simply set tf as initial time and t0 as final time and use the end values as initial conditions.

  • $\begingroup$ Possible duplicate of Runge-Kutta fourth order method. Integrating backwards $\endgroup$ Nov 26, 2019 at 19:52
  • $\begingroup$ @Lutz Sorry, that was not the code I was using. I have corrected it. $\endgroup$
    – user33042
    Nov 27, 2019 at 11:58
  • $\begingroup$ Yes, that now makes sense. $\endgroup$ Nov 27, 2019 at 13:25
  • $\begingroup$ I could not reproduce your error with reasonable paramters. Could you please add the parameters where you observed this divergent behavior? I tried with $x_0=y_0=\sqrt2$, interval $[0,40]$ with 200 segments, that is, step size $h=0.2$, and backtracking from the points with index 20,40,...,200. I did not observe any divergence in the phase plot, the backwards curves are all over each other and over the forwards curve. $\endgroup$ Nov 28, 2019 at 11:24

2 Answers 2


The problem you are encountering is likely not a consequence of your choice of algorithm, but in fact a consequence of the resulting dynamical system after applying time reversal. Per the definition of an attractor, all points in some neighborhood of the attractor will converge to the attractor under the flow of the dynamical system as $t\to\infty$. However, time reversal simply swaps the direction of said flow, so when time is reversed, each point in a sufficiently small neighborhood around the attractor will move away from the attractor, so the stability flips and this attractor becomes an unstable equilibrium of the system.

Now for the numerical effects. You are correct that since there are many solutions that converged to the attractor, the finite-precision nature of the computations will lead to the solution you backtrack not lining up. As for the blowup, this is a result of the specific features of this system of differential equations. We can easily show that $(0,0)$ is the only equilibrium of this system, but if you look at solutions in the phase plane of this system, you will see that trajectories spiral about the origin as $t\to\infty$. This essentially means that every possible trajectory of this system gets arbitrarily close together near the origin, so backtracking these trajectories with any error results in a different trajectory. Also, since every trajectory goes to the origin, in the time reversal, every solution will blow up since there are no other equilibria.

enter image description here


You may have seen depictions of ODE dynamics for the scalar equation $x'(t)=f(t,x(t))$ in the form of a $t,x$ plot in which one plots little arrows in the entire $t,x$ plane. A trajectory starting from a particular $t,x_0$ value then follows the arrows it encounters along its way.

Now think of an attractor, i.e., a curve in $t,x$ space to which all of these trajectories are attracted. This attraction means that the arrows below the curve must point towards the curve, on the curve they point tangential to the curve, and above the curve they must point down at the curve. Now imagine you are integrating backward and you have accumulated a bit of numerical error, so you're not exactly on the attractor curve any more. Since you're now following the arrows in the opposite direction, it's clear from the statement of what an "attractor" is, that if you're working in the opposite direction an attractor actually becomes a "repellor", and that you'll have to diverge away from it as soon as you're not exactly on the curve any more.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy