In this work we study the behavior of numerical approximations of solitary wave solutions of nonlinear wave partial differential equations (PDEs). These solitary waves evolve in time only by translation; this translation symmetry is, in accordance with Noether’s Theorem [50], associated with a particular conserved functional of the PDE. We investigate in a broad setting the phenomenon, already studied for certain equations, that numerical methods that conserve (up to rounding errors) this functional (or the Hamiltonian of the system) exhibit much smaller errors over long times.

This behavior has been demonstrated for numerical approximations of certain solutions of Hamiltonian systems. These solutions are referred to as relative equilibria, and are those whose trajectory lies on a manifold defined by a symmetry group. For such solutions, numerical methods that exactly conserve certain invariants give rise to a leading term in the global error that grows linearly in time [25]. In contrast, for general (non-conservative) numerical solutions approximating relative equilibria, the error growth is typically quadratic (this should be contrasted with more general estimates of numerical error growth, which are typically exponential in time). This behavior has been shown for finite-dimensional Hamiltonian systems [12, 14, 15, 25]. For dispersive nonlinear wave equations, it was first observed in the context of solitary wave solutions of the Korteweg-de Vries (KdV) equation, by Sanz-Serna [72] and later by Bona et al. [11]. This behavior was eventually proved for discretizations of the KdV equation by de Frutos and Sanz-Serna [18].

Similar results were later obtained for solitary wave solutions of the nonlinear Schrödinger equation [24], Peregrine’s regularized long wave (RLW) equation (also known as the Benjamin–Bona–Mahoney (BBM) equation) [7, 49], and the generalized BBM equation [4, 22]. An extension to certain other dispersive wave equations, including the generalized KdV, generalized BBM, and generalized Benjamin–Ono equations, is presented in [4]. The results in [49] are purely experimental, while the remaining results just cited include proofs along with numerical demonstrations.

Most of the PDE results in this direction are specific to solitary wave solutions. The conservative discretizations that yield linear error growth also exhibit modified solitary waves [7, 22]. These are discrete solitary waves that are close to but different from the exact solitary wave solutions. The ability of these modified solitary waves to propagate discretely without changing shape or amplitude means that conservative methods are appealing for long-time simulations of solitary waves and their interactions [23]. The concept of a modified solitary wave also provides, for some systems, an intuitive rough explanation of the observed error growth rates. In a non-conservative method, the solitary wave is approximated by a wave whose amplitude grows or diminishes linearly in time. Since the speed of the solitary wave is (at least to first approximation) a linear function of the amplitude, the error in the speed of the wave also grows linearly in time. This leads to a quadratic error in the location (phase) of the wave. Meanwhile, it was shown in [4, 7, 22] that a conservative scheme yields a modified solitary wave whose amplitude and speed are constant in time (though different from those of the true solitary wave). Hence the phase error grows only linearly.

The foregoing results serve as the motivation for the present study. Here we take an experimental approach, allowing the consideration of several other dispersive wave equations as well as non-dispersive hyperbolic systems that possess similar kinds of solutions. In this work we provide strong evidence that the phenomenon of linear error growth in time for conservative numerical solutions extends to a very large class of dispersive wave equations and nonlinear invariants, including invariants that are not quadratic, and even certain solutions of first-order hyperbolic systems that have no dispersive terms.

We briefly introduce the spatial and temporal discretization methods we will use in Sect. 3. In Sect. 4, we analyze the temporal error growth of solitary wave solutions to several nonlinear dispersive wave equations. Our experimental results include the Fornberg-Whitham [80], Camassa-Holm [13], Degasperis-Procesi [19], Holm-Hone [36], and BBM-BBM equations [9, 10]. For each of these models, we apply recently-constructed conservative schemes and show experimentally that they yield improved (linear) error growth when compared to non-conservative schemes for the same model. To demonstrate the importance of nonlinearity for the different error growth behaviors of conservative and non-conservative methods, we investigate a linear dispersive wave equation in Sect. 5.2. There, both kinds of methods result in the same asymptotic error growth rate, although the absolute error of the conservative method is smaller. We then go further outside the realm of available results and consider two first-order nonlinear hyperbolic systems that have been shown to possess solitary-wave-like solutions. In Sect. 6 we study the variable-coefficient p-system in one dimension, with periodically varying coefficients. Previous work on this system has noted similarities with dispersive nonlinear wave equations; see [40, 46]. In Sect. 7, we study the two-dimensional shallow water equations with varying bathymetry. Finally, we summarize and discuss our results in Sect. 8.

The main contributions of this work are as follows:

  1. 1.

    We illustrate via computational experiments that the favorable behavior proved for conservative numerical solutions of certain nonlinear dispersive PDEs [4, 7, 18, 24] holds for several other such PDEs.

  2. 2.

    We show through numerous examples that not only do conservative schemes exhibit a better asymptotic error behavior for large times, but also a much smaller size of the global error even for short times.

  3. 3.

    We show through a computational example that the condition of mass conservation, assumed in the main theorems of [7, 18], is necessary in practice (see Sect. 5.1).

  4. 4.

    We demonstrate for the first time that the aforementioned favorable behavior can be observed also in the numerical solution of a system that does not possess solitary wave solutions with simple translation or rotation symmetries (see Sect. 6).

  5. 5.

    We demonstrate for the first time that dramatically better error growth for conservative methods can be observed also in systems with two spatial dimensions (see Sect. 7).

The source code used to generate the results of this study is available online [67]. The numerical methods studied in this article are implemented in Julia [8] and make use of the open source library SummationByPartsOperators.jl [63], which utilizes FFTW [29] for Fourier collocation methods. We use time integration methods from [58]. The plots are generated using Matplotlib [37].

Relative equilibrium solutions

One framework for understanding the rates of error growth observed in the present work is that of relative equilibrium theory. Here we review very briefly this theory in the context of finite-dimensional dynamical systems (where it is most completely developed) and Hamiltonian PDEs.

