1 Introduction

A large amount of work in the literature has been devoted to study the following second order oscillatory differential equations arising from various aspects of Hamiltonian dynamics [19, 21, 23, 24, 36, 38, 39, 41, 42, 46, 49]

$$\begin{aligned} {\ddot{\mathbf {x}}}(t)+A\mathbf {x}(t)+\mathbf {g}(\mathbf {x}(t))=0,\quad t>0, \end{aligned}$$
(1.1)

where \(\mathbf {x}=\mathbf {x}(t)\in \mathbb {R}^d\) and \(A=\varOmega ^2\in \mathbb {R}^{d\times d}\) is a positive semi-definite symmetric matrix of arbitrarily large norm. In a Hamiltonian system, \(\mathbf {x}\) is interpreted as the positions of the particles and \({\dot{\mathbf {x}}}\) denotes the corresponding velocities. By a diagonalization of the matrix, one can consider

$$\begin{aligned} A=\frac{1}{\varepsilon ^2}\varLambda ^2, \end{aligned}$$

where \(0<\varepsilon \le 1\) is inversely proportional to the spectral radius of \(\varOmega \) and \(\varLambda \) is a diagonal matrix with nonnegative entries independent of \(\varepsilon \). The function \(\mathbf {g}(\cdot ):\mathbb {R}^d\rightarrow \mathbb {R}^d\) is a possible nonlinearity and has a Lipschitz constant bounded independently of \(\varepsilon \) [41, 42], which in a Hamiltonian system, usually represents the internal force generated by a potential function \(V(\cdot )\) [42, 44], i.e. \(\nabla V(\mathbf {x})=\mathbf {g}(\mathbf {x})\), and consequently the total energy E(t) of the system is conserved as

$$\begin{aligned} E(t):=\frac{1}{2}\left[ \dot{\mathbf {x}}^\mathrm {T}\dot{\mathbf {x}}+\frac{1}{\varepsilon ^2}\mathbf {x}^\mathrm {T}\varLambda ^2\mathbf {x}\right] +V(\mathbf {x})\equiv E(0),\quad t\ge 0. \end{aligned}$$
(1.2)

When large frequencies are involved in the Hamiltonian system, which corresponds to the parameter \(0<\varepsilon \ll 1\), the solution of the ODEs (1.1) becomes highly oscillatory and propagates waves with wavelength at \(O(\varepsilon )\). Due to the high oscillations, designing uniformly accurate numerical integrators for solving (1.1) in the limit regime is the major and challenging subject in order to study the ODE system efficiently. The ODEs (1.1) is widely considered in the literatures [36, 38, 39, 41, 42, 46, 49] to associate with two given initial values, i.e. \(\mathbf {x}(0)\) and \(\dot{\mathbf {x}}(0)\), that make the reduced energy

$$\begin{aligned} {\widetilde{E}}(t):=\dot{\mathbf {x}}^\mathrm {T}\dot{\mathbf {x}}+\frac{1}{\varepsilon ^2}\mathbf {x}^\mathrm {T}\varLambda ^2\mathbf {x},\quad t\ge 0, \end{aligned}$$

uniformly bounded as \(\varepsilon \rightarrow 0\). For simplicity of illustration, let us assume here \(\varLambda \) is non-singular. Then the boundedness of the reduced energy implies

$$\begin{aligned} \mathbf {x}(t)=O(\varepsilon ),\quad {\dot{\mathbf {x}}}(t)=O(1),\quad t\ge 0,\quad 0<\varepsilon \ll 1. \end{aligned}$$

Thus, the initial value problem of (1.1) is imposed as

