1 Introduction

The appearance of powerful computers has made the N-body simulations among efficient tools [1] for the study of various astrophysical and cosmological problems. The N-body gravitating systems cover a broad class of astrophysical problems, from the evolution of the Solar system as of a nearly integrable problem, up to the dynamics of star clusters, galaxies, and galaxy clusters as non-integrable problems. The cosmological simulations include from the evolution of primordial density perturbations up to the formation of dark matter galaxy halos, etc.

The N-body simulation activities have been developed in two conventional directions:

  1. 1.

    Numerical integration of N equations of motion in order to follow the evolution of the system. The main difficulty of these investigations based on standard iterative methods of numerical integration of differential equations (Runge–Kutta, etc.) is the inevitable storage of errors with the increasing of the number of steps. This leads to rapid loss of the reliability of the results derived, the faster, the larger is the number of equations (i.e. the number of particles) and/or the longer is the duration of the calculations.

  2. 2.

    Investigation of the character of motion in the systems, which includes the finding out of integrals of motion, analysis of appearing stochastic regions, etc. The main feature of this direction is the application of methods of dynamical systems, e.g. of Kolmogorov–Arnold–Moser (KAM) theory, Lyapunov exponents, KS-entropy, etc [2]. N-body gravitating systems, for example, do reveal variety of complex, chaotic properties which play a crucial role in their evolution and structure; see e.g. [38].

Speaking of numerical investigations of dynamical systems, both, smooth and discrete, one may note that the second direction seems to be particularly fruitful. Beginning from the pioneer study by Fermi, Pasta and Ulam in the early 1950s, it has led to unexpected and profound results such as the strange attractors, the Feigenbaum sequence of bifurcations, etc. As compared to those remarkable results, the numerical (iterative) study of the evolution of Hamiltonian systems, due to the reasons mentioned, looks moderately successful and reliable. The latter is equally true for such an important class of Hamiltonian systems as the so-called nearly integrable systems [2],

$$\begin{aligned} H(I,\vartheta ,\beta ) = H_0(I)+\beta H_1(I,\vartheta ), \end{aligned}$$
(1)

where \(I, \vartheta \) are the action-angle coordinates and \(\beta \) is the small parameter defining the non-integrable part of the Hamiltonian \(H_1\).

The well-known Hénon–Heiles system [9] modeling the stellar motion in a spiral galaxy is of this type; the same class of Hamiltonians can be attributed also to various aspects of planetary dynamics. The unique role of the system (1.1) in the Hamiltonian mechanics is determined undoubtedly by the proof of the KAM theorem, according to which, when distinct conditions are satisfied, there exist invariant tori,

$$\begin{aligned}&\!\!\!I= I_0 + u(\vartheta , \beta ), \end{aligned}$$
(2)
$$\begin{aligned}&\!\!\!\vartheta = \vartheta _0 + \omega t + v(\vartheta ,\beta ), \end{aligned}$$
(3)

where uv are periodic functions [2].

It is well known that the KAM theorem with its roots goes back to the main problem of celestial mechanics, the stability and evolution of the Solar system. Although the KAM theorem does not directly reveal the fate of the Solar system, its ideas were used for efficient numerical studies of the Solar system dynamics; see [7, 8] and other studies by Laskar et al. The KAM theorem itself does not determine the value of the perturbation \(\beta \), for which its statements are true, and regarding the planetary dynamics there are also principal difficulties in checking of the necessary conditions of the theorem with respect to each consideration. Moreover, due to the Arnold diffusion – a universal instability peculiar to non-linear systems of dimension \(N > 2\) – irrespective of whether the Solar system satisfies the conditions of the KAM theorem or not, it still cannot remain stable. Finding itself after an accidental perturbation in the stochastic region of phase space, the system can remain in it for an infinitely long time and therefore, the observed picture has to be destroyed anyway – the planets must either fall onto the Sun or fly away. So, those fundamental results at least do predict that, strictly speaking, the Solar system cannot last forever anyway, although the time scale of the latter instability (Arnold diffusion), according to estimates, far exceeds the Hubble time.

The example described above shows, on the one hand, the universality of systems with a perturbed Hamiltonian; on the other hand, the difficulties in direct application of the KAM theorem for revealing of the evolution of real physical and astrophysical systems.

Connecting certain hopes with computers and speaking of their potentialities, one must mention the importance of computer algebra methods, which, in our opinion, offer new prospects for the investigation of complex dynamics.