Relative equilibria are equilibria of a reduced dynamical system obtained by reduction modulo a set of symmetry groups of the original dynamical system. Relative equilibria evolve only along the manifold corresponding to the symmetry groups. In the case of finite-dimensional Hamiltonian systems, each symmetry group corresponds to an invariant quantity. A relative equilibrium \(u_0\) of a Hamiltonian system with Hamiltonian \({\mathscr {H}}(u)\) and invariant quantities \({\mathscr {I}}_j(u)\) satisfies [25, Eqn. (36)]

$$\begin{aligned} \nabla \left( {\mathscr {H}}(u_0) - \sum _i \lambda _i {\mathscr {I}}_i(u_0)\right)&= 0, \end{aligned}$$

where the values \(\lambda _i\) are Lagrange multipliers. For a relative equilibrium solution of a Hamiltonian system, perturbations in directions that lie on the manifold corresponding to the symmetry group grow linearly in time, while perturbations in other directions grow quadratically [25, Lemma 2.4]. Therefore, if a numerical method conserves the invariants corresponding to the symmetry group, the numerical error will grow only linearly in time [25, Theorem 3.2].

The situation is analogous but more involved for Hamiltonian PDEs like the dispersive wave equations considered in Sect. 4. Each of these equations can be written as a Hamiltonian system

$$\begin{aligned} u_t = J \delta {\mathscr {H}}(u) \end{aligned}$$

where \({\mathscr {H}}\) is the Hamiltonian, \(\delta \) is the variational derivative, and J is a skew-symmetric operator. Each system possesses an additional invariant \({\mathscr {I}}(u)\), such that

$$\begin{aligned} J\delta {\mathscr {I}}(u) = \partial _x u. \end{aligned}$$

This implies that the symmetry group of translations is associated with the invariant \({\mathscr {I}}\); the relative equilibrium condition (analogous to (1)) is

$$\begin{aligned} \delta ({\mathscr {H}}(u) - c {\mathscr {I}}(u))&= 0. \end{aligned}$$

Using (2) and (3), we find that multiplying (4) on the left by J gives the equation \(\partial _t u - c\partial _x u = 0\), satisfied by translation-invariant solitary waves with speed c. Thus, for each of the equations we consider, solitary wave solutions correspond to relative equilibria, where the symmetry group is generated by translation.

It is possible to show also for these systems that numerical methods whose errors lie entirely within the appropriate manifold yield an error that grows only linearly in time; see e.g.[4, 18, 24] for examples of such analysis. Due to the condition (4), it is sufficient to conserve either \({\mathscr {H}}\) or \({\mathscr {I}}\), in order to obtain linear growth in time of the leading term in the global error [4, 18]. Rigorous results in this vein require a detailed perturbation analysis specific to the PDE in question. We do not pursue such analysis here, and focus instead on an experimental study.

We remark here that the results proving linear error growth for KdV and RLW solitary waves [7, 18] also require the assumption of mass conservation. The necessity of this assumption has not been investigated experimentally, perhaps since “sensible methods exactly conserve the mass" [18]. However, the well-known orthogonal projection schemes can be used to conserve a nonlinear invariant at the cost of not conserving mass; in Sect. 5.1 we investigate the asymptotic error growth for such schemes.

Discretization methods

Next, we introduce the type of discretization methods employed in this article.

Spatial semidiscretizations

Proving the conservation of invariants of partial differential equations usually requires the product/chain rule and integration by parts. It is often useful to mimic the same procedure at the discrete level by using summation by parts (SBP) operators, which are constructed specifically to satisfy a discrete analogue of integration by parts. A review of the relevant theory can be found in [16, 26, 76]. Many classes of numerical methods can be formulated within the SBP framework, including finite difference [75], finite volume [52, 53], continuous Galerkin [1, 34, 35], discontinuous Galerkin [30], and flux reconstruction methods [69]. A brief review of how to formulate these methods in the SBP framework with application to structure-preserving numerical methods used in this article is given in [68].

Next, we will briefly introduce SBP operators in periodic domains in one space dimension. Extensions to multiple space dimensions can be achieved via tensor products. We consider a grid \(\pmb {x} = (x_1, \dots , x_m)\) where \(x_1 = x_\mathrm {min}\le x_2 \dots \le x_{m} = x_\mathrm {max}\). All nonlinear operations will be performed pointwise, i.e.we use a collocation approach.

Definition 3.1

Given a grid \(\pmb {x}\), a p-th order accurate i-th derivative matrix is a matrix that satisfies


with the convention \(\pmb {x}^0 = \pmb {1}\) and \(0 \pmb {x}^k = \pmb {0}\). We say is consistent if \(p \ge 0\).

For periodic boundary conditions (under which solutions at \(x_\mathrm {min}\) and \(x_\mathrm {max}\) are identical), integration by parts is basically a statement about the symmetry of a derivative operator with respect to the \(L^2\) scalar product. Discretely, an approximation of this scalar product is represented by a so-called mass matrix .Footnote 1

Definition 3.2

A periodic first-derivative SBP operator consists of a grid \(\pmb {x}\), a consistent first-derivative matrix , and a symmetric and positive-definite matrix such that


We will often refer to an operator as a (periodic) SBP operator if the other operators (such as the mass matrix ) are clear from the context. We always assume derivative operators are consistent, but we will usually omit this term.

Definition 3.3

A periodic second-derivative SBP operator consists of a grid \(\pmb {x}\), a consistent second-derivative matrix , and a symmetric and positive-definite matrix such that


Definition 3.4

A periodic fourth-derivative SBP operator consists of a grid \(\pmb {x}\), a consistent fourth-derivative matrix , and a symmetric and positive-definite matrix such that


In this work, we use Fourier (pseudospectral) collocation methods [28, 44] because of their efficiency and accuracy for smooth problems. This allows us to ensure, with reasonable grids, that the temporal discretization error dominates the spatial error for all of our 1D numerical tests. Nevertheless, all classes of methods within the SBP framework can be used and analyzed interchangeably to construct conservative semidiscretizations.