$$\begin{aligned} \left\{ \begin{aligned}&{\ddot{\mathbf {x}}}(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {x}(t)+\mathbf {g}(\mathbf {x}(t))=0,\quad t>0,\\&\mathbf {x}(0)=\varepsilon \phi _0,\quad \dot{\mathbf {x}}(0)=\phi _1, \end{aligned}\right. \end{aligned}$$
(1.3)

with given data \(\phi _0,\phi _1\in \mathbb {R}^d\) independent of \(\varepsilon \). This energy bounded type data usually arises from classical Hamiltonian system. In particular, we would like to remark in molecular dynamics, the nonlinearity \(\mathbf {g}(\cdot )\) is often generated by some nonbonded potentials [44]. The two most typical nonbonded potentials are the Coulomb potential \(V_C\) with \(n_0\) particles in \(m_0\,(d={n_0}m_0)\) dimensions as [44]

$$\begin{aligned} V_C(\mathbf {x}):=\sum _{l=2}^{n_0}\sum _{j=1}^{l-1}\frac{-c_{lj}}{|\mathbf {q}_l-\mathbf {q}_j|},\quad c_{lj}>0, \end{aligned}$$
(1.4)

where \(\mathbf {q}_l\in \mathbb {R}^{m_0}\) and \(\mathbf {x}=(\mathbf {q}_1,\ldots ,\mathbf {q}_{n_0})^\mathrm {T}\) and the Lennard-Jones potential \(V_{LJ}\) [42]

$$\begin{aligned} V_{LJ}(\mathbf {x}):=\sum _{l=2}^{n_0}\sum _{j=1}^{l-1}\left( \frac{c_{lj}}{|\mathbf {q}_l-\mathbf {q}_j|}\right) ^{12}- \left( \frac{c_{lj}}{|\mathbf {q}_l-\mathbf {q}_j|}\right) ^{6},\quad c_{lj}>0. \end{aligned}$$
(1.5)

In these two cases, in order to provide that the nonlinearity \(\mathbf {g}(\mathbf {x})\) in (1.3) has a Lipschitz constant essentially independent of \(\varepsilon \), one has to modify the practical potential \(V(\mathbf {x})\) used in (1.2) for generating \(\mathbf {f}(\mathbf {x})\) to

$$\begin{aligned} V(\mathbf {x})=\varepsilon ^3V_C(\mathbf {x})\quad \hbox {or}\quad V(\mathbf {x})=\varepsilon ^{14}V_{LJ}(\mathbf {x}), \end{aligned}$$
(1.6)

instead of taking \(V=V_C\) or \(V=V_{LJ}\) directly. It is clear to see that it is the initial data in (1.3) makes the position value small in the highly oscillatory regime. The higher the oscillation frequency is, however the smaller the amplitude is. The problem (1.3) with this type of initial data has been well studied by Sanz-Serna and Lubich etc in the past decades. The exponential (wave) integrators (EIs) or also known as trigonometric integrators with different kinds of filters [25, 32, 36,37,38,39,40, 42] have been proposed and shown to offer uniform second order accuracy in the absolute position error for \(0<\varepsilon \le 1\) and offer uniform first order accuracy in velocity error. The long time energy preserving property of the EIs has been analyzed in [19, 21, 22, 41] by means of a powerful tool known as modulated Fourier expansion. Besides, Enquist etc developed a general methodology known as the heterogeneous multiscale method (HMM) [2, 26, 50,51,52] for problems with widely different scales, and the method has been applied to solve the highly oscillatory ODEs [2, 26, 50]. Different from numerical methods like EIs which look for complete knowledge of the problem at every scale, the HMM only solves an averaged effective model by a macro-solver and predicts local information of the original model by a micro-solver. The modulated Fourier expansions have been used to analyze HMM in [47].

Recently, another type initial data which comes from some limit regimes of quantum physics [3,4,5,6, 14] has been considered to the ODEs as

$$\begin{aligned} \left\{ \begin{aligned}&\ddot{\mathbf {y}}(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {y}(t)+\mathbf {f}(\mathbf {y}(t))=0,\quad t>0,\\&\mathbf {y}(0)=\mathbf {\phi }_0,\quad \dot{\mathbf {y}}(0)=\frac{\mathbf {\phi }_1}{\varepsilon }, \end{aligned}\right. \end{aligned}$$
(1.7)

where in order to distinguish the scales, we switch the notations from \(\mathbf {x}\) and \(\mathbf {g}\) to \(\mathbf {y}\) and \(\mathbf {f}\), respectively. This type of initial data makes the reduced energy \({\widetilde{E}}(t)=\dot{\mathbf {y}}^\mathrm {T}\dot{\mathbf {y}}+\frac{1}{\varepsilon ^2}\mathbf {y}^\mathrm {T}\varLambda ^2\mathbf {y}\) turn to infinity as \(\varepsilon \rightarrow 0\). Without confusions, we shall address the problem (1.7) as the energy unbounded type and refer to (1.3) as energy bounded type. Compared to the previous energy bounded case, the energy unbounded type problem corresponds to larger position value case, that is \(\mathbf {y(t)}=O(1)\) as \(0<\varepsilon \ll 1\), and it leads to much wider oscillations in the solution. Thus, we also address the initial data in (1.7) as large initial data. The two types of problems are connected by a scaling. In fact, by introducing a scaling to the variables as

$$\begin{aligned} \mathbf {y}(t)=\frac{\mathbf {x}(t)}{\varepsilon }, \end{aligned}$$
(1.8)

we can rewrite the energy bounded problem (1.3) in an energy unbounded form

$$\begin{aligned} \left\{ \begin{aligned}&\ddot{\mathbf {y}}(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {y}(t)+\frac{1}{\varepsilon }\mathbf {g}(\varepsilon \mathbf {y}(t))=0,\quad t>0,\\&\mathbf {y}(0)=\mathbf {\phi }_0,\quad \dot{\mathbf {y}}(0)=\frac{\mathbf {\phi }_1}{\varepsilon }, \end{aligned}\right. \end{aligned}$$
(1.9)

or rewrite the energy unbounded problem (1.7) in an energy bounded form

$$\begin{aligned} \left\{ \begin{aligned}&{\ddot{\mathbf {x}}}(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {x}(t)+{\varepsilon }\mathbf {f}\left( \frac{\mathbf {x}(t)}{\varepsilon }\right) =0,\quad t>0,\\&\mathbf {x}(0)=\varepsilon \mathbf {\phi }_0,\quad \dot{\mathbf {x}}(0)=\mathbf {\phi }_1. \end{aligned}\right. \end{aligned}$$
(1.10)

Thus, to consider the energy bounded problem (1.3) is to consider (1.7) with the nonlinearity

$$\begin{aligned} \mathbf {f}(\mathbf {y})=\mathbf {g}_\varepsilon (\mathbf {y}):=\frac{1}{\varepsilon }\mathbf {g}(\varepsilon \mathbf {y}), \end{aligned}$$

and conversely to consider the energy unbounded problem (1.7) is to consider (1.3) with the nonlinearity

$$\begin{aligned} \mathbf {g}(\mathbf {x})=\mathbf {f}_\varepsilon (\mathbf {x}):={\varepsilon }\mathbf {f}\left( \frac{\mathbf {x}}{\varepsilon }\right) . \end{aligned}$$

Now comparing (1.3) with (1.10) or (1.7) with (1.9), we can see that under the scaling, the essential difference between the two types of initial data lies on the behavior of the function \(\mathbf {g}(\cdot )\) (or \(\mathbf {f}\)). For the linear function, i.e. \(\mathbf {g}(\mathbf {x})=M \mathbf {x}\) with \(M\in \mathbb {R}^{d\times d}\), clearly the energy bounded problem (1.9) (or (1.10)) is completely equivalent to the unbounded case (1.7) (or (1.3)). However for nonlinear \(\mathbf {g}(\cdot )\), they could be quite different. For \(\mathbf {g}=\nabla V\) in (1.3) generated by the practical unbonded potential V in (1.6), the scaled \(\mathbf {g}_\varepsilon (\mathbf {y})\) in (1.9) is indeed generated by the original unbond potential functions (1.4) or (1.5). In practise, another major brunch of nonlinearities \(\mathbf {g}(\cdot )\) take the power functions, i.e. each component \(g_j(\mathbf {x})\,(j=1,\ldots ,d)\) of \(\mathbf {g}\) is a (or a sum of) pth-order (\(p\ge 2\)) pure power function of \(x_1,\ldots ,x_d\). These power type nonlinearities widely occur in the scalar field theory in quantum physics [3,4,5] and in the classical dynamical systems such as the Fermi–Pasta–Ulam (FPU) problem [42, 43]. These type of functions make the nonlinearity in the equation (1.9) a very small quantity. For example, if \(g_j(\mathbf {x})\) is a cubic power function, then \(\mathbf {g}_\varepsilon (\mathbf {y})=O(\varepsilon ^2)\) as \(0<\varepsilon \ll 1\). The higher the order of the polynomial is, the smaller the nonlinearity becomes. Thus, the energy bounded problem (1.3) with the power nonlinearity is just a very small perturbation to the harmonic oscillator as \(\varepsilon \) is small. While for the energy unbounded problem (1.7) with power nonlinearity where \(\mathbf {f}(\mathbf {y})=O(1)\) as \(0<\varepsilon \ll 1\), the nonlinearity is no longer a small perturbation. Under this sense, we can also say that considering the energy unbounded problem (1.7) is considering a much stronger nonlinearity in the second order oscillatory equations, where wider resonance could happen in the solution in a shorter time scale. We give an example to illustrate the different oscillatory behaviors in the solutions of the two types of problems. We choose in (1.3) and (1.7): \(d=2,\mathbf {x}=(x_1,x_2)^\mathrm {T},\mathbf {y}=(y_1,y_2)^\mathrm {T},\phi _0=(1,2)^\mathrm {T},\phi _1=(1,3)^\mathrm {T},\varLambda =diag(\pi ,\pi )\) and \(\mathbf {g}(\mathbf {x})=(x_1x_2^2,x_1^2x_2)^\mathrm {T}, \mathbf {f}(\mathbf {y})=(y_1y_2^2,y_1^2y_2)^\mathrm {T}\), and the solutions under different \(\varepsilon \) are shown in Fig. 1. Figure 2 shows the error between the solution of (1.3) or (1.7) and its corresponding the harmonic oscillator by removing the nonlinearity:

$$\begin{aligned} \left\{ \begin{aligned}&{\ddot{\mathbf {x}}}_{ho}(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {x}_{ho}(t)=0,\quad t>0,\\&\mathbf {x}_{ho}(0)=\varepsilon \phi _0,\quad \dot{\mathbf {x}}_{ho}(0)=\phi _1, \end{aligned}\right. \quad \hbox {or}\quad \left\{ \begin{aligned}&\ddot{\mathbf {y}}_{ho}(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {y}_{ho}(t)=0,\quad t>0,\\&\mathbf {y}_{ho}(0)=\phi _0,\quad \dot{\mathbf {y}}_{ho}(0)=\frac{\phi _1}{\varepsilon }. \end{aligned}\right. \end{aligned}$$
(1.11)

By denoting \(\dot{\mathbf {y}} = \varepsilon ^{-1} \mathbf {u}\), (1.7) reads \(\dot{\mathbf {u}} = -\varepsilon ^{-1} \mathbf {y}- \varepsilon \mathbf {f}(\mathbf {y})\) and one can see that the nonlinearity is a higher order perturbation to the linear part. Formally as \(\varepsilon \rightarrow 0\), both \(\mathbf {x}(t)\) and \(\mathbf {y}(t)\) converges to \(\mathbf {x}_{ho}(t)\) and \(\mathbf {y}_{ho}(t)\) respectively for fixed \(t>0\) (we shall see more clearly later). Figure 2 indicates the convergence rates of the two types of problems in \(\varepsilon \) are quite different. Another way to analyse (1.7), for example under the polynomial nonlinearity of degree \(p+1\), is to define \(\mathbf {u}=(\varepsilon ^{1/p}\mathbf {y}+i\varepsilon ^{(p+1)/p}\varLambda ^{-1}\dot{\mathbf {y}})/\sqrt{2},\) then the problem becomes

$$\begin{aligned}\left\{ \begin{aligned}&i\dot{\mathbf {u}}=\varepsilon ^{-1}\varLambda \mathbf {u}+\frac{\varepsilon ^{(p+1)/p}}{\sqrt{2}}\varLambda ^{-1}\mathbf {f}\left( \frac{\mathbf {u}+\overline{\mathbf {u}}}{\sqrt{2}\varepsilon ^{1/p}}\right) ,\\&\mathbf {u}(0)=\varepsilon ^{1/p}\frac{\phi _0+i\varLambda ^{-1}\phi _1}{\sqrt{2}}. \end{aligned}\right. \end{aligned}$$

It corresponds to a nonlinear Schrödinger-type equation with small initial data and has been intensively studied by means of the modulated Fourier expansion [20, 27, 28, 34, 35].

Fig. 1
figure 1

Solutions of the energy bounded problem (1.3) (left) and the energy unbounded problem (1.7) (right) under different \(\varepsilon \)

Fig. 2
figure 2

First row errors \(|\mathbf {x}(t)-\mathbf {x}_{ho}(t)|/\varepsilon \) and \(|\mathbf {y}(t)-\mathbf {y}_{ho}(t)|\) between the solutions of (1.3) and (1.7) and their corresponding the harmonic oscillators under different \(\varepsilon \). Second row growths of the maximum errors \(\displaystyle e_x(t):=\sup \nolimits _{0\le s\le t}\{|\mathbf {x}(s)-\mathbf {x}_{ho}(s)|/\varepsilon \}\) and \(\displaystyle e_y(t):=\sup \nolimits _{0\le s\le t}\{|\mathbf {y}(s)-\mathbf {y}_{ho}(s)|\}\)

Another essential difference between the energy bounded and unbounded problems is that from the computational point of view, if one has a numerical integrator to (1.3) and (1.9) or (1.7) and (1.10) with numerical solutions denoted as \(\mathbf {x}^n\) and \(\mathbf {y}^n\) as approximations to \(\mathbf {x}(t_n)\) and \(\mathbf {y}(t_n)\) respectively at some time grids \(t_n=n\tau \) with \(n\in \mathbb {N}\) and \(\tau >0\) the time step, the absolute position error for the energy unbounded problem

$$\begin{aligned} \mathbf {e}^n:=\mathbf {y}(t_n)-\mathbf {y}^n=\frac{\mathbf {x}(t_n)-\mathbf {x}^n}{\varepsilon }\approx \frac{\mathbf {x}(t_n)-\mathbf {x}^n}{|\mathbf {x}(t_n)|},\quad 0<\varepsilon \ll 1, \end{aligned}$$

can be treated as the relative error for the energy bounded case. Though uniform accurate second order numerical integrators have been developed for solving energy bounded problem (1.3) as we mentioned before, the approximations could make no sense when the step size \(\tau ^2\gg \varepsilon \) since the solution \(\mathbf {x}(t)=O(\varepsilon )\), and the uniform convergence would be lost after scaling by \(\varepsilon ^{-1}\). Thus, considering the relative error bound to the energy bounded case or switching to considering the energy unbounded type problem is more convincible for uniform convergence. A detailed table of the relations between each quantity connected by the scaling (1.8) in the two problems is given in Table 1. Along the numerical aspects for the energy unbounded ODEs (1.7), investigations in the literatures so far are limited. Due to the strong oscillation features, existing numerical methods in the energy bounded case do not give any clues on their performance in the energy unbounded case. Popular multiscale integrators in the literature such as the stroboscopic averaging method (SAM) [8,9,10] and the multi-revolution composition method (MRCM) [12, 13] could apply in the limit regime. Generalisations of SAM and MRCM are known as the envelope-following methods which we refer to [45] and the references therein. Other methods that could apply to (1.7) include the flow averaging integrators (FLAVORS) [48] and the HMM with Poincaré map technique [1]. To design the uniformly accurate (UA) schemes for solving (1.7) for all \(0<\varepsilon \le 1,\) there are two approaches. One is the two-scaled formulation [14] which extends the problem with another degree-of-freedom. The other one is the multiscale time integrator which is based on some asymptotic expansion of the solution [3, 5,6,7].

Table 1 Relations between different quantities by the scaling (1.8) in the two types of problems (1.3) and (1.7)

In this paper, we are going to propose and study some multiscale time integrators (MTIs) for solving the energy unbounded model problem (1.7) in the highly oscillatory regime. The basic tools we are utilizing here are the modulated Fourier expansion which is well-known as a fundamental framework for solving and analyzing highly oscillatory differential equations [19, 21,22,23,24, 41, 42, 47]. We shall apply the expansion to the solution at every time step and decompose the equations according to the \(\varepsilon \) amplitude and frequency, which is different from the usual way of applying the modulated Fourier expansion. We find out not only the leading order terms in the modulated Fourier expansion, but also take care of the remainder’s equation with proper numerical integrators. The strategy has been used before in [3, 5,6,7]. However, unlike the previous work, for the model (1.7) we are able to identify the leading order term exactly and approximate the oscillatory remainder with uniform accuracy, which essentially benefit us in the end to reach a uniform second order accuracy. On the contrast, for the problem studied in [3, 5,6,7], only a uniform first order accuracy is achieved. For the polynomial type nonlinearity case in (1.7), we use the exponential integrators to get the remainder. As for general nonlinearity case, under the assumption that the diagonal entries of \(\varLambda \) are multiples of a generic constant \(\alpha >0\), we apply the stroboscopic like numerical integrator [8,9,10, 29, 30]. The proposed MTIs are explicit, easy to implement and have uniformly second order convergence in the absolute position error for solving (1.1) with (1.7), which in turn shows the MTIs can give uniformly second order convergence in the relative position error for the energy bounded model (1.3). We remark that for the general nonlinearity with multiple irrational frequencies case, designing and analyzing uniformly accurate integrators in the highly-oscillatory regime are very challenging. We refer to [11] for some recent progress which makes use of Diophantine approximation from number theory.

The rest of the paper is organized as follows. In Sect. 2, we shall propose the MTIs based on the multiscale decomposition. In Sect. 3, we shall give the main convergence theorem and the proof. Numerical results and comparisons are given in Sect. 4 followed by conclusions drawn in Sect. 5. Throughout this paper, we use the notation \(A\lesssim B\) for two scalars A and B to represent that there exists a generic constant \(C>0\), which is independent of time step \(\tau \) (or n) and \(\varepsilon \), such that \(|A|\le CB\), and all the absolute value of a vector \(|\mathbf {y}|\) is interpreted as the standard Euclidian norm.

2 Numerical schemes

Now assume \(0<\varepsilon \le 1\) and we are solving the energy unbounded model problem (1.7) which we write it down again for readers’ convenience.

$$\begin{aligned}\left\{ \begin{aligned}&\ddot{\mathbf {y}}(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {y}(t)+\mathbf {f}(\mathbf {y}(t))=0,\quad t>0,\\&\mathbf {y}(0)=\mathbf {\phi }_0,\quad \dot{\mathbf {y}}(0)=\frac{\mathbf {\phi }_1}{\varepsilon }. \end{aligned}\right. \end{aligned}$$

To keep us away from extra troubles in presenting the core of our method, we first assume \(\varLambda \) is positive definite and later we will come to discuss the case when \(\varLambda \) has some zero entries.

Take \(\tau =\Delta t>0\) and denote \(t_n=n\tau \) for \(n=0,1,\ldots ,\). With

$$\begin{aligned} \mathbf {y}(t_n)=\phi _0^n=O(1),\quad \dot{\mathbf {y}}(t_n)=\frac{\phi _1^n}{\varepsilon }=O\left( \frac{1}{\varepsilon }\right) ,\quad n\ge 0, \end{aligned}$$
(2.1)

for \(t=t_n+s\), we take ansatz of the solution, which is known as the modulated Fourier expansion, as

$$\begin{aligned} \mathbf {y}(t_n+s)=\mathrm {e}^{\frac{i s}{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i s}{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n(s),\quad 0\le s\le \tau , \end{aligned}$$
(2.2)

where \(\mathbf {r}^n(s)=(r_1^n(s),\ldots ,r_d^n(s))^\mathrm {T}\in \mathbb {R}^d\) and \(\mathbf {z}^n=(z_1^n,\ldots ,z_d^n)^\mathrm {T}\in \mathbb {C}^d\) is independent of time. Here and after, the exponential function of a matrix A is interpreted as \(\mathrm {e}^A:=\sum \nolimits _{n=0}^\infty \frac{A^n}{n!}\). Plugging the ansatz back to (1.7), we get

$$\begin{aligned} {\ddot{\mathbf {r}}}^n(s)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {r}^n(s)+\mathbf {f}\left( \mathrm {e}^{\frac{i s}{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i s}{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n(s)\right) =0,\quad 0\le s\le \tau . \end{aligned}$$
(2.3)

With \(s=0\) in (2.2) and the derivative of (2.2) with respect to s, we find

$$\begin{aligned} \mathbf {y}(t_n)=\mathbf {z}^n+\overline{\mathbf {z}}^n+\mathbf {r}^n(0)=\phi _0^n,\quad \dot{\mathbf {y}}(t_n)=\frac{i}{\varepsilon }\varLambda \left( \mathbf {z}^n-\overline{\mathbf {z}}^n\right) +\dot{\mathbf {r}}^n(0)=\frac{\phi _1^n}{\varepsilon }. \end{aligned}$$

We choose \(\mathbf {r}^n(0)={\dot{\mathbf {r}}}^n(0)=0\) to keep the remainder \(\mathbf {r}^n(s)\) as small as possible, and then by matching the \(O(\frac{1}{\varepsilon })\) and O(1) terms in the second equation, we get

$$\begin{aligned} \mathbf {z}^n+\overline{\mathbf {z}}^n=\phi _0^n,\quad \mathbf {z}^n-\overline{\mathbf {z}}^n=-i\varLambda ^{-1}\phi _1^n. \end{aligned}$$

Solving the above equations we get

$$\begin{aligned} \left\{ \begin{aligned}&\mathbf {z}^n=\frac{1}{2}\left( \phi _0^n-i\varLambda ^{-1}\phi _1^n\right) ,\\&\mathbf {r}^n(0)=0,\quad \quad {\dot{\mathbf {r}}}^n(0)=0. \end{aligned}\right. \end{aligned}$$
(2.4)

Then by using the variation-of-constant formula to (2.3), we get

$$\begin{aligned} \begin{aligned} \mathbf {r}^n(s)=&-\varepsilon \varLambda ^{-1}\int _0^s\sin \left( \frac{\varLambda }{\varepsilon }(s\!-\! \theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n\!+\!\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\!+\!\mathbf {r}^n(\theta )\right) \mathrm {d}\theta ,\ \ 0\le s\le \tau . \end{aligned} \end{aligned}$$

Taking derivative with respect to s on both sides of above equation, we get

$$\begin{aligned}\begin{aligned} {\dot{\mathbf {r}}}^n(s)=&-\int _0^s\cos \left( \frac{\varLambda }{\varepsilon }(s-\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n(\theta )\right) \mathrm {d}\theta ,\ \ 0\le s\le \tau . \end{aligned} \end{aligned}$$

Let \(s=\tau \), we then get

$$\begin{aligned} \left\{ \begin{aligned} \ \mathbf {r}^n(\tau )=&-\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i \theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n(\theta )\right) \mathrm {d}\theta ,\\ {\dot{\mathbf {r}}}^n(\tau )=&-\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n(\theta )\right) \mathrm {d}\theta . \end{aligned}\right. \end{aligned}$$
(2.5)

Now we can see in the modulated expansion (2.2), we have found out the leading order term \(\mathbf {z}^n=O(1)\) exactly and the unknowns become the next order terms which are denoted as the remainder \(\mathbf {r}^n(s)\) satisfying the equations (2.3). From (2.5), we can see clearly \(\mathbf {r}^n(s)=O(\varepsilon ),\,{\dot{\mathbf {r}}}^n(s)=O(1)\). Thus, though the equations (2.3) of the remainder are similar to the original problem (1.7), the oscillation amplitude is reduced. Based on (2.5), we can start to design numerical integrators hoping to get uniform convergence. The numerical integrator is designed in two different cases. One is when the nonlinearity is polynomial type, the other is when \(\varLambda \) is a multiple of a single frequency but for general nonlinearity.

Once we obtain the approximations of \(\mathbf {r}^n(\tau )\) and \({\dot{\mathbf {r}}}^n(\tau )\), then we use the ansatz to recover the approximations of \(\mathbf {y}^{n+1}\) and \({\dot{\mathbf {y}}}^{n+1}\), i.e.

$$\begin{aligned}\left\{ \begin{aligned}&\mathbf {y}(t_{n+1})=\mathrm {e}^{\frac{i\tau }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\tau }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n(\tau )=:\phi _0^{n+1},\\&\dot{\mathbf {y}}(t_{n+1})=\frac{i\varLambda }{\varepsilon }\left( \mathrm {e}^{\frac{i\tau }{\varepsilon }\varLambda }\mathbf {z}^n- \mathrm {e}^{-\frac{i\tau }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) +\dot{\mathbf {r}}^n(\tau )=:\frac{\phi _1^{n+1}}{\varepsilon }. \end{aligned}\right. \end{aligned}$$

At each time step, the algorithm proceeds as a decomposition-solution-reconstruction flow [3, 5, 6]. We refer to the numerical integrators proposed the following based on the multiscale decomposition (2.2) as multiscale time integrators (MTIs).

Remark 2.1

We remark that the above multiscale decomposition also shows the average of the problem (1.7). One can consider the expansion (2.2) as

$$\begin{aligned} \mathbf {y}(t)=\mathrm {e}^{\frac{i t}{\varepsilon }\varLambda }\mathbf {z}^0+\mathrm {e}^{-\frac{i t}{\varepsilon }\varLambda }\overline{\mathbf {z}}^0+\mathbf {r}(t),\quad t\ge 0. \end{aligned}$$

Hence with \(\mathbf {r}(t)=O(\varepsilon )\) from (2.5), we see that formally for a fixed \(t>0\), as \(\varepsilon \rightarrow 0\), \(\mathbf {y}(t)\) converges to \(\mathrm {e}^{\frac{i t}{\varepsilon }\varLambda }\mathbf {z}^0+\mathrm {e}^{-\frac{i t}{\varepsilon }\varLambda }\overline{\mathbf {z}}^0\) which solves the linear model in (1.11). At last, by using the setup in example (4.2), we show in Fig. 3 the dynamics of \(\mathbf {r}(t)\) which solves

$$\begin{aligned}\left\{ \begin{aligned}&{\ddot{\mathbf {r}}}(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {r}(t)+\mathbf {f}\left( \mathrm {e}^{\frac{i t}{\varepsilon }\varLambda }\mathbf {z}+\mathrm {e}^{-\frac{i t}{\varepsilon }\varLambda }\overline{\mathbf {z}}+\mathbf {r}(t)\right) =0,\quad t>0,\\&\mathbf {r}(0)={\dot{\mathbf {r}}}(0)=\mathbf {0},\quad \mathbf {z}=\frac{1}{2}\left( \phi _0-i\varLambda ^{-1}\phi _1\right) . \end{aligned}\right. \end{aligned}$$
Fig. 3
figure 3

Absolute value of the solution \(\mathbf {r}(t)\) under different \(\varepsilon \)

2.1 MTIs for polynomial case

We begin with the case that the nonlinearity \(\mathbf {f}\) is polynomial type, where we can find out the explicit dependence of \(\mathbf {f}(\mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n)\) on the fast variable \(\frac{\theta }{\varepsilon }\), in particular for the leading order part \(\mathbf {f}(\mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n)\) for

$$\begin{aligned} \varLambda =\left( \begin{array}{ccc} \omega _1&{}\ &{}\ \\ \ &{}\ddots &{}\ \\ \ &{}\ &{}\omega _d\end{array}\right) , \end{aligned}$$

with \(\omega _1,\ldots ,\omega _d>0\) independent of \(\varepsilon \).

We denote for \(j=1,\ldots ,d\),

$$\begin{aligned} f_j\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n\right) =f_j\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) +h_j\left( \mathbf {z}^n,\mathbf {r}^n,\theta \right) , \end{aligned}$$
(2.6)

and further we can find

$$\begin{aligned} f_j\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) =\sum _{m_j}\mathrm {e}^{\frac{i\theta }{\varepsilon } L_{m_j}}g_{m_j}\left( \mathbf {z}^n,\overline{\mathbf {z}}^n\right) , \end{aligned}$$
(2.7)

where \(\displaystyle L_{m_j}=\sum \nolimits _{l=1}^dn_{l}^{(m_j)}\omega _l,\ n_{l}^{(m_j)}\in \mathbb {N}\) and \(g_{m_j}\) is a pure power function of \(\mathbf {z}^n\) and \(\overline{\mathbf {z}}^n\), i.e.

$$\begin{aligned} g_{m_j}\left( \mathbf {z}^n,\overline{\mathbf {z}}^n\right) =\lambda _{m_j}\prod _{l}^d(z_l^n)^{p_l^{(m_j)}}(\overline{z_l}^n)^{q_l^{(m_j)}},\quad p_l^{(m_j)}-q_l^{(m_j)}=n_{l}^{(m_j)}, \end{aligned}$$
(2.8)

with \(p_l^{(m_j)},q_l^{(m_j)}\in \mathbb {N},\ \lambda _{m_j}\in \mathbb {R}\). Then the integral in (2.5) becomes

$$\begin{aligned}&\int _0^\tau \sin \left( \frac{\omega _j}{\varepsilon }(\tau -\theta )\right) \mathbf {f}_j\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon } \varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n(\theta )\right) \mathrm {d}\theta \nonumber \\&\quad =\sum _{m_j}\int _0^\tau \sin \left( \frac{\omega _j}{\varepsilon }(\tau -\theta )\right) \mathrm {e}^{\frac{i\theta }{\varepsilon }L_{m_j}}\mathrm {d}\theta \cdot g_{m_j}\left( \mathbf {z}^n,\overline{\mathbf {z}}^n\right) \nonumber \\&\quad \quad + \int _0^\tau \sin \left( \frac{\omega _j}{\varepsilon }(\tau -\theta )\right) h_j\left( \mathbf {z}^n,\mathbf {r}^n(\theta ),\theta \right) \mathrm {d}\theta \nonumber \\&\quad =\sum _{m_j}C_{m_j}\cdot g_{m_j}\left( \mathbf {z}^n,\overline{\mathbf {z}}^n\right) + \int _0^\tau \sin \left( \frac{\omega _j}{\varepsilon }(\tau -\theta )\right) h_j\left( \mathbf {z}^n,\mathbf {r}^n(\theta ),\theta \right) \mathrm {d}\theta , \end{aligned}$$
(2.9)

where

$$\begin{aligned} C_{m_j}=C_{m_j}(\tau ):=\int _0^\tau \sin \left( \frac{\omega _j}{\varepsilon }(\tau -\theta )\right) \mathrm {e}^{\frac{i\theta }{\varepsilon }L_{m_j}}\mathrm {d}\theta , \end{aligned}$$

can be obtained exactly. For the last unknown integral in (2.9) which depends on \(\mathbf {r}^n(\theta )\), noticing that from (2.13) we have

$$\begin{aligned} \left| h_j\left( \mathbf {z}^n,\mathbf {r}^n,\theta \right) \right| = \left| \int _0^1\nabla f_j\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon } \varLambda }\overline{\mathbf {z}}^n+\rho \mathbf {r}^n\right) d\rho \,\mathbf {r}^n\right| =O(\varepsilon ), \end{aligned}$$

so we simply apply the standard single step trapezoidal rule to approximate it. Noting (2.4) and \(h_j(\mathbf {z}^n,\mathbf {0},0)=0\), all together in (2.5) we get for each \(j=1,\ldots ,d,\)

$$\begin{aligned} r_j^n(\tau )\approx -\frac{\varepsilon }{\omega _j}\sum _{m_j}C_{m_j}\cdot g_{m_j}\left( \mathbf {z}^n,\overline{\mathbf {z}}^n\right) . \end{aligned}$$

Similarly, we have

$$\begin{aligned} \dot{r}_j^n(\tau )\approx -\sum _{m_j}\dot{C}_{m_j}\cdot g_{m_j}\left( \mathbf {z}^n,\overline{\mathbf {z}}^n\right) - \frac{\tau }{2}h_j(\mathbf {z}^n,r_j^n(\tau ),\tau ), \end{aligned}$$

with

$$\begin{aligned} \dot{C}_{m_j}=\dot{C}_{m_j}(\tau ):=\int _0^\tau \cos \left( \frac{\omega _j}{\varepsilon }(\tau -\theta )\right) \mathrm {e}^{\frac{i\theta }{\varepsilon }L_{m_j}}\mathrm {d}\theta . \end{aligned}$$

Then the detailed numerical scheme of the MTI for the polynomial type nonlinearity case reads as follows.

For \(n\ge 0\), let \(\mathbf {y}^n\) and \({\dot{\mathbf {y}}}^n\) be the approximations of \(\mathbf {y}(t_n)\) and \({\dot{\mathbf {y}}}(t_n)\), \(\mathbf {r}^{n+1}=(r_1^{n+1},\ldots ,r_d^{n+1})^\mathrm {T}\) and \({\dot{\mathbf {r}}}^{n+1}=(\dot{r}_1^{n+1},\ldots ,\dot{r}_d^{n+1})^\mathrm {T}\) be the approximations of \(\mathbf {r}^{n}(\tau )\) and \({\dot{\mathbf {r}}}^{n}(\tau )\), and \(Z^n\) be \(\mathbf {z}^n\), respectively. Choosing \(\mathbf {y}^0=\mathbf {y}(0)= \phi _0\), \({\dot{\mathbf {y}}}^0={\dot{\mathbf {y}}}(0)=\frac{\phi _1}{\varepsilon }\), for \(n\ge 0\), \(\mathbf {y}^{n+1}\) and \({\dot{\mathbf {y}}}^{n+1}\) are updated as

$$\begin{aligned} \left\{ \begin{aligned}&\mathbf {y}^{n+1}=\mathrm {e}^{\frac{i\tau }{\varepsilon }\varLambda }Z^n+\mathrm {e}^{-\frac{i\tau }{\varepsilon }\varLambda }\overline{Z}^n+\mathbf {r}^{n+1},\\&\dot{\mathbf {y}}^{n+1}=\frac{i\varLambda }{\varepsilon }\left( \mathrm {e}^{\frac{i\tau }{\varepsilon }\varLambda }Z^n- \mathrm {e}^{-\frac{i\tau }{\varepsilon }\varLambda }\overline{Z}^n\right) +\dot{\mathbf {r}}^{n+1}, \end{aligned}\right. \end{aligned}$$
(2.10)

where

$$\begin{aligned} Z^n&=\frac{1}{2}\left( \mathbf {y}^n-i\varepsilon \varLambda ^{-1}{\dot{\mathbf {y}}}^n\right) , \end{aligned}$$
(2.11a)
$$\begin{aligned} r_j^{n+1}&=-\frac{\varepsilon }{\omega _j}\sum _{m_j}C_{m_j}\cdot g_{m_j}\left( Z^n,\overline{Z}^n\right) , \end{aligned}$$
(2.11b)
$$\begin{aligned} \dot{r}_j^{n+1}&=-\sum _{m_j}\dot{C}_{m_j}\cdot g_{m_j}\left( Z^n,\overline{Z}^n\right) - \frac{\tau }{2}h_j(Z^n,\mathbf {r}^{n+1},\tau ),\quad j=1,\ldots ,d. \end{aligned}$$
(2.11c)

2.2 MTIs for general nonlinearity case

Next we consider the case for general nonlinearity but under the assumption that \(\varLambda \) is a multiply of a single frequency \(\alpha >0\), i.e.

$$\begin{aligned} \varLambda =\left( \begin{array}{ccc} \omega _1&{}\ &{}\ \\ \ &{}\ddots &{}\ \\ \ &{}\ &{}\omega _d\end{array}\right) =\alpha \left( \begin{array}{ccc} n_1&{}\ &{}\ \\ \ &{}\ddots &{}\ \\ \ &{}\ &{}n_d\end{array}\right) =:\alpha D,\quad n_1,\ldots ,n_d\in \mathbb {N}^+. \end{aligned}$$
(2.12)

We also introduce the function,

$$\begin{aligned} \mathbf {h}(\mathbf {z}^n,\mathbf {r}^n(\theta ),\theta ):=\mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n(\theta )\right) -\mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) , \end{aligned}$$
(2.13)

for \(n\ge 0\) and \(0\le \theta \le \tau \), and we rewrite (2.3) as

$$\begin{aligned} \mathbf {r}^n(\tau )= & {} -\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) \mathrm {d}\theta \nonumber \\&-\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {h}(\mathbf {z}^n,\mathbf {r}^n(\theta ),\theta )\mathrm {d}\theta ,\end{aligned}$$
(2.14a)
$$\begin{aligned} {\dot{\mathbf {r}}}^n(\tau )= & {} -\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) \mathrm {d}\theta \nonumber \\&-\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {h}(\mathbf {z}^n,\mathbf {r}^n(\theta ),\theta )\mathrm {d}\theta . \end{aligned}$$
(2.14b)

For the second integral term on the right hand side of (2.14a) or (2.14b), we do the single step trapezoidal rule as before. As for the first integral, we do a change of variable \(s=\frac{\alpha \theta }{\varepsilon }\) and denote \(\frac{\alpha \tau }{2\pi \varepsilon }=m+\gamma \) with \(m\in \mathbb {N},\, 0\le \gamma <1\), then

$$\begin{aligned}&\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) \mathrm {d}\theta \\&\quad =\frac{\varepsilon }{\alpha }\int _0^{\frac{\alpha \tau }{\varepsilon }}\sin \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {f}\left( \mathrm {e}^{i s D}\mathbf {z}^n+\mathrm {e}^{-i s D}\overline{\mathbf {z}}^n\right) \mathrm {d}s\quad \\&\quad =\frac{\varepsilon }{\alpha }\sum _{l=0}^{m-1}\int _{2\pi l}^{2\pi (l+1)}\sin \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {f}\left( \mathrm {e}^{i s D}\mathbf {z}^n+\mathrm {e}^{-i s D}\overline{\mathbf {z}}^n\right) \mathrm {d}s\\&\quad \quad +\frac{\varepsilon }{\alpha } \int _{2\pi m}^{2\pi m+2\pi \gamma }\sin \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {f}\left( \mathrm {e}^{i s D}\mathbf {z}^n+\mathrm {e}^{-i s D}\overline{\mathbf {z}}^n\right) \mathrm {d}s. \end{aligned}$$

Due to the periodicity and denoting \(\mathbf {g}\left( \mathbf {z}^n,s\right) :=\mathbf {f}\left( \mathrm {e}^{i s D}\mathbf {z}^n+\mathrm {e}^{-i s D}\overline{\mathbf {z}}^n\right) \), we get

$$\begin{aligned}&\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) \mathrm {d}\theta \\&\quad =\frac{m\varepsilon }{\alpha }\int _{0}^{2\pi }\sin \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {g}\left( \mathbf {z}^n,s\right) \mathrm {d}s +\frac{\varepsilon }{\alpha } \int _{0}^{2\pi \gamma }\sin \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {g}\left( \mathbf {z}^n,s\right) \mathrm {d}s.\nonumber \end{aligned}$$
(2.15)

Similarly,

$$\begin{aligned}&\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau \!-\!\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) \mathrm {d}\theta \\&\quad =\frac{m\varepsilon }{\alpha }\int _{0}^{2\pi }\cos \left( \frac{\varLambda }{\varepsilon }\tau \!-\! D s\right) \mathbf {g} \left( \mathbf {z}^n,s\right) \mathrm {d}s \!+\!\frac{\varepsilon }{\alpha } \int _{0}^{2\pi \gamma }\cos \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {g}\left( \mathbf {z}^n,s\right) \mathrm {d}s.\nonumber \end{aligned}$$
(2.16)

Now the functions in the integrals (2.15) and (2.16) become smooth in terms of s. Though the explicit formulas of (2.15) and (2.16) are not available for general \(\mathbf {f}\), with \(\mathbf {z}^n\) known, they can be approximated very accurately with error bounds independent of \(\varepsilon \). Here since the first integral part in (2.15) or (2.16) is over a complete period, so we apply the composite trapezoidal rule which can efficiently offer spectral accuracy as

$$\begin{aligned}&\int _{0}^{2\pi }\sin \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {g}\left( \mathbf {z}^n,s\right) \mathrm {d}s\nonumber \\&\quad \approx \frac{2\pi }{M}\sum _{j=0}^{M-1}\sin \left( \frac{\varLambda }{\varepsilon }\tau - D s_j\right) \mathbf {g}\left( \mathbf {z}^n,s_j\right) =:\mathbf {I}_1(\mathbf {z}^n),\end{aligned}$$
(2.17a)
$$\begin{aligned}&\int _{0}^{2\pi }\cos \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {g}\left( \mathbf {z}^n,s\right) \mathrm {d}s\nonumber \\&\quad \approx \frac{2\pi }{M}\sum _{j=0}^{M-1}\cos \left( \frac{\varLambda }{\varepsilon }\tau - D s_j\right) \mathbf {g}\left( \mathbf {z}^n,s_j\right) =:\mathbf {J}_1(\mathbf {z}^n), \end{aligned}$$
(2.17b)

with \(s_j=\frac{2\pi j}{M}\) and \(M\in \mathbb {N}\) chosen sufficiently large such that the truncation error of the quadrature is negligible. For the second integral in (2.15) or (2.16), we can do further transformation and use the Gauss-Legendre quadrature which is also spectrally accurate as

$$\begin{aligned}&\int _{0}^{2\pi \gamma }\sin \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {g}\left( \mathbf {z}^n,s\right) \mathrm {d}s\nonumber \\&\quad =\pi \gamma \int _{-1}^{1}\sin \left( \frac{\varLambda }{\varepsilon }\tau -\pi \gamma D(x+1)\right) \mathbf {g}\left( \mathbf {z}^n,\pi \gamma (x+1)\right) \mathrm {d}x\nonumber \\&\quad \approx \pi \gamma \sum _{j=1}^{M}\nu _j\sin \left( \frac{\varLambda }{\varepsilon }\tau -\pi \gamma D(x_j+1)\right) \mathbf {g}\left( \mathbf {z}^n,\pi \gamma (x_j+1)\right) =:\mathbf {I}_2(\mathbf {z}^n),\nonumber \\\end{aligned}$$
(2.18a)
$$\begin{aligned}&\int _{0}^{2\pi \gamma }\cos \left( \frac{\varLambda }{\varepsilon }\tau - D s\right) \mathbf {g}\left( \mathbf {z}^n,s\right) \mathrm {d}s\nonumber \\&\quad =\pi \gamma \int _{-1}^{1}\cos \left( \frac{\varLambda }{\varepsilon }\tau -\pi \gamma D(x+1)\right) \mathbf {g}\left( \mathbf {z}^n,\pi \gamma (x+1)\right) \mathrm {d}x \nonumber \\&\quad \approx \pi \gamma \sum _{j=1}^{M}\nu _j\cos \left( \frac{\varLambda }{\varepsilon }\tau -\pi \gamma D(x_j+1)\right) \mathbf {g}\left( \mathbf {z}^n,\pi \gamma (x_j+1)\right) =:\mathbf {J}_2(\mathbf {z}^n),\nonumber \\ \end{aligned}$$
(2.18b)

where \(x_j\) for \(j=1,\ldots ,M,\) is the j-th root of the Legendre polynomial \(P_M(x)\) and \(\nu _j\) is the associated weight. Again we choose M large enough such that all the approximations here are ‘accurate’. Note that the integrals in both (2.17) and (2.18) are for functions without any large frequencies on O(1) intervals. The errors from the quadratures are uniformly bounded with respect to \(\varepsilon \). Hence, M can be chosen independently from \(\varepsilon \). Moreover, if the nonlinearity \(\mathbf {f}\) is smooth, then thanks to the spectral accuracy of the used quadratures, the practical demand on \(M\in \mathbb {N}\) to reach high accuracy is not severe.

Then the detailed numerical scheme of the MTI in this case reads as follows. For \(n\ge 0\), let \(\mathbf {y}^n\) and \({\dot{\mathbf {y}}}^n\) be the approximations of \(\mathbf {y}(t_n)\) and \({\dot{\mathbf {y}}}(t_n)\), \(\mathbf {r}^{n+1}\) and \({\dot{\mathbf {r}}}^{n+1}\) be the approximations of \(\mathbf {r}^{n}(\tau )\) and \({\dot{\mathbf {r}}}^{n}(\tau )\), and \(Z^n\) be \(\mathbf {z}^n\), respectively. Choosing \(\mathbf {y}^0=\mathbf {y}(0)= \phi _0\), \({\dot{\mathbf {y}}}^0={\dot{\mathbf {y}}}(0)=\frac{\phi _1}{\varepsilon }\), for \(n\ge 0\), \(\mathbf {y}^{n+1}\) and \({\dot{\mathbf {y}}}^{n+1}\) are updated the same as (2.10)–(2.11a), but with

$$\begin{aligned} \mathbf {r}^{n+1}= & {} -\frac{\varepsilon ^2}{\alpha }\varLambda ^{-1}\left( m\mathbf {I}_1(Z^n)+\mathbf {I}_2(Z^n)\right) ,\end{aligned}$$
(2.19a)
$$\begin{aligned} {\dot{\mathbf {r}}}^{n+1}= & {} -\frac{\varepsilon }{\alpha }\left( m\mathbf {J}_1(Z^n)+\mathbf {J}_2(Z^n)\right) -\frac{\tau }{2}\mathbf {h}(Z^n,\mathbf {r}^{n+1},\tau ), \end{aligned}$$
(2.19b)

where \(\mathbf {I}_1,\mathbf {I}_2,\mathbf {J}_1,\mathbf {J}_2\) are defined in (2.17) and (2.18).

It is clear that the proposed MTI (2.10) with (2.11) or (2.19) is fully explicit and easy to implement in practice. We remark that the ansatz (2.2) we used is just a modulated Fourier expansion of the solution \(\mathbf {y}(t_n+s)\) for \(s\in [0,\tau ]\). The solution is expanded at every time grid, thus it is different from the standard use of the modulated Fourier expansion in the studies of oscillatory equations in [19, 21, 22, 41].

We remark that when the nonlinearity \(\mathbf {f}\) in this case is taken as a polynomial type function, then the practical computational results of the MTI (2.19) is indeed the same as the MTI (2.11) derived for the polynomial case in Sect. 2.1. This is because both numerical schemes evaluate the leading order oscillatory part of the solution exactly or very accurately, and approximate the remainder by the same way. From computational cost point of view, the MTI (2.19) is more expensive than the MTI (2.11), since the MTI (2.19) for the general case needs to compute the integrals \(I_j\) and \(J_j\,(j=1,2)\) at each time level by quadratures, while in MTI (2.11) the integral coefficients \(C_{m_j}\) and \(\dot{C}_{m_j}\) are computed once for all. Thus, when both (2.19) and (2.11) are applicable, we would recommend the MTI (2.11) for the polynomial case.

We summarize here the schemes proposed so far which are the main algorithm for solving (1.7). The rest part of this section will discuss two practical situations as complements to the main algorithm.

figure a

2.3 Two scales in the linear part

At last, we write this subsection as a short note for the case

$$\begin{aligned} \ddot{\mathbf {y}}(t)+A\mathbf {y}(t)+\mathbf {f}(\mathbf {y}(t))=0,\quad t>0, \end{aligned}$$
(2.20)

where in the linear oscillatory part, the matrix A has two different scales, i.e.

$$\begin{aligned} A=\left( \begin{array}{cc} \frac{1}{\varepsilon ^2}\varLambda ^2&{}\ \\ \ &{} M^2\end{array}\right) \in \mathbb {R}^{d\times d}. \end{aligned}$$

Here \(\varLambda \in \mathbb {R}^{d_1\times d_1}\) is similar as before with all positive entries kept away from zero as \(\varepsilon \rightarrow 0\), and \(M\in \mathbb {R}^{d_2\times d_2}\, (d_1+d_2=d)\) is a non-negative matrix independent of \(\varepsilon .\) In this situation, the highly oscillatory part and the non-oscillatory part in (2.20) are separated. Denoting the solution \(\mathbf {y}=(\mathbf {y}_O,\mathbf {y}_N)^\mathrm {T}\) with \(\mathbf {y}_O\in \mathbb {R}^{d_1}\) and \(\mathbf {y}_N\in \mathbb {R}^{d_2}\), and \(\mathbf {f}=(\mathbf {f}_O,\mathbf {f}_N)^\mathrm {T},\) with \(\mathbf {f}_O\in \mathbb {R}^{d_1}\) and \(\mathbf {f}_N\in \mathbb {R}^{d_2}\), (2.20) becomes

$$\begin{aligned} \left\{ \begin{aligned}&\ddot{\mathbf {y}}_O(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {y}_O(t)+\mathbf {f}_O(\mathbf {y}_O(t),\mathbf {y}_N(t))=0,\\&\ddot{\mathbf {y}}_N(t)+M^2\mathbf {y}_N(t)+\mathbf {f}_N(\mathbf {y}_O(t),\mathbf {y}_N(t))=0,\quad t>0. \end{aligned}\right. \end{aligned}$$
(2.21)

Then one can apply the expansion (2.2) to the oscillatory part \(\mathbf {y}_O(t_n+s)\) and carry out the same decomposition as used before. Whenever the approximation to the non-oscillatory part \(\mathbf {y}_N(t_n+s)\) is needed, since it is smooth so one can apply any quadratures, for example the Gautschi’s type quadrature,

$$\begin{aligned} \mathbf {y}_N(t_n+s)\approx \mathbf {y}_N(t_n)+s{\dot{\mathbf {y}}}_N(t_n), \end{aligned}$$

for a second order of accuracy. Then for the polynomial case discussed in Sect. 2.1, it is straightforward to derive an MTI with uniform convergence. As for the general case in Sect. 2.2, one can use

$$\begin{aligned}&\mathbf {f}(\mathbf {y}_O(t_n+s),\mathbf {y}_N(t_n+s))=\mathbf {f}(\mathbf {y}_O(t_n+s),\mathbf {y}_N(t_n)+s{\dot{\mathbf {y}}}_N(t_n)+O(s^2))\\&\quad =\mathbf {f}(\mathbf {y}_O(t_n+s),\mathbf {y}_N(t_n))+s\nabla _{\mathbf {y}_N}\mathbf {f}(\mathbf {y}_O(t_n+s),\mathbf {y}_N(t_n)){\dot{\mathbf {y}}}_N(t_n) +O(s^2), \end{aligned}$$

in order to make it easier to evaluate the integration of the oscillatory but periodic part.

2.4 With source terms

The above MTIs in Sects. 2.1 and 2.2 can be extended to study the second order oscillatory ODEs with a source term. The problem reads

$$\begin{aligned} \left\{ \begin{aligned}&\ddot{\mathbf {y}}(t)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {y}(t)+\mathbf {f}(\mathbf {y}(t))=\mathbf {s}(t),\quad t>0,\\&\mathbf {y}(0)=\mathbf {\phi }_0,\quad \dot{\mathbf {y}}(0)=\frac{\mathbf {\phi }_1}{\varepsilon }. \end{aligned}\right. \end{aligned}$$
(2.22)

where the source term \(\mathbf {s}(t)\) is given as

$$\begin{aligned} \mathbf {s}(t)=\sum _{l=1}^M\mathbf {a}_l(t)\mathrm {e}^{i\upsilon _lt},\quad M\in \mathbb {N}, \end{aligned}$$
(2.23)

with \(\mathbf {a}_l(t)\in \mathbb {R}^d\) a smooth function and \(\upsilon _l\in \mathbb {R}\). The source term \(\mathbf {s}(t)\) denotes the external force applied to the system and the form (2.23) usually arise from the studies of electronic circuits [15,16,17,18].

Carrying out the decomposition of the differential equations (2.22) based on the same ansatz (2.2) similarly as before, one will end up with

$$\begin{aligned} {\ddot{\mathbf {r}}}^n(s)+\frac{1}{\varepsilon ^2}\varLambda ^2\mathbf {r}^n(s)+\mathbf {f}\left( \mathrm {e}^{\frac{i s}{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i s}{\varepsilon }\varLambda }\overline{\mathbf {z}}^n+\mathbf {r}^n(s)\right) =\mathbf {s}(t_n+s),\quad 0\le s\le \tau , \end{aligned}$$
(2.24)

with initial data (2.4). We will have two additional integrations regarding to the source term in the variation-of-constant formulas, i.e.

$$\begin{aligned} \left\{ \begin{aligned} \mathbf {S}^n=\,&\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {s}\left( t_n+\theta \right) \mathrm {d}\theta \\ =\,&\varepsilon \varLambda ^{-1}\sum _{l=1}^M\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {a}_l\left( t_n+\theta \right) \mathrm {e}^{i\upsilon _l(t_n+\theta )}\mathrm {d}\theta ,\\ \dot{\mathbf {S}}^n=&\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {s}\left( t_n+\theta \right) \mathrm {d}\theta \\ =&\sum _{l=1}^M\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {a}_l\left( t_n+\theta \right) \mathrm {e}^{i\upsilon _l(t_n+\theta )}\mathrm {d}\theta ,\quad n\ge 0. \end{aligned}\right. \end{aligned}$$
(2.25)

From real application point of view, \(\mathbf {a}_l(t)\) are usually simple analytic functions such as polynomials and trigonometric functions [16, 17], where the above integration (2.25) can be either evaluated exactly or approximated as accurate as desired. In this sense, we can always integrate the source term \(\mathbf {S}^n=(S_1^n,\ldots ,S_d^n)\) and \({\dot{\mathbf {S}}}^n=(\dot{S}_1^n,\ldots ,\dot{S}_d^n)\) accurately and uniformly for \(0<\varepsilon \le 1\) and the rest approximations in the MTIs can be done similarly as before.

3 Convergence results

In this section, we shall give the convergence result of the proposed MTIs for solving (1.7) under the two cases. In order to obtain rigorous error estimates, we assume that the exact solution \(\mathbf {y}(t)\) to (1.7) satisfies the following assumptions

$$\begin{aligned} \mathbf {f}\in C^1(\mathbb {R}^d),\quad \mathbf {y}(t)\in C^2(0,T),\quad \hbox {and}\quad \left\| \frac{d^m}{dt^m}\mathbf {y}\right\| _{L^\infty (0,T)}\lesssim \frac{1}{\varepsilon ^{m}},\quad m=0,1,2, \end{aligned}$$
(3.1)

for \(0<T<T^*\) with \(T^*\) the maximum existence time. Denoting

$$\begin{aligned} C_0:=\max \left\{ \Vert \mathbf {y}\Vert _{L^{\infty }(0,T)},\ \varepsilon \Vert \dot{\mathbf {y}}\Vert _{{L^{\infty }(0,T)}}\right\} , \end{aligned}$$
(3.2)

and the error functions as

$$\begin{aligned} \mathbf {e}^n:=\mathbf {y}(t_n)-\mathbf {y}^n,\quad \dot{\mathbf {e}}^n:=\dot{\mathbf {y}}(t_n)-\dot{\mathbf {y}}^n,\quad 0\le n\le \frac{T}{\tau }, \end{aligned}$$
(3.3)

then we have the following error estimates for the MTIs.

Theorem 3.1

(Error bounds of MTIs) For the numerical integrator MTIs, i.e. (2.10) with (2.11) or (2.19), under the assumption (3.1) and \(\varLambda \) is nonsingular, there exits a constant \(\tau _0>0\) independent of \(\varepsilon \) and n, such that for any \(0<\varepsilon \le 1\),

$$\begin{aligned}&|\varLambda \mathbf {e}^n|+\varepsilon |\dot{\mathbf {e}}^n|\lesssim \tau ^2,\quad |\varLambda \mathbf {e}^n|+\varepsilon |\dot{\mathbf {e}}^n|\lesssim \varepsilon ^2,\quad 0<\tau \le \tau _0,\end{aligned}$$
(3.4a)
$$\begin{aligned}&|\mathbf {y}^n|\le C_0+1,\quad |\dot{\mathbf {y}}^n|\le \frac{C_0+1}{\varepsilon }, \quad 0\le n \le \frac{T}{\tau }. \end{aligned}$$
(3.4b)

Here we shall only show the proof of the theorem for the MTI (2.10) with (2.19) for solving (1.7) under the case (2.12), while the other case is similar. To proceed to proof, we first establish some lemmas.

Lemma 3.1

Suppose \(\mathbf {y}^n\) and \({\dot{\mathbf {y}}}^n\) are the numerical solutions from the MTI (2.10) with (2.19), then we have

$$\begin{aligned} \mathbf {y}^{n+1}= & {} \cos \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {y}^n+\varepsilon \varLambda ^{-1}\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {y}}}^n \\&-\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }Z^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon } \varLambda }\overline{Z}^n\right) \mathrm {d}\theta ,\quad 0\le n<\frac{T}{\tau }, \nonumber \end{aligned}$$
(3.5a)
$$\begin{aligned} {\dot{\mathbf {y}}}^{n+1}= & {} -\frac{\varLambda }{\varepsilon }\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {y}^n+\cos \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {y}}}^n\\&-\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }Z^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{Z}^n\right) \mathrm {d}\theta -\frac{\tau }{2}\mathbf {h}(Z^n,\mathbf {r}^{n+1},\tau ).\nonumber \end{aligned}$$
(3.5b)

Proof

First of all, as we remarked before, we assume in (2.19) the quadratures in \(I_j(Z^n),\,J_j(Z^n)(j=1,2)\) are accurate enough to recover

$$\begin{aligned} \begin{aligned} \frac{\varepsilon }{\alpha }\left( m\mathbf {I}_1(Z^n)+\mathbf {I}_2(Z^n)\right)&=\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }Z^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{Z}^n\right) \mathrm {d}\theta ,\\ \frac{\varepsilon }{\alpha }\left( m\mathbf {J}_1(Z^n)+\mathbf {J}_2(Z^n)\right)&=\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }Z^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{Z}^n\right) \mathrm {d}\theta . \end{aligned} \end{aligned}$$
(3.6)

Then plugging (2.11a) into (2.10), we get

$$\begin{aligned} \mathbf {y}^{n+1}=&\cos \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {y}^n+\varepsilon \varLambda ^{-1}\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {y}}}^n +\mathbf {r}^{n+1},\\ {\dot{\mathbf {y}}}^{n+1}=&-\frac{\varLambda }{\varepsilon }\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {y}^n+\cos \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {y}}}^n +{\dot{\mathbf {r}}}^{n+1}. \end{aligned}$$