Below, we will show that computer algebraic methods along with those of dynamical systems enable the principal possibility of investigation of the evolution of a system without the effect of the storage of errors, i.e. of an accuracy independent on time. The search of error-free numerical integration schemes can be considered among the key problems of stellar dynamics, Problem 5 in [10]; see also [11].

2 Evolution in the phase space

The convenience of the investigation of a Hamiltonian system with small perturbation for action-angle variables is connected with the following. As is well known, the Hamiltonian of an n-dimensional integrable system with a phase space \(R^{2n} =\{p,q\}\), e.g. in the case of free oscillators with perturbation

$$\begin{aligned} H(p,q) = \sum ^n_{k=1}\left[ \frac{p_k^2}{2} + \frac{(\omega ^k q^k)^2}{2}\right] +\beta U(q), \end{aligned}$$
(4)

i.e. a system having n first integrals of motion in involution, enables one to transit from the variables (pq) to that of action-angle variables \((I,\vartheta )\),

$$\begin{aligned} \begin{array}{l} q^k=(2I_k/\omega ^k)^{1/2} \cos \vartheta ^k,\\ p_k=(2I_k\omega ^k)^{1/2} \sin \vartheta ^k. \end{array} \end{aligned}$$
(5)

Then, for \(\beta = 0\), the equations of motion

$$\begin{aligned} \begin{array}{l} \dot{I}_k= -\frac{\partial H}{\partial \vartheta ^k},\\ \dot{\vartheta }^k= \omega ^k(I) + \frac{\partial H}{\partial I_k}, \end{array} \end{aligned}$$
(6)

have a trivial solution,

$$\begin{aligned} \begin{array}{l} I_k = \mathrm{const},\\ \vartheta ^k = \omega ^k + \delta ^k,\quad \delta ^k = \mathrm{const}. \end{array} \end{aligned}$$
(7)

As follows from the Liouville theorem, in this case the phase space of the system splits into compact manifolds diffeomorphic to n-tori,

$$\begin{aligned} \mathrm{Tor}^n=\{\vartheta ^i\; \mathrm{mod}\; 2\pi \}. \end{aligned}$$
(8)

When \(\beta \ne 0\), the Hamiltonian equations read

$$\begin{aligned} \begin{array}{l} \dot{I}^k= -\frac{\partial H(I,\vartheta ,\beta )}{\partial \vartheta ^k},\\ \dot{\vartheta }^k= \frac{\partial H(I,\vartheta ,\beta )}{\partial I_k}, \end{array} \end{aligned}$$
(9)

where

$$\begin{aligned} H(I,\vartheta ,\beta ) = \sum ^n_{k=1} \omega ^k I_k + \beta V(I,\vartheta ). \end{aligned}$$
(10)

However, instead of solving or analyzing these equations as is done conventionally, we will proceed as follows.

One can observe that if (see [2, Section 39])

$$\begin{aligned} \dot{x}^k=A^k(x), \end{aligned}$$
(11)

then for any smooth function f(x) the following holds:

$$\begin{aligned} \frac{\mathrm{d}}{\mathrm{d}t} f(x)=\frac{\partial f(x)}{\partial x^k}\dot{x}^k=\frac{\partial f(x)}{\partial x^k}A^k(x). \end{aligned}$$
(12)

Therefore,

$$\begin{aligned} i\frac{\mathrm{d}}{\mathrm{d}t} f(x) -iA^k(x)\frac{\partial f(x)}{\partial x^k} = 0 \end{aligned}$$
(13)

or

$$\begin{aligned} i\frac{\mathrm{d}}{\mathrm{d}t} f(x) + L_A f(x) = 0 \end{aligned}$$
(14)

where

$$\begin{aligned} L_A = -iA^k(x)\frac{\partial }{\partial x^k}. \end{aligned}$$
(15)

Considering the function \(f(I,\vartheta )\) in the phase space \((I,\vartheta )\) and applying the above observation we find that the equation describing the evolution of this function at \((I,\vartheta )\equiv x\) changing according to (6) has the form

$$\begin{aligned} i\frac{\mathrm{d}}{\mathrm{d}t} f(x,t) + L(\beta ) f(x,t) = 0, \end{aligned}$$
(16)

where