Time integration methods

To transfer the semidiscrete conservation results to fully-discrete schemes, the recent relaxation approach is used [39, 64,65,66, 70]. Related ideas date back to [72, 73] and [20, pp. 265–266] but have been developed widely just recently.

Semidiscretizations reduce an initial boundary value PDE to an initial value ODE

$$\begin{aligned} u'(t) = f(u(t)), \quad u(0) = u^0. \end{aligned}$$

Throughout this work we use superscripts to denote the time step, and here \(u^0\) is the initial condition. To conserve a nonlinear invariant functional J(u) discretely in a one-step method, we require \(J(u^n) = J(u^{n-1}) = J(u^0)\). For a Runge–Kutta method


we define the update direction

$$\begin{aligned} d^n := \sum _{i=1}^{s} b_{i} f_i, \end{aligned}$$

where we use the abbreviation \(f_i := f(t_n + c_i \varDelta t, y_i)\). Since the new solution \(u^n\) will not be conservative in general, we modify the update formula (10b) by introducing a relaxation parameter \(\gamma ^n\) and use

$$\begin{aligned} u(t_n + \gamma ^n\varDelta t) \approx u^{n+1}_\gamma = u^n + \gamma ^n \varDelta td^n. \end{aligned}$$

To guarantee conservation of J, \(\gamma ^n\) is computed as root of

$$\begin{aligned} J(u^{n+1}_\gamma ) = J(u^n). \end{aligned}$$

This scalar nonlinear equation can be solved efficiently using algorithms such as the one of [2]. By the general theory on relaxation methods, there is exactly one root \(\gamma ^n = 1 + {\mathscr {O}}(\varDelta t^{p-1})\) of (13) [66, Theorem 2.14]. By construction of the relaxation parameter \(\gamma ^n\), the resulting solution \(u^{n+1}_\gamma \) conserves the invariant J. Moreover, the relaxation approach also automatically conserves linear invariants (as long as the semi-discretization conserves them), which is an important prerequisite of analytical results on linear vs. quadratic error growth in time. Finally, the solution (12) has the same local order of accuracy as that given by the original Runge–Kutta method (10).

Nonlinear dispersive wave equations

In this section, we consider several nonlinear dispersive wave equations. Each possesses an additional invariant \({\mathscr {I}}(u)\), and possesses stable solitary wave solutions that satisfy the relative equilibrium condition (4). Each equation also possesses one or more linear invariants, which are preserved by the discretizations we use. Since these invariants do not require any special numerical treatment, we do not discuss them explicitly.

For each equation we give a numerical method that conserves \({\mathscr {I}}(u)\), based on SBP operators applied to a split form of the equation. In each case, \(D_j\) always denotes a periodic jth-derivative SBP operator. The matrices used for discretization of a given equation are also assumed to have in common a corresponding diagonal mass matrix M. We will sometimes require an assumption that the derivative matrices \(D_j\) commute; this will be stated explicitly when it is required.

Conservative numerical methods for these equations have been developed and analyzed in [68] using various classes of SBP operators. We will use split forms to preserve local conservation laws, since the chain and product rules cannot hold discretely for many high-order discretizations [62]. These are related to entropy-conservative methods in the sense of Tadmor [77]. While certain split forms have been known for some time [71, eq. (6.40)], they are still state of the art and enable the construction of numerical methods with desirable properties [31, 61, 74, 82].

For each equation, after reviewing the Hamiltonian structure and split-form conservative spatial discretization, we present a numerical test of error growth for a solitary wave solution. The solitary wave solutions are obtained via the Petviashvili method [56] using a Fourier collocation method with \(2^{16}\) nodes. The resulting solitary wave profile is interpolated to a grid using fewer nodes and used as initial condition. A conservative semidiscretization is obtained by using Fourier collocation methods in space. This semidiscretization is integrated in time using the fifth-order accurate Runge–Kutta method of Tsitouras [78] with adaptive time stepping based on local error estimates. We show results for both this method without relaxation (non-conservative) and with relaxation in time (conservative). The errors plotted are discrete \(L^2\) errors computed using the discrete norm induced by the mass matrix , which is the identity matrix times the grid spacing for Fourier collocation methods.

Fornberg–Whitham equation

For convenience we define \(S= {\text {I}}- \partial _x^2\). Then the Fornberg-Whitham equation [80]

$$\begin{aligned} S\partial _t u(t,x) + S\partial _x f(u(t,x)) + \partial _x u(t,x)= & {} 0,\nonumber \\ u(0, x)= & {} u^0(x),\nonumber \\ f(u)= & {} \frac{u^2}{2}, \end{aligned}$$

with periodic boundary conditions can also be written as

$$\begin{aligned} \partial _t u(t,x) + \partial _x f(u(t,x)) + S_P^{-1} \partial _x u(t,x) = 0, \end{aligned}$$

where \(S_P^{-1}\) is the inverse of the elliptic operator \({\text {I}}- \partial _x^2\) with periodic boundary conditions. This equation possesses the Hamiltonian and additional nonlinear invariant

$$\begin{aligned} {\mathscr {H}}(u)&= \int _{x_\mathrm {min}}^{x_\mathrm {max}}\left( \frac{u^3}{6} + \frac{1}{2}u {S_P^{-1}} u\right) \hbox {d}x, \quad {\mathscr {I}}(u) = \int _{x_\mathrm {min}}^{x_\mathrm {max}} u^2 \hbox {d}x. \end{aligned}$$

It can be written in the form (2) by taking \(J=-\partial _x\). The discrete equivalent of \({\mathscr {I}}(u)\) is conserved by semidiscretizations of the form


where and commute [68].

Camassa–Holm equation

The Camassa-Holm equation [13]

$$\begin{aligned} \begin{aligned} S\partial _t u(t,x) + \partial _x \biggl ( \frac{3}{2} u(t,x)^2 - \frac{1}{2} (\partial _x u(t,x))^2 - u(t,x) \partial _x^2 u(t,x) \biggr )&= 0, \\ u(0, x)&= u^0(x), \end{aligned} \end{aligned}$$