Then by using (2.19) and (3.6), we get directly the assertion (3.1). \(\square \)

Introducing the local truncation errors based on (3.1) as

$$\begin{aligned} \xi ^n= & {} \mathbf {y}(t_{n+1})- \cos \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {y}(t_n)-\varepsilon \varLambda ^{-1}\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {y}}}(t_n)\nonumber \\&+\,\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) \mathrm {d}\theta ,\end{aligned}$$
(3.7a)
$$\begin{aligned} \dot{\xi }^n= & {} {\dot{\mathbf {y}}}(t_{n+1})+\frac{\varLambda }{\varepsilon }\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {y}(t_n) -\cos \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {y}}}(t_n)\nonumber \\&+\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) \mathrm {d}\theta +\frac{\tau }{2}\mathbf {h}(\mathbf {z}^n,\mathbf {r}^{n}(\tau ),\tau ),\nonumber \\ \end{aligned}$$
(3.7b)

then we have

Lemma 3.2

For the local truncation errors \(\xi ^n\) and \(\dot{\xi }^n\), we have estimates

$$\begin{aligned} |\varLambda \xi ^n|+\varepsilon |\dot{\xi }^n|\lesssim \tau ^3,\quad |\varLambda \xi ^n|+\varepsilon |\dot{\xi }^n|\lesssim \tau \varepsilon ^2,\quad 0\le n<\frac{T}{\tau }. \end{aligned}$$
(3.8)