$$\begin{aligned} \begin{array}{l} \!L(\beta ) = L_0 + \beta B,\\ \!L_0 = -i \frac{\partial H}{\partial I_k} \frac{\partial }{\partial \vartheta ^k},\\ \!B(V) = -i \left[ \frac{\partial V}{\partial I_k} \frac{\partial }{\partial \vartheta ^k} - \frac{\partial V}{\partial \vartheta ^k} \frac{\partial }{\partial I_k}\right] . \end{array} \end{aligned}$$
(17)

By means of the Laplace transform

$$\begin{aligned} \tilde{f}(x,\lambda ) = \int _0^{\infty } \mathrm{d}t\, f(x,t)\, \mathrm{e}^{i\lambda t}, \end{aligned}$$
(18)

one can rewrite Eq. (16) as follows:

$$\begin{aligned} -\lambda \tilde{f}(x,\lambda ) + L\tilde{f}(x,\lambda ) = -i f(x,0) \end{aligned}$$
(19)

or

$$\begin{aligned}&\tilde{f}(x,\lambda ) = i R_\lambda (\beta ) g(x), \nonumber \\ g(x)&\!\!\!\equiv f(x,0), \end{aligned}$$
(20)

where the resolvent \(R_{\lambda }(\beta )\) is equal to

$$\begin{aligned} R_{\lambda }(\beta ) = (\lambda - L(\beta ))^{-1}. \end{aligned}$$
(21)

One can show that the following expression is fulfilled:

$$\begin{aligned}&R_\lambda (\beta )g(x) = (\lambda -L_0-\beta B)^{-1}g(x) \nonumber \\&\quad =(1-\beta R_\lambda B)^{-1} R_\lambda g(x)\nonumber \\&\quad =\sum ^N_{k=0} a_k(\beta ^k)[R_{\lambda }B]^k R_{\lambda }g(x)+o(\beta ^N), \end{aligned}$$
(22)

i.e. at fixed \(\beta \), by variation of N, we can reach a given accuracy.

If

$$\begin{aligned} g(I, \vartheta ) = \sum _{k \in Z^n} g_k(I)\, \mathrm{e}^{i \langle k,\vartheta \rangle }, \end{aligned}$$
(23)

where

$$\begin{aligned} \langle k,\vartheta \rangle =k_i \vartheta ^i, \end{aligned}$$

then

$$\begin{aligned} \begin{array}{l} R_{\lambda } g(I,\vartheta ) = (\lambda -L_0)^{-1}g(I,\vartheta )= (\lambda +i \langle \omega ,\partial _\theta \rangle )^{-1}g(I,\vartheta ) \\ \quad =\sum \limits _{k \in Z^n} g_k(I)(\lambda +i \langle \omega ,\partial _\theta \rangle )^{-1} \mathrm{e}^{i \langle k,\vartheta \rangle } = \sum \limits _{k \in Z^n} g_k(I) \frac{\mathrm{e}^{i \langle k,\vartheta \rangle }}{\lambda - \langle k,\omega \rangle }, \end{array} \end{aligned}$$
(24)

i.e. Eq. (18) can he calculated relatively easily.

We choose the function g(x) in the form

$$\begin{aligned} g(I,\vartheta )=-\frac{1}{2}\sum _{k=1}^n(I_k-I_{0k})^2+\sum _{k=1}^n\cos (\vartheta ^k-\vartheta ^k_0). \end{aligned}$$
(25)

This choice is conditioned by two factors: first, it has a single maximum on \(R^n \times \mathrm{Tor}^n\) and, hence, its evolution has the same property; second, it allows an elementary representation in the form of a Fourier expansion.

Having \(R_{\lambda } g\), by means of the inverse Laplace transform we get the desired function,

$$\begin{aligned} f(x,t)=\int _C\frac{\mathrm{d}\lambda }{2\pi }\, \mathrm{e}^{-i\lambda t}\tilde{f}(x,\lambda )= - \int _C \frac{\mathrm{d}\lambda }{2\pi } \mathrm{e}^{-\lambda t} R_{\lambda }(\beta ) g(x), \end{aligned}$$
(26)

where the contour of integration is

$$\begin{aligned} C=\{ \sigma +is,\, -\infty < \sigma < \infty ,\, s= a>0\}. \end{aligned}$$
(27)

Therefore, the evolution of the initial function of \(f(x,0) = g(x)\) is found. Estimating after this the maximum of the function \(f(x,t) \equiv f(I,\vartheta , t)\) for each t we find the time evolution of \(I,\vartheta \), thus determining the evolution of the Hamiltonian system for those time instances.