with periodic boundary conditions can also be written as

$$\begin{aligned}&\partial _t u + S_P^{-1} \bigl ( \partial _x u^2 + u \partial _x u - \alpha \partial _x (u \partial _x^2 u) - (1 - \alpha ) \partial _x^2 (u \partial _x u) \nonumber \\&\quad - (2 \alpha - 1) (\partial _x u) (\partial _x^2 u) \bigr ) = 0, \end{aligned}$$

where \(\alpha \in {\mathbb {R}}\) is a parameter determining the split form [68]. This equation possesses the Hamiltonian and an additional nonlinear invariant

$$\begin{aligned} {\mathscr {H}}(u)&= \frac{1}{2} \int _{x_\mathrm {min}}^{x_\mathrm {max}}\left( u^3 + u (\partial _x u)^2\right) \hbox {d}x, \quad {\mathscr {I}}(u) = \frac{1}{2} \int _{x_\mathrm {min}}^{x_\mathrm {max}} \bigl ( u^2 + (\partial _x u)^2 \bigr ) \hbox {d}x. \end{aligned}$$

It can be written in the form (2) by taking \(J=-\frac{1}{2}{S_P^{-1}}\partial _x\). The discrete equivalent of \({\mathscr {I}}(u)\) is conserved by semidiscretizations of the form [68]


Degasperis–Procesi equation

The Degasperis-Procesi equation [19]

$$\begin{aligned} S\partial _t u(t,x) + {(4 {\text {I}}- \partial _x^2) \partial _x} f(u(t,x))= & {} 0,\nonumber \\ u(0, x)= & {} u^0(x),\nonumber \\ f(u)= & {} \frac{u^2}{2}, \end{aligned}$$

with periodic boundary conditions can also be written as

$$\begin{aligned} \partial _t u(t,x) + S_P^{-1} (4{\text {I}}- \partial _x^2) \partial _x f(u(t,x)) = 0, \end{aligned}$$

where \(S_P^{-1}\) is the inverse of the elliptic operator \({\text {I}}- \partial _x^2\) with periodic boundary conditions. This equation admits (among others) the nonlinear invariants [19]

$$\begin{aligned} {\mathscr {H}}(u)&= -\int _{x_\mathrm {min}}^{x_\mathrm {max}}\frac{1}{6} u^3 \hbox {d}x,&{\mathscr {I}}(u)&= \frac{1}{2} \int _{x_\mathrm {min}}^{x_\mathrm {max}} \bigl ( (u - \partial _x^2 u) v \bigr ) \bigr ) \hbox {d}x,&v = (4{\text {I}}- \partial _x^2)^{-1} u. \end{aligned}$$

It can be written in the form (2) by taking \(J = S_P^{-1} (4{\text {I}}- \partial _x^2) \partial _x\). The discrete equivalent of \({\mathscr {I}}(u)\) is conserved by semidiscretizations of the form [68]


BBM–BBM system

The BBM–BBM system [5, 6, 9, 10]

$$\begin{aligned} \partial _t \eta (t,x) + \partial _x u(t,x) + \partial _x \bigl ( \eta (t,x) u(t,x) \bigr ) - \partial _t \partial _x^2 \eta (t,x)= & {} 0,\nonumber \\ \partial _t u(t,x) + \partial _x \eta (t,x) + \partial _x \frac{u(t,x)^2}{2} - \partial _t \partial _x^2 u(t,x)= & {} 0,\nonumber \\ \eta (0, x)= & {} \eta ^0(x),\nonumber \\ u(0, x)= & {} u^0(x), \end{aligned}$$

with periodic boundary conditions can also be written as

$$\begin{aligned} \partial _t \eta (t,x) + S_P^{-1} \partial _x \bigl ( u(t,x) + \eta (t,x) u(t,x) \bigr )= & {} 0,\nonumber \\ \partial _t u(t,x) + S_P^{-1} \partial _x \biggl ( \eta (t,x) + \frac{u(t,x)^2}{2} \biggr )= & {} 0. \end{aligned}$$

This equation admits the nonlinear invariants

$$\begin{aligned} {\mathscr {H}}(\eta , u)&= -\frac{1}{2}\int _{x_\mathrm {min}}^{x_\mathrm {max}} (\eta ^2 + (1 + \eta ) u^2) \hbox {d}x,&{\mathscr {I}}(\eta , u)&= \int _{x_\mathrm {min}}^{x_\mathrm {max}} (\eta u + (\partial _x \eta )(\partial _x u)) \hbox {d}x, \end{aligned}$$

and can be written in the form (2) by taking

$$\begin{aligned} J&= \begin{pmatrix} 0 &{} S^{-1}\partial _x \\ S^{-1}\partial _x &{} 0 \end{pmatrix}. \end{aligned}$$

As mentioned in Sect. 2, we expect to observe linear error growth whenever the numerical method conserves either \({\mathscr {H}}(\eta , u)\) or \({\mathscr {I}}(\eta , u)\). For this example, we demonstrate this by testing methods that conserve each of these quantities separately.

The discrete equivalent \(-\frac{1}{2} (\pmb {\eta }^T M \pmb {\eta } + \pmb {u}^T M (\pmb {1} + \pmb {\eta }) \pmb {u})\) of \({\mathscr {H}}(\eta , u)\) is conserved by semidiscretizations of the form


where commute [68].

Conservation of the discrete equivalent of \({\mathscr {I}}(\eta , u)\) can be achieved with the standard Galerkin method [48] or SBP methods using the split form


see Theorem 4.1 below.

Theorem 4.1

If is a periodic first-derivative SBP operator and is a periodic second-derivative SBP operator with diagonal mass matrix, then the semidiscretization (30) conserves the quadratic invariant \({\mathscr {I}}\) (defined in (28)).