Proof

Applying the variation-of-constant formula directly to (1.7) for \(t=t_n+s\), we have

$$\begin{aligned} \mathbf {y}(t_{n+1})&= \cos \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {y}(t_n)+\varepsilon \varLambda ^{-1}\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {y}}}(t_n)\nonumber \\&\quad -\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathbf {y}(t_n+\theta )\right) \mathrm {d}\theta , \quad 0\le n<\frac{T}{\tau }. \end{aligned}$$

Using the expansion (2.2) and noticing (2.13), we find

$$\begin{aligned} \mathbf {y}(t_{n+1})&= \cos \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {y}(t_n)+\varepsilon \varLambda ^{-1}\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {y}}}(t_n)\nonumber \\&\quad -\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon }\varLambda }\overline{\mathbf {z}}^n\right) \mathrm {d}\theta \nonumber \\&\quad -\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {h}(\mathbf {z}^n,\mathbf {r}^n(\theta ),\theta )\mathrm {d}\theta . \end{aligned}$$

Now since the leading order oscillatory part is evaluated exactly, so the truncation error is only caused by the single step trapezoidal rule, i.e.

$$\begin{aligned} \xi ^n&=\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {h}(\mathbf {z}^n,\mathbf {r}^n(\theta ),\theta )\mathrm {d}\theta ,\quad 0\le n<\frac{T}{\tau }. \end{aligned}$$
(3.9)