The principal difference between this and the standard iteration methods of integration of Hamiltonian systems is clear; here the time t is a parameter of f(xt) and does not influence the accuracy of calculation of the latter.

3 Computations via the new scheme

Firstly, let us note the importance of application of the computer algebra in our calculations. Due to the absence of errors at an integration and differentiation operation, the final results practically do not contain any errors. To demonstrate this, we consider a dynamical system given by a two-dimensional Hamiltonian of two oscillators with small perturbations,

$$\begin{aligned} H = \omega _1 I_1 + \omega _2 I_2 +\beta I_1 \cos \vartheta _1. \end{aligned}$$
(28)

The initial function \(f(I, \vartheta , 0)\) was chosen in the form of Eq. (25). Then the evolution of that function by means of the procedure described was obtained,

$$\begin{aligned}&f(I,\vartheta ,t)=\exp (i\vartheta _1)(I_1-I_1(0))I_1\nonumber \\&\qquad +\frac{1}{2}\exp (-i\vartheta _1(0)) [\exp (-i\omega _1t)-1] \nonumber \\&\qquad +\,\exp (i\vartheta _1)(I_1-I_1(0))I_1\nonumber \\&\qquad +\frac{1}{2}\exp (3i\vartheta _1-2i\omega _1t-i\vartheta _1(0))\nonumber \\&\qquad \times \,[\exp (i\omega _1t)-1]\,\omega _1^{-1}\beta \nonumber \\&\qquad -\frac{1}{2}(I_1-I_1(0))^2-\frac{1}{2}(I_2-I_2(0))^2 \nonumber \\&\qquad +\,\frac{1}{2}\exp (i\vartheta _1-i\omega _1t-i\vartheta _1(0))\nonumber \\&\qquad +\frac{1}{2}\exp (i\vartheta _2- i\omega _2t-i\vartheta _2(0)). \end{aligned}$$
(29)

The evolution of the surface determined by the function \(f(I, \vartheta , t)\) at different instances of time and for \(I_1=\mathrm{const}, I_2=\mathrm{const}\) is shown in Fig. 1. In Figs. 2 and 3 the variations of \(\vartheta _1\) and \(I_1\) by the time for different initial conditions and values of \(\beta \) are shown. The trajectories are regular with a period of \(2\pi \). During computations, at the increase (decrease) of \(\beta \) by an order of magnitude, the calculation time varied proportionally, at the accuracy \(10^{-4}\). The performed computations were little time consuming (for i7, 2600 3.4 GHz processor of 6 GB memory); we plan to apply the approach to real physical systems and provide more results in forthcoming papers.

Fig. 1
figure 1

The time evolution of the surface determined by Eq. (29) for \(I_1=\mathrm{const}, I_2=\mathrm{const}\)

Let us stress again that the accuracy of the computations of the trajectory does not depend on time, since no iterations are involved.

Fig. 2
figure 2

The time variations of \(\vartheta _1\) for initial conditions \(I_1(0)=1.0, I_2(0)=2.0\), and \(\vartheta _1(0)=3.0, \vartheta _2(0)=2.0\), and several values of \(\beta \)

Fig. 3
figure 3

The time variations of \(I_1\) for different initial conditions and values of \(\beta \): a \(I_1(0)=1.0, I_2(0)=2.0\), and \(\vartheta _1(0)=3.0, \vartheta _2(0)=2.0\), b \(I_1(0)=4.5, I_2(0)=2.0\), and \(\vartheta _1(0)=1.0, \vartheta _2(0)=2.0\)

4 Conclusions

We demonstrated a principal way of finding out of the evolution of a dynamical system independent on time accuracy; namely, the phase space point \(I_1(0), I_2(0), \vartheta _1(0), \vartheta _2(0)\) describing the initial state of the Hamiltonian system is transferred to an arbitrary t, without any storage of errors. The key feature of this method is that we transfer the function \(f(I, \vartheta , 0)\) and, therefore, solve an equation which is sufficiently easier (linear), as compared to the Hamiltonian equations. Moreover, the former equation is solved analytically and not by an iteration procedure.

Another remarkable advantage of this procedure is the following: the initial state of a non-linear system during evolution can find itself in the stochastic region of phase space. The description of this is impossible by integration (even numerical) of the Hamiltonian equations, while our method allows us to investigate even this phenomenon. This aspect is particularly important for the study of N-body gravitating systems in view of their well-known chaotic properties. Then this method can open new principal possibilities for cosmological and extensive astrophysical N-body simulations.