Using [68, Lemma 2.28] and [68, Lemma 2.27] results in


Applying the SBP property (6) additionally and using that is diagonal yields


Finally, similar arguments based on the symmetry of with respect to the mass matrix lead to


\(\square \)

Holm–Hone equation

As our last example in this section, we consider the Holm–Hone equation [36]:

$$\begin{aligned} (4 - 5 \partial _x^2 + \partial _x^4) \partial _t u + u \partial _x^5 u + 2 (\partial _x u) \partial _x^4 u - 5 u \partial _x^3 u - 10 (\partial _x u) \partial _x^2 u + 12 u \partial _x u= & {} 0,\nonumber \\ u(0, x)= & {} u^0(x),\nonumber \\ \end{aligned}$$

with periodic boundary conditions. It can also be written as

$$\begin{aligned} \partial _t u + (4{\text {I}}- 5 \partial _{x,P}^2 + \partial _{x,P}^4)^{-1} \left( \partial _x \bigl ( u (4 {\text {I}}- 5 \partial _x^2 + \partial _x^4) u \bigr ) + (\partial _x u) (4 {\text {I}}- 5 \partial _x^2 + \partial _x^4) u \right) = 0,\nonumber \\ \end{aligned}$$

where \((4{\text {I}}- 5 \partial _{x,P}^2 + \partial _{x,P}^4)^{-1}\) is the inverse of the elliptic operator \(4{\text {I}}- 5 \partial _x^2 + \partial _x^4\) with periodic boundary conditions. This equation can be written in the form (2) using the nonlinear invariant [36, 79]

$$\begin{aligned} {\mathscr {H}}(u)&= \frac{1}{2} \int _{x_\mathrm {min}}^{x_\mathrm {max}} u (4{\text {I}}- \partial _x^2) ({\text {I}}- \partial _x^2) u = \frac{1}{2} \int _{x_\mathrm {min}}^{x_\mathrm {max}} \bigl ( 4 u^2 + 5 (\partial _x u)^2 + (\partial _x^2 u)^2 \bigr ). \end{aligned}$$

Unlike the previous equations, this one appears to have no second nonlinear invariant; instead the translation symmetry is generated by the linear invariant

$$\begin{aligned} {\mathscr {I}}(u)&= u - \partial _x^2 u. \end{aligned}$$

The relevant operator appearing in (2) is

$$\begin{aligned} J&= - ({\mathscr {I}}\partial _x + \partial _x {\mathscr {I}}). \end{aligned}$$

Both the discrete equivalent of the linear invariant \({\mathscr {I}}(u)\) and the discrete equivalent of the nonlinear invariant \({\mathscr {H}}(u)\) are conserved by semidiscretizations of the form


where commute [68].

Numerical results

For each of the five equations just studied, we perform a similar numerical experiment. We use a numerically generated smooth solitary wave solution as initial condition in a periodic domain, and apply the corresponding SBP spatial discretization with Fourier collocation methods in space and Tsitouras’ fifth-order Runge-Kutta method [78] in time, with or without using relaxation to enforce conservation of a nonlinear invariant \({\mathscr {I}}\). Specific parameters for each simulation are shown in Table 1.

Table 1 Summary of numerical simulations. #DOF denotes the number of the degrees of freedom (number of grid points) of the spatial semidiscretization. Tol. is the local error tolerance used for adaptive time stepping
Fig. 1
figure 1

Error growth in time for numerically generated solitary wave solutions using Fourier collocation in space and 5th-order Runge–Kutta in time. The conservative method uses relaxation to enforce conservation of a nonlinear invariant

Fig. 2
figure 2

Error growth in time for a numerically generated solitary wave solution of the BBM–BBM system (26), using (29) with Fourier collocation in space and 5th-order Runge–Kutta in time. The conservative method uses relaxation to enforce conservation of \({\mathscr {H}}\) (see (28))

Fig. 3
figure 3

Numerical solutions at the final time for a numerically generated solitary wave solution of the BBM–BBM system (26) using relaxation methods conserving \({\mathscr {H}}\) (see (28))

In each case, we observe approximately linear error growth for the conservative method and approximately quadratic growth for the non-conservative method, until eventually the error for the non-conservative method saturates when the exact and numerical solutions no longer overlap.

An example of the numerical solutions themselves is shown in Fig. 3, using BBM–BBM. The numerical solutions obtained using the non-conservative method have a visible amplitude error and a significant phase error. In contrast, the conservative method yields numerical solutions that are visually indistinguishable from the reference solution. Results for the other equations are similar.

For the BBM–BBM system, we also conduct numerical experiments using the discretization (30) and applying relaxation to conserve the corresponding functional. The error growth in time using this method is visually indistinguishable from that shown for the method (29). As expected, the error of the associated conservative method grows linearly in time while the error of the non-conservative method grows quadratically.

Additionally, we perform numerical experiments with non-smooth traveling waves. While these are available in closed form for some of the nonlinear dispersive wave equations studied in this article, their reduced regularity makes it more difficult to approximate them numerically well enough in space. Note that existing analytical results about the error growth in time described in Sect. 2 are based on discretization only in time and assume exactness in space. Thus, the spatial semidiscretization must be well-resolved in order for these results to apply to fully discrete schemes.

Here, we use eighth-order accurate finite difference methods with \(2^{13}\) nodes for peakon solutions of the form \(u(t, x) = c \exp (-|x - c t|)\) with \(c = 1.2\) of the Camassa–Holm equation [13, 45] in the periodic domain \([-35, 35]\). The fifth-order Runge–Kutta method uses a local error tolerance of \(10^{-7}\). The results visualized in Fig. 4 are in accordance with the expectations: We observe quadratic error growth for non-conservative methods and linear error growth for conservative methods.

Fig. 4
figure 4

Numerical results for a non-smooth solitary wave solution of the Camassa–Holm equation (18) using finite difference methods in space and 5th-order Runge–Kutta in time. The conservative method uses relaxation to enforce conservation of the nonlinear invariant \({\mathscr {I}}(u)\)