We note that

$$\begin{aligned} \mathbf {h}\left( \mathbf {z}^n,\mathbf {r}^n(\theta ),\theta \right) = \int _0^1\nabla \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon } \varLambda }\overline{\mathbf {z}}^n+\rho \mathbf {r}^n(\theta )\right) \mathrm {d}\rho \,\mathbf {r}^n(\theta ), \end{aligned}$$

and under (3.1) and (2.3),

$$\begin{aligned} \Vert \mathbf {r}^n\Vert _{L^\infty (0,\tau )}+\varepsilon \Vert {\dot{\mathbf {r}}}^n\Vert _{L^\infty (0,\tau )} +\varepsilon ^2\Vert {\ddot{\mathbf {r}}}^n\Vert _{L^\infty (0,\tau )}\lesssim \varepsilon ,\quad 0\le n<\frac{T}{\tau }, \end{aligned}$$

then by using the error formula of trapezoidal rule we get

$$\begin{aligned} |\varLambda \xi ^n|=\left| \varepsilon \frac{\tau ^3}{12}\frac{\mathrm {d}^2}{\mathrm {d}\theta ^2}\left[ \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {h}(\mathbf {z}^n,\mathbf {r}^n(\theta ),\theta )\right] \bigg |_{\theta =\theta ^*\in [0,\tau ]}\right| \lesssim \tau ^3, \end{aligned}$$