Significance of linear invariants

In this section we investigate the importance of conservation of linear invariants. First, we study the behavior of a method that preserves energy but not mass for the KdV equation. Then, we consider a linear PDE in which nonlinear invariants play no role.

Projection methods: non-conservation of mass

Here we consider the propagation of a soliton solution of the KdV equation, using three methods. All three methods use the SBP spatial discretization of [65] with eighth-order accurate finite differences that is mass- and energy-conserving. The time discretizations are:

  • An IMEX RK method of [38] that conserves mass but not energy.

  • The corresponding relaxation method that conserves both mass and energy.

  • The corresponding orthogonal projection method that conserves energy but not mass.

For details on orthogonal projection, we refer to [33, Section IV.4]. A similar comparison was conducted in [65]; here we conduct a more detailed study of the error growth for the projection scheme.

Results are shown in Fig. 5. The first two methods behave as expected, in accordance with theoretical results in [18]. The projection method initially performs similar to the relaxation method. However, its error grows quadratically after some time and eventually leads to a much more inaccurate solution, in accordance with the theory of [18]. Interestingly, the large global error in total mass at late times is exhibited not primarily in a change in mass of the soliton, but in a gradual downward drift of the ambient value of u, as shown in Fig. 6. We observed a similar behavior of orthogonal projection methods also for other nonlinear dispersive wave equations such as the BBM equation.

Fig. 5
figure 5

Numerical solutions and error over time for numerical propagation of a KdV soliton

Fig. 6
figure 6

Closeup of numerical solution by projection at various times

A linear dispersive equation

As alluded to in the introduction, nonlinearity is an important condition to observe different behaviors of the error growth in time. To demonstrate that, we consider the linear dispersive equation

$$\begin{aligned} \begin{aligned} ({\text {I}}- \partial _x^2) \partial _t u(t,x) + \partial _x u(t,x)&= 0, \quad t \in (0, T), x \in (x_\mathrm {min}, x_\mathrm {max}), \\ u(0,x)&= u^0(x), \quad x \in [x_\mathrm {min}, x_\mathrm {max}], \end{aligned} \end{aligned}$$

with periodic boundary conditions. The functionals

$$\begin{aligned} J_1^{\mathrm {lin}}(u)&= \int _{x_\mathrm {min}}^{x_\mathrm {max}} u, \end{aligned}$$
$$\begin{aligned} J_2^{\mathrm {lin}}(u)&= \int _{x_\mathrm {min}}^{x_\mathrm {max}} (u^2 + (\partial _x u)^2) = \int _{x_\mathrm {min}}^{x_\mathrm {max}} u ({\text {I}}- \partial _x^2) u, \end{aligned}$$

are invariants of solutions of (39), which are conserved by semidiscretizations of the form


Theorem 5.1

If is a periodic first-derivative SBP operator and is a periodic second-derivative SBP operator, then the semidiscretization (41) conserves the invariants (40) of (39).


Using [68, Lemma 2.28] and [68, Lemma 2.27] results in


Using the symmetry of with respect to the mass matrix and applying the SBP property (6) results in


\(\square \)

Numerical result for the analytical solution

$$\begin{aligned} u(t, x) = \sin (\pi (x - c t)), \quad c = \frac{1}{1 + 4 \pi ^2}, \end{aligned}$$

in the domain \([x_\mathrm {min}, x_\mathrm {max}] = [-1, 1]\) are shown in Fig. 7. The spatial semidiscretization using a Fourier pseudospectral method with \(N = 2^6\) nodes is integrated in time with the fifth-order accurate Runge–Kutta method of [78] and a tolerance of \(10^{-5}\). While the conservative method has a significantly reduced amplitude error, the phase error of the conservative and non-conservative methods are visually indistinguishable. Consequently, the error growth rate in time for both methods is linear. This is in accordance with analytical results available for other linear equations such as hyperbolic systems with constant coefficients in periodic domains; for these equations, the error can also be bounded in time if non-periodic domains are used and the boundary conditions are imposed appropriately [43, 51, 54, 55].

Fig. 7
figure 7

Numerical results for the linear dispersive equation (39) using relaxation methods conserving the energy (40b)

The variable-coefficient p-system