or using (3.9) directly we get

$$\begin{aligned} |\varLambda \xi ^n|\lesssim \tau \varepsilon ^2. \end{aligned}$$

Similarly, we can get the results for \(\dot{\xi }^n\) as

$$\begin{aligned} |\dot{\xi }^n|\lesssim \frac{\tau ^3}{\varepsilon },\quad |\dot{\xi }^n|\lesssim \tau \varepsilon , \end{aligned}$$

and the proof is completed. \(\square \)

Next, we introduce the nonlinear errors

$$\begin{aligned}&\eta ^n=\varepsilon \varLambda ^{-1}\int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \Big [\mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }Z^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon } \varLambda }\overline{Z}^n\right) \nonumber \\&\qquad -\mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon }\varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon } \varLambda }\overline{\mathbf {z}}^n\right) \Big ]\mathrm {d}\theta ,\\&\dot{\eta }^n=\int _0^\tau \cos \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \left[ \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }Z^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon } \varLambda }\overline{Z}^n\right) -\mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }\mathbf {z}^n+\mathrm {e}^{-\frac{i\theta }{\varepsilon } \varLambda }\overline{\mathbf {z}}^n\right) \right] \mathrm {d}\theta \\&\qquad +\frac{\tau }{2}\left[ \mathbf {h}(Z^n,\mathbf {r}^{n+1},\tau )- \mathbf {h}(\mathbf {z}^n,\mathbf {r}^{n}(\tau ),\tau )\right] ,\quad 0\le n<\frac{T}{\tau },\nonumber \end{aligned}$$

then we have

Lemma 3.3

For the errors from the nonlinearity \(\eta ^n\) and \(\dot{\eta }^n\), under (3.4b) which will be proven by induction later, we have estimates

$$\begin{aligned} |\varLambda \eta ^n|+\varepsilon |\dot{\eta }^n|\lesssim \tau \left( |\varLambda \mathbf {\mathrm {e}}^n|+\varepsilon |\dot{\mathbf {\mathrm {e}}}^n|\right) +\tau ^3,\quad 0\le n<\frac{T}{\tau }. \end{aligned}$$
(3.10)

Proof

Firstly, under assumption (3.1) and (3.4b), we can easily have

$$\begin{aligned} |\varLambda \eta ^n|&\lesssim \int _0^\tau \int _0^1\left| \nabla \mathbf {f}\left( \mathrm {e}^{\frac{i\theta }{\varepsilon } \varLambda }(\rho (Z^n-\mathbf {z}^n)+\mathbf {z}^n)+\mathrm {e}^{-\frac{i\theta }{\varepsilon } \varLambda }(\rho (\overline{Z}^n-\mathbf {z}^n)+\overline{\mathbf {z}}^n)\right) \right| \\&\mathrm {d}\rho \mathrm {d}\theta |Z^n-\mathbf {z}^n|\lesssim \tau |Z^n-\mathbf {z}^n|\lesssim \tau \left( |\mathbf {\mathrm {e}}^n|+\varepsilon |\dot{\mathbf {\mathrm {e}}}^n|\right) . \end{aligned}$$

Then similarly, together with triangle inequality we get

$$\begin{aligned} |\dot{\eta }^n|&\lesssim \tau \left( |\mathbf {\mathrm {e}}^n|+\varepsilon |\dot{\mathbf {\mathrm {e}}}^n|\right) +\tau \left| \mathbf {h}(Z^n,\mathbf {r}^{n+1},\tau )- \mathbf {h}(\mathbf {z}^n,\mathbf {r}^{n}(\tau ),\tau )\right| \nonumber \\&\lesssim \tau \left( |\mathbf {\mathrm {e}}^n|+\varepsilon |\dot{\mathbf {\mathrm {e}}}^n|\right) +\tau |Z^n-\mathbf {z}^n|+\tau |\mathbf {r}^{n+1}-\mathbf {r}^{n}(\tau )|\nonumber \\&\lesssim \tau \left( |\mathbf {\mathrm {e}}^n|+\varepsilon |\dot{\mathbf {\mathrm {e}}}^n|\right) +\tau |\mathbf {r}^{n+1}-\mathbf {r}^{n}(\tau )|. \end{aligned}$$
(3.11)

Noting (2.3) and (3.1), we have

$$\begin{aligned} |\mathbf {r}^{n+1}-\mathbf {r}^{n}(\tau )|&\lesssim |Z^n-\mathbf {z}^n|+\left| \varepsilon \varLambda ^{-1} \int _0^\tau \sin \left( \frac{\varLambda }{\varepsilon }(\tau -\theta )\right) \mathbf {h}(\mathbf {z}^n,\mathbf {r}^n(\theta ),\theta )\mathrm {d}\theta \right| \\&\lesssim \left( |\mathbf {\mathrm {e}}^n|+\varepsilon |\dot{\mathbf {\mathrm {e}}}^n|\right) +\tau ^2. \end{aligned}$$

Plugging the above estimate back to (3.11), we complete the proof. \(\square \)

Combing the above lemmas, now we can prove the main theorem by the energy method and it is carried out in the framework of mathematical induction in order to guarantee the boundedness of the numerical solutions [3,4,5].

Proof of Theorem 3.1

For \(n=0,\) from the choice of initial data in the scheme, we have

$$\begin{aligned} |\mathbf {e}^0|=0,\quad |\dot{\mathbf {e}}^0|=0, \end{aligned}$$

and results (3.4a) and (3.4b) are obviously true.

Now for \(n\ge 1\), assume (3.4a) and (3.4b) are true for all \(n\le m\le \frac{T}{\tau }-1\), and then we need to show results (3.4a) and (3.4b) are still valid for \(n=m+1\). Subtracting (3.7) from (3.1), we get

$$\begin{aligned}&\mathbf {e}^{n+1}=\cos \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {e}^n+\varepsilon \varLambda ^{-1}\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {e}}}^n+\xi ^n+\eta ^n, \end{aligned}$$
(3.12a)
$$\begin{aligned}&{\dot{\mathbf {e}}}^{n+1}=-\frac{\varLambda }{\varepsilon }\sin \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {e}^n+\cos \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {e}}}^n +\dot{\xi }^n+\dot{\eta }^n, \end{aligned}$$
(3.12b)

Multiplying \(\varLambda \) to the left on both sides of (3.12a) and multiplying (3.12b) by \(\varepsilon \), then taking the inner product with themself, respectively, by the Hölder inequality, we get

$$\begin{aligned} \left| \varLambda \mathbf {e}^{n+1}\right| ^2\le & {} (1+\tau )\left| \varLambda \cos \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {e}^n +\varepsilon \sin \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {e}}}^n\right| ^2\nonumber \\&\quad +\left( 1+\frac{1}{\tau }\right) \left| \varLambda (\xi ^n+\eta ^n)\right| ^2, \end{aligned}$$
(3.13a)
$$\begin{aligned} \varepsilon ^2\left| {\dot{\mathbf {e}}}^{n+1}\right| ^2\le & {} (1+\tau )\left| -\varLambda \sin \left( \frac{\varLambda }{\varepsilon }\tau \right) \mathbf {e}^n +\varepsilon \cos \left( \frac{\varLambda }{\varepsilon }\tau \right) {\dot{\mathbf {e}}}^n\right| ^2\nonumber \\&\quad +\left( 1+\frac{1}{\tau }\right) \varepsilon ^2\left| \dot{\xi }^n+\dot{\eta }^n\right| ^2. \end{aligned}$$
(3.13b)

Adding (3.13b) to (3.13a), with definition

$$\begin{aligned} \mathscr {E}({\dot{\mathbf {e}}}^{n},\mathbf {e}^{n}):=\varepsilon ^2\left| {\dot{\mathbf {e}}}^{n}\right| ^2+\left| \varLambda \mathbf {e}^{n}\right| ^2,\quad 0\le n\le \frac{T}{\tau }, \end{aligned}$$

we get

$$\begin{aligned} \mathscr {E}({\dot{\mathbf {e}}}^{n+1},\mathbf {e}^{n+1})-\mathscr {E}({\dot{\mathbf {e}}}^{n},\mathbf {e}^{n}) \lesssim \tau \mathscr {E}({\dot{\mathbf {e}}}^{n},\mathbf {e}^{n})+\frac{1}{\tau }\mathscr {E}^n(\dot{\xi }^{n}+\dot{\eta }^{n},\xi ^{n}+ \eta ^{n}),\quad 0\le n\le m. \end{aligned}$$
(3.14)

Summing (3.14) up for \(n=0,\ldots ,m\), we get

$$\begin{aligned} \mathscr {E}({\dot{\mathbf {e}}}^{m+1},\mathbf {e}^{m+1})-\mathscr {E}({\dot{\mathbf {e}}}^{0},\mathbf {e}^{0}) \lesssim \tau \sum _{n=0}^{m}\mathscr {E}({\dot{\mathbf {e}}}^{n},\mathbf {e}^{n})+\frac{1}{\tau }\sum _{n=0}^{m}\mathscr {E}^n(\dot{\xi }^{n}+\dot{\eta }^{n},\xi ^{n}+ \eta ^{n}). \end{aligned}$$

Noting \(\mathscr {E}({\dot{\mathbf {e}}}^{0},\mathbf {e}^{0})=0\) and using results from (3.2) and (3.3), we get

$$\begin{aligned} \mathscr {E}({\dot{\mathbf {e}}}^{m+1},\mathbf {e}^{m+1}) \lesssim \tau \sum _{n=0}^{m}\mathscr {E}({\dot{\mathbf {e}}}^{n},\mathbf {e}^{n})+\min \{\tau ^4,\varepsilon ^4\}. \end{aligned}$$

Then by discrete Gronwall’s inequality, we get

$$\begin{aligned} \mathscr {E}({\dot{\mathbf {e}}}^{m+1},\mathbf {e}^{m+1})\lesssim \min \{\tau ^4,\varepsilon ^4\}, \end{aligned}$$

which implies (3.4a) is true for \(n=m+1\). Furthermore, by triangle inequality,

$$\begin{aligned}&|\mathbf {y}^{m+1}|\le |\mathbf {e}^{m+1}|+|\mathbf {y}(t_{m+1})|\le \rho (\varLambda ^{-1})|\varLambda \mathbf {e}^{m+1}|+|\mathbf {y}(t_{m+1})|\le C_0+1,\\&|{\dot{\mathbf {y}}}^{m+1}|\le |{\dot{\mathbf {e}}}^{m+1}|+|{\dot{\mathbf {y}}}(t_{m+1})|\le \frac{C_0+1}{\varepsilon }, \end{aligned}$$

when \(0<\tau \le \tau _0\) for some \(\tau _0>0\) independent of \(\varepsilon \) and n. Thus (3.4b) also holds for \(n=m+1\) and the proof is completed. \(\square \)