The examples in Sect. 4 all involve dispersive nonlinear wave equations with constant coefficients. The results there are in line with the results available in the literature, all of which involve similar dispersive nonlinear wave equations. We now turn to a very different kind of example that demonstrates the generality of the behavior in question. Specifically, we study a system of nonlinear first-order hyperbolic conservation laws with spatially-varying coefficients. This system has no dispersive terms, and in a strict sense has no traveling wave solutions. It has been observed to possess solutions (known as “stegotons") that are similar to solitary waves, although they change shape periodically in time; see [46].

Specifically, we investigate the behavior of numerical solutions to the first-order system

$$\begin{aligned} \partial _t \varepsilon (t,x) - \partial _x u(t,x)= & {} 0 \nonumber \\ \varrho (x) \partial _t u(t,x) - \partial _x \sigma (\varepsilon (t,x), x)= & {} 0, \end{aligned}$$

where u is the velocity, \(\varrho \) the prescribed density, \(\varepsilon \) the strain, and

$$\begin{aligned} \sigma (\varepsilon ,x) = \exp (K(x)\varepsilon ) - 1 \end{aligned}$$

the stress [46]. Here we have used notation corresponding to elasticity, but the same system arises in Lagrangian gas dynamics and is referred to as the p-system. The energy

$$\begin{aligned} \int E(u(t,x), \varepsilon (t,x), x) \hbox {d}x, \quad E(u, \varepsilon , x) = \frac{1}{2}\varrho (x) u^2 + \int _0^\varepsilon \sigma (s,x) \hbox {d}s \end{aligned}$$

is conserved for strong solutions of (45). Generically, solutions of this system give rise to discontinuities (shocks) and a theory of weak solutions must be invoked. If \(\varrho (x)\) and \(\sigma (\varepsilon ,x)\) do not depend explicitly on x then the system has no traveling wave solutions. However, with appropriate initial data and periodic variation of the PDE coefficients, solutions appear to be regular for all time and the energy (47) is conserved [40].

A straightforward application of an SBP operator in a periodic domain results in the semidiscretization


where \(\pmb {\sigma }\) and the division by \(\pmb {\varrho }\) are evaluated pointwise.

Theorem 6.1

Let be a periodic SBP first-derivative operator with diagonal mass matrix . Then the semidiscretization (48) conserves the total mass of \(\varepsilon \), the total mass of \(\varrho u\), and the total energy \(\eta = \int E\).


For a periodic SBP operator, the rate of change of the total masses is




where \(\Sigma = \int _0^\varepsilon \sigma (s, x) \hbox {d}s\). Hence,


where we have used that the mass matrix is diagonal. \(\square \)

We use smooth coefficients given by

$$\begin{aligned} \varrho (x)&= \frac{5}{2} - \frac{3}{2}\sin (2\pi x), \quad K(x) = \frac{5}{2} - \frac{3}{2}\sin (2\pi x), \end{aligned}$$

in the domain [0, 20]. To study the error growth in time, we construct a stegoton solution numerically using Clawpack [17, 41, 42, 47] as follows. We start with a zero initial condition and a left boundary condition given by

$$\begin{aligned} \varepsilon (0,t)&= 0, \\ u(0,t)&= {\left\{ \begin{array}{ll} -0.1\left[ 1+\cos \left( t_0\pi \right) \right] , &{}\quad \text{ if } |t_0|\le 1, \\ 0, &{} \quad \text{ otherwise }, \end{array}\right. } \end{aligned}$$

where \(t_0=\frac{t-2.5}{2.5}\). This corresponds to a moving wall that generates a pulse that eventually becomes a train of stegotons. We solve this problem to a late time (so that the stegotons are well separated) on a highly-refined grid, and then isolate the first resulting stegoton. For more details see [67].

Next, we use the numerically constructed single-stegoton solution as initial condition. We apply an energy-conservative Fourier pseudospectral semidiscretization (48) with \(2^8\) nodes. We solve the resulting ODE system using the fifth-order Runge–Kutta method of [78] with adaptive time stepping and a tolerance of \(10^{-6}\). The error growth is shown in Fig. 8 for solutions obtained with relaxation (conservative) and without relaxation (non-conservative). After an initial transient period, the error of the non-conservative scheme grows quadratically while the corresponding conservative method results in approximately linear error growth. The error of the non-conservative method starts to saturate at \(t \approx 10^4\) since the numerical and reference waves do not overlap anymore, as can be seen in Fig. 9. The numerical solutions obtained using the non-conservative method have a clearly visible phase error. In addition, the shape of the numerical solutions is deformed, in particular for u. In contrast, the phase error of the conservative method is negligible. Nevertheless, the shape of the numerical solutions has changed a bit over these very long-time simulations, and small oscillations have appeared in the tails of the solitary wave.

Fig. 8
figure 8

Error growth in time for a numerically generated stegoton solution of the variable-coefficient p-system (45), using (48) with Fourier collocation in space and fifth-order Runge–Kutta in time. The conservative method uses relaxation to enforce conservation of (47)

Fig. 9
figure 9

Numerical solutions at the final time for a numerically generated stegoton solution of the variable-coefficient p-system (45). The conservative solution is visually indistinguishable from the reference solution

Although existing theory such as that reviewed in Sect. 2 cannot be applied to this system, it is perhaps not unreasonable to expect the behavior we have observed. Although stegotons are not translation invariant, they appear to be solutions of the form

$$\begin{aligned} u(x,t) = {\tilde{u}}(x-ct, ct) \end{aligned}$$

where \({\tilde{u}}\) is periodic in its second argument; i.e.

$$\begin{aligned} {\tilde{u}}(y, z+\varOmega ) = {\tilde{u}}(y,z) \end{aligned}$$

where \(\varOmega =1\) is the period of the material coefficients \(\varrho (x), K(x)\). This “periodic translation invariance" may fulfill the same role as simple translation invariance. Note also that the system considered here behaves, with a certain extreme choice of coefficients, like the discrete Toda lattice [46]; for the latter system, it is known that symplectic numerical integrators exhibit linear error growth [33, pp. 413–414].

The shallow water equations

We now turn to the shallow water equations in two space dimensions. Like the last example, this is a first-order hyperbolic system whose solutions generically develop shock discontinuities. As with the last example, the constant-coefficient equations have no traveling wave solutions; however, for appropriate initial data and varying bathymetry, numerical experiments suggest that solitary wave solutions exist [57]. Nevertheless, this example differs in important ways from all the preceding ones and from all the results available in the literature on error growth for dispersive nonlinear waves. It is a two-dimensional system, and its solitary wave solutions have a two-dimensional structure (localized in x and periodic in y). Aside from the theoretical complication this involves, it also imposes a practical challenge. Since the exact form of the solitary wave solutions is not known, we will need to compute an approximate solitary wave initial condition, as we did in Sect. 6. However, in this case we cannot exhaustively resolve the solution and we expect that resulting initial condition is close to, but still different from, a solitary wave.

The shallow water equations in two space dimensions with variable bathymetry b(xy) are,

$$\begin{aligned} \begin{aligned} \partial _t h + \partial _x (h v_x) + \partial _y (h v_y)&= 0, \\ \partial _t (h v_x) + \partial _x \left( h v_x^2 + \frac{1}{2} g h^2\right) + \partial _y (h v_x v_y)&= - g h \partial _x b, \\ \partial _t (h v_y) + \partial _x (h v_x v_y) + \partial _y\left( h v_y^2 + \frac{1}{2} g h^2\right)&= - g h \partial _y b, \end{aligned} \end{aligned}$$

where h(xyt) is the water height and \(v_x(x,y,t), v_y(x,y,t)\) are the x- and y-components of velocity, respectively. The conserved energy is

$$\begin{aligned} E = \frac{1}{2}(h v^2 + g h^2) + g h b. \end{aligned}$$

A two-parameter family of well-balanced, energy-conservative semidiscretizations of the shallow water equations with variable bathymetry was presented in [59, 60]. The semidiscretization


is a member of this family and was presented earlier in [32, 81], see also [27] for related methods.

In the following, we use the gravitational constant \(g = 9.8\) and the smooth bottom topography

$$\begin{aligned} b(x, y) = \frac{1}{4} - \frac{1}{4} \sin (2 \pi y) \end{aligned}$$

in the domain \([0, 20] \times [-0.5, 0.5]\) with periodic boundary conditions. Results in [57] and additional computations we have conducted indicate that a wide range of initial conditions lead to solitary waves that propagate along the x coordinate direction, transverse to the variation in bathymetry. These solitary waves have a non-trivial structure in both spatial dimensions.

To study the error growth in time, we construct a solitary wave solution as follows. Based on [57], we start with an initial condition given by

$$\begin{aligned} h(x,y)+b(x,y)=\eta ^*+A\exp \left( -\frac{x^2}{4}\right) , \quad h v_x(x,y)= h v_y(x,y)=0, \end{aligned}$$

where \(\eta ^*=0.75\) and \(A=5\times 10^{-2}\). After propagating the initial condition up to a final time of \(t=340\), we obtain a train of solitary waves, from which we isolate the largest wave. For more details see [67]. Next, we use the numerically constructed wave as initial condition for an energy-conservative Fourier pseudospectral discretization (54) with \(2^{10}\) nodes in x and \(2^{6}\) nodes in y. We solve the resulting ODE using the fifth-order Runge-Kutta method of [78] with adaptive time stepping and a tolerance of \(10^{-6}\). The error growth is shown in Fig. 10. In contrast to the examples considered previously, the error growth rates of both methods are sublinear. In agreement with previous results, the error of the conservative method still grows significantly slower, resulting in an error at the final time (after 15 periods) that is approximately an order of magnitude smaller.

Fig. 10
figure 10

Error growth in time for a numerically generated solitary wave solution of the shallow-water equations (52)

Snapshots of the numerical solutions at the final time are shown in Figs. 11 and 12. The conservative method advects the profiles of the perturbations well, resulting in a numerical solution that is visually nearly indistinguishable from the initial profile. In contrast, the non-conservative method results in a slightly visible phase error. In addition, signs of nonlinear instabilities in the form of high-frequency oscillations start to manifest in the y-momentum and in reduced form also in the x-momentum and the total water height.

Fig. 11
figure 11

Snapshots of numerical solutions for a numerically generated solitary wave solution of the shallow-water equations (52)

Fig. 12
figure 12

Slices at \(y \approx -0.26\) of the numerical solutions shown in Fig. 11

Possible reasons for error growth rates that are not linear/quadratic stem from differences relative to the other equations studied so far: this system is two-dimensional, there are no known exact solitary wave solutions, and the computed initial solitary wave is still affected by small numerical errors due to the cost of fully resolving the wave in two dimensions. Additionally, the spatial resolution may not be sufficient, so spatial discretization errors may be significant in these simulations.

Although these numerical results presented for the shallow water equations do not match the linear/quadratic error growth rates of the other examples discussed previously, they still show the usefulness of conservative methods. In the current implementation, the CPU time of the conservative and non-conservative method are comparable while the accuracy differs by an order of magnitude. To obtain similarly accurate solutions using the non-conservative method would require an increased space/time resolution and hence more computational resources.

Summary and conclusions

We have studied the error growth in time of numerical solitary wave solutions of several systems of PDEs, focusing on the difference in behavior between conservative and non-conservative methods. In all cases, the general pattern is the same: conservative methods exhibit linear error growth, while non-conservative methods exhibit quadratic error growth. As one might expect based on this, the magnitude of the error itself is also much smaller for conservative methods.

We have shown that this phenomenon extends to a wide range of dispersive nonlinear wave equations, and that this behavior seems to arise when any nonlinear invariant is conserved, even if it is not quadratic (see Sect. 4.4). Furthermore, we have shown that this behavior extends to other classes of equations, including the p-system example in Sect. 6. This is remarkable in that the equations in question are non-dispersive and the solutions are not traveling waves in the usual sense. Nevertheless, a similar advantage is obtained by using a conservative discretization.

This suggests that conservative methods may be much more efficient for solving wave problems that possess one or more conserved functionals. Efficiency depends also on the cost of the method, which we have not focused on here. In most previous works related to this phenomenon, energy conservation was achieved through the use of fully-implicit Runge–Kutta time integration. With the relaxation Runge–Kutta approach, we can instead employ essentially explicit relaxation Runge–Kutta methods for non-stiff spatial discretizations, and diagonally implicit or linearly implicit (Rosenbrock) methods for stiff problems. These incur only a very small additional cost per time step (in order to solve a scalar algebraic equation). For the methods we have compared here, at least, the conservative approach using relaxation is much more efficient (in terms of computational cost for a given level of error) than the corresponding non-conservative method.

We expect that, for the nonlinear dispersive wave equations studied, a rigorous theoretical explanation of our results could be obtained by perturbation analysis similar to what has been done for other similar PDEs. It is much less clear how to obtain a theoretical justification for the results regarding variable-coefficient first-order hyperbolic PDEs. A first step in this direction might be a study focused on finite-dimensional non-autonomous Hamiltonian systems.

It is natural to ask whether the behavior studied here can be observed for more general solutions (not consisting of a single traveling wave). Some theoretical results are available for other classes of solutions; e.g. for multi-soliton solutions of KdV [3] and quasi-periodic solutions of KdV [21]. An extension of the current study to more general solutions is the subject of ongoing work, and initial tests suggest a complex variety of behaviors. Nevertheless, these tests indicate that conservative methods are consistently much more accurate than their non-conservative counterparts.