Remark 3.2

We remark in the Theorem 3.1 and the proof, we use the assumption the nonlinearity \(\mathbf {f}\) is smooth in \(\mathbb {R}^d\). Thus the error estimates (3.4a) in the Theorem 3.1 do not give any clues about the error bounds of the MTIs for solving the rational type nonlinearities generated by unbond potentials. We will study this case numerically later.

4 Numerical results

In this section, we show the numerical results of the proposed MTIs for both polynomial case and smooth general case. Also, we show the numerical results of the rational type nonlinearity. As benchmark of comparisons, we consider the EIs with three most popular filters as suggested in [36].

The general scheme of the EIs with filters are widely presented in the literatures [33, 36,37,38,39, 42]. Three most popular groups of filters which offer the best numerical performance for solving (1.1) with energy bounded type initial data are suggested in [36] as

$$\begin{aligned}&si(\rho )=\mathrm {sinc}(\rho )\phi (\rho ),\qquad \phi (\rho )=\mathrm {sinc}(\rho ); \end{aligned}$$
(4.1a)
$$\begin{aligned}&\psi (\rho )=\mathrm {sinc}^2\left( \frac{1}{2}\rho \right) ,\qquad \phi (\rho )=\mathrm {sinc}(\rho )\left( 1+\frac{1}{3}\sin ^2\left( \frac{1}{2}\rho \right) \right) ; \end{aligned}$$
(4.1b)
$$\begin{aligned}&\psi (\rho )=\mathrm {sinc}^3(\rho ),\qquad \quad \ \ \,\phi (\rho )=\mathrm {sinc}(\rho ). \end{aligned}$$
(4.1c)

The filter (4.1a) is proposed by García-Archilla et al. in [31] (shorted as GA), (4.1b) is proposed by Hochbruck and Lubich in [39] (shorted as HL) and (4.1c) is proposed by Grimm and Hochbruck in [36] (shorted as GH).

Firstly, we test the MTI (2.11) for the polynomial nonlinearity case. We choose

$$\begin{aligned} d=4,\quad \varLambda =diag(1,\mathrm {e},3,\pi ),\quad \phi _0=(1,1,2,1)^\mathrm {T},\quad \phi _1 =(1,2,1,-1)^\mathrm {T}, \end{aligned}$$

and

$$\begin{aligned} \mathbf {f}(\mathbf {y})=(y_4^3,y_3^3,y_2^3,y_1^3)^\mathrm {T}, \end{aligned}$$
(4.2)

in model (1.7). Here since the analytical solution to this problem is not available, the ‘exact’ solution \(\mathbf {y}(T)\) is obtained numerically by the MTI (2.11) under a very small time step \(\tau = 10^{-5}\). The position error \(\mathbf {\mathrm {e}}^N=\mathbf {y}(T)-\mathbf {y}^N\) is computed at \(N=\frac{T}{\tau }\) and measured under standard Euclidian norm. The results of the MTI method and the three chosen EIs under different time steps \(\tau \) and \(\varepsilon \) are shown in Table 2 at \(T=2\).

Secondly, we test the MTI (2.19) for the general smooth nonlinearity case under condition (2.12). We choose

$$\begin{aligned} d=4,\quad \varLambda =\pi \cdot diag(1,2,2,1),\quad \phi _0=(1,1,2,1)^\mathrm {T},\quad \phi _1=(1,2,1,1)^\mathrm {T}, \end{aligned}$$

and

$$\begin{aligned} \mathbf {f}(\mathbf {y})=(\sin (y_4),\sin (y_3),\sin (y_2),\sin (y_1))^\mathrm {T}, \end{aligned}$$
(4.3)

in problem (1.7). The position error of the MTIs and EIs under different time steps \(\tau \) and \(\varepsilon \) are shown in Table 3 at \(T=2\). We take the \(M=10\) in (2.17) and (2.18) to reach machine accuracy.

Table 2 Position error of the MTI (2.11) for the polynomial case (4.2) at \(T=2\) and comparisons with EIs
Table 3 Position error of the MTI (2.19) for the general smooth nonlinearity case (4.3) but with (2.12) at \(T=2\) and comparisons with EIs
Table 4 Position error of the MTI (2.19) for the rational nonlinearity case (4.4) given by Coulomb potential with (2.12) at \(T=2\) and comparisons with EIs

Thirdly, we test the MTIs for solving the ODEs (1.7) with rational type nonlinearity. We choose

$$\begin{aligned} d=4,\quad \mathbf {y}=(\mathbf {q}_1,\mathbf {q}_2)^\mathrm {T},\quad \mathbf {q}_1=(y_1,y_2)^\mathrm {T},\quad \mathbf {q}_2=(y_3,y_4)^\mathrm {T}, \end{aligned}$$

and the nonlinearity generated by the Coulomb potential \(V_C\) (1.4), i.e.

$$\begin{aligned} \mathbf {f}(\mathbf {y})=\frac{-\left( y_1-y_3,y_2-y_4,y_3-y_1,y_4-y_2\right) ^\mathrm {T}}{\left[ (y_1-y_3)^2+(y_2-y_4)^2\right] ^{\frac{3}{2}}}, \end{aligned}$$
(4.4)

with

$$\begin{aligned} \varLambda =\pi \cdot diag(1,1,2,1),\quad \phi _0=(1,1,-1,-1)^\mathrm {T},\quad \phi _1=\frac{1}{2}(-1,-1,1,1)^\mathrm {T}, \end{aligned}$$

in (1.7). \(M=10\) is also used in (2.17) and (2.18) to get machine accuracy. The position error of different numerical methods are shown in a similar way in Table 4 at \(T=2\).

Fig. 4
figure 4

Error \(|e^N|\) of the MTIs for the polynomial case (4.2) (left figure) and the general smooth case (4.3) (right figure) with different \(\varepsilon \) under \(\tau \lesssim \varepsilon \)

Fig. 5
figure 5

Error \(|e^N|\) of the MTIs for the polynomial case (4.2) (left figure) and the general smooth case (4.3) (right figure) with different \(\tau \) under \(\varepsilon \lesssim \tau \)

Fig. 6
figure 6

Error \(|e^N|\) of the MTIs for the general smooth case (4.3) (left figure) and the rational case (4.4) (right figure) with \(\tau =0.2/2^8\) under different \(\tau \lesssim \varepsilon \)

From Tables 2, 3 and 4, Figs. 4, 5 and 6 and additional results not shown here for brevity, the following observations can be drawn:

  1. 1.

    With fixed \(\tau \) as \(\varepsilon \) decreases, the MTIs in all cases have uniform error bounds (cf. Tables 2, 3 and 4), while the EIs have clearly increase in the sine nonlinearity test and the rational nonlinearity test (cf. Fig. 6).

  2. 2.

    For the smooth nonlinearity cases, the MTIs have second order convergence in \(\tau \) when \(\tau \lesssim \varepsilon \) decreases (cf. Tables 2, 3; Fig. 4), and have second order convergence in \(\varepsilon \) when \(\varepsilon \lesssim \tau \) decreases (cf. Tables 2, 3; Fig. 5). Thus, the theoretical error estimates are optimal.

  3. 3.

    The MTIs work very well for rational nonlinearity case from both stability and accuracy points of view (cf. Table 4). For all cases, the MTIs offer much smaller position error than the EIs under the same time step.

Fig. 7
figure 7

Error \(|e^N|\) of the MTI case 4.5 as function of \(\tau \) in log scale for different \(\varepsilon \) at \(T=1\) under two different \(\upsilon \)

Next, we show a numerical example with zero mode frequency in the linear part and a standard forced Van der Pol oscillator type source term [16] with a frequency \(\upsilon >0\):

$$\begin{aligned} \left\{ \begin{aligned}&\ddot{y}_1(t)+\frac{1}{\varepsilon ^2}y_1(t)+\sin (y_2(t))=\sin (\upsilon \, t),\\&\ddot{y}_2(t)+(y_1(t))^3=0,\qquad t>0,\\&y_1(0)=y_2(0)=1,\quad \dot{y}_1(0)=\frac{1}{\varepsilon },\quad \dot{y}_2(0)=\frac{3}{2}, \end{aligned}\right. \end{aligned}$$
(4.5)

by using the MTIs with the techniques mentioned in Sects. 2.3 and 2.4.

The error at \(T=1\) for two different \(\upsilon \) under different \(\tau \) and \(\varepsilon \) are shown in Fig. 7. The numerical results show that the MTI with the techniques from Sects. 2.3 and 2.4 works well in this case with performance similarly as before and clearly once again illustrate that the convergence is uniform in \(\varepsilon \).

At last, we use an example to show the long-time behaviour of the proposed MTI for solving (1.7). We take in (1.7)

$$\begin{aligned} d=2,\quad \varLambda =diag(1,\mathrm {e}),\quad \phi _0=(1,2)^T,\quad \phi _1=(1,-1)^T,\quad \mathbf {f}(\mathbf {y})=(y_1y_2^2,y_2y_1^2)^\mathrm {T}. \end{aligned}$$
(4.6)

Then the energy H(t) is conserved by (1.7), i.e.

$$\begin{aligned} H(t):=\dot{\mathbf {y}}^T(t)\dot{\mathbf {y}}(t)+\frac{1}{\varepsilon ^2}\mathbf {y}^T(t)\varLambda \mathbf {y}(t)+y_1^2(t)y_2^2(t)\equiv H(0),\quad t\ge 0. \end{aligned}$$

We solve (1.7) by MTI (2.11) and compute the numerical energy \(H^n=(\dot{\mathbf {y}}^n)^T\dot{\mathbf {y}}^n+\frac{1}{\varepsilon ^2}(\mathbf {y}^n)^T\varLambda \mathbf {y}^n+(y_1^ny_2^n)^2\) from the numerical solution. The relative energy error \(|H^n-H(0)|/|H(0)|\) for \(\varepsilon =0.1\) and \(\varepsilon =0.01\) are shown in Fig. 8 till \(t=100\) under several step size \(\tau \).

Fig. 8
figure 8

Relative energy error of MTI for \(\varepsilon =0.1\) and \(\varepsilon =0.01\) till \(T=100\) under different \(\tau \)

5 Conclusion

In this paper, we proposed some multiscale time integrators (MTIs) for solving oscillatory second order ODEs with large initial data that leads to unbounded energy in the limit regime. Comments on the relation between the energy unbounded type initial data and the widely used energy bounded type initial data in the ODEs are given. The MTIs are proposed based on modulated Fourier expansion of the solution at every time step. Detailed numerical schemes are derived for the case when the nonlinearity in the ODEs is a polynomial type, and for the case of general nonlinearity but with the linear oscillatory part in the ODEs is multiples of a single frequency. The schemes are fully explicit and easy to implement. Rigorous error estimates of the proposed MTIs for solving the oscillatory ODEs with smooth nonlinearity are established to show the uniform second order convergence rate when the oscillation frequency increases. Extensive numerical experiments of the MTIs are done to confirm the analysis together with comparisons with popular EIs. Numerical explorations of the MTIs for solving the ODEs with rational type nonlinearity are also done.