1 Introduction

The aim of this paper is to develop time splitting schemes in combination with transparent boundary conditions that have spectral accuracy in space. Splitting schemes are based on the divide and conquer idea; i.e. to divide the original problem into smaller sub-problems which are, hopefully, easier to solve. However, obtaining an approximation of the solution of the original problem from the solutions of the sub-problems is not always straightforward: order reductions or strong CFL conditions that destroy the convergence of the numerical scheme are known to arise, see e.g. [8, 10, 18]. Furthermore, transparent boundary conditions are non-local in time and depend on the solution. Imposing them with splitting methods poses a challenge in the derivation of stable numerical schemes of order higher than one.

In this paper, we show that it is possible to construct a second-order splitting scheme that performs well, in the context outlined above, and can be implemented efficiently. In particular, we show that the proposed numerical method is stable independent of the space grid spacing (i.e. no CFL type condition is needed). We focus our attention on a linearised version of the Korteweg–de Vries equation

$$\begin{aligned} {\left\{ \begin{array}{ll} \partial _t u (t,x)+ g(x) \partial _x u(t,x) + \partial _x^3 u(t,x) = 0, \quad (t,x)\in [0,T]\times \mathbb {R},\\ u(0,x) = u^0(x), \end{array}\right. } \end{aligned}$$
(1)

where \(T>0\). The same ideas, however, can be applied to a more general set of linear partial differential equations with variable coefficients. Note that the partial differential Eq. (1), despite being linear, finds many applications in a physical context. For example, it is used to model long waves in shallow water over an uneven bottom, see e.g. [17, 21].

The goal of this work is to design a splitting scheme that is second order in time with spectral accuracy in space. This paper can be seen as an extension to [12], where a splitting scheme of order one in time and spectral accuracy in space is presented. When solving (1) one of the main difficulties one has to face is the unbounded domain \(\mathbb {R}\). Numerical simulations typically consider a finite domain that leads to boundary conditions. Our goal is to design a numerical scheme that retains the same dynamics as the original problem (1), but on a finite domain. This can be achieved by imposing transparent boundary conditions. The advantage of such boundary conditions is the zero-reflection property of the solution at the boundaries. Further, the solution can leave the finite domain and re-enter at a later time without any loss of information. On the downside, transparent boundary conditions are non-local in time (and space for two and three-dimensional problems), therefore, they become expensive for long time simulations. In particular, memory requirements grow proportionally with the number of time steps. While it is still possible to employ them in 1D, the multidimensional cases become impracticable. A remedy is to approximate transparent boundary conditions and obtain so-called absorbing boundary conditions. In this way, information at the boundaries is lost, but memory requirements remain constant. A lot of work has been done for the Schrödinger equation in recent years, see [1, 3, 5] and references therein. For third-order problems, we refer the reader to [6, 7, 12, 23] and references therein.

In the present case, the third derivative in space renders any explicit integrator extremely expensive. Therefore, an implicit scheme should be implemented. While coupling an implicit time discretization with a spectral space discretization yields banded matrices for constant advection, they lead to full matrices if g varies in space. We therefore employ a time-splitting approach in order to separate the advection problem from the dispersive problem. Operator splitting methods for dispersive problems have been employed and studied before, we refer the reader to [9, 11, 12, 15]. For splitting method with absorbing boundary conditions we cite the work [5]. Splitting methods allow us to design specific solvers for the variable coefficient problem. For example, [20] uses a technique based on preconditioning. However, a direct splitting of (1) is not advisable. The problem of separating the advection equation is the potential requirement of inflow conditions at the boundaries. The actual inflow, however is unknown and should be estimated for example by extrapolation methods. This leads to instabilities when spectral methods are applied unless a very restrictive CFL condition is satisfied. The idea to overcome this problem is to perform a modified splitting that allows us to treat the advection problem without prescribing any inflow condition. The boundary conditions are transferred to the dispersive problem only. In this case, we can compute the values we need with the help of the \(\mathcal {Z}\)-transform, as has been done for a constant coefficient dispersive problem in [6, 7]. Another popular technique to avoid reflections at the boundaries is the perfectly matched layer method (PML). This method has been introduced in [4] for Maxwell’s equations. Subsequently, it has been adapted to the Schrödinger equation [22] and very recently a general PML approach in combination with pseudo-spectral methods has been proposed in [2]. To the best of our knowledge a PML method for a linearised Korteweg–de Vries equation is currently not available.

The paper is organized as follows. In Sect. 2 we derive the semi-discrete scheme, discrete in time and continuous in space, by applying the Strang splitting method. In Sect. 3 we impose transparent boundary conditions for the scheme derived in Sect. 2. In particular, we determine the proper values of the numerical solution at the boundaries with the help of the \(\mathcal {Z}\)-transform. The stability of the resulting numerical method is then analyzed in Sect. 4. In Sect. 5 we describe a pseudo-spectral method for the spatial discretization which takes the transparent boundary conditions into account. Finally, in Sect. 6 we present numerical results that illustrate the theory.

2 Time discretization: modified splitting approach

In this section we derive a semi-discrete scheme by applying the Strang splitting method to problem (1) restricted to a finite interval [ab], where \(a<b\). Inspired by the ideas in [12], we perform a time splitting in order to separate the advection problem \(\partial _t u(t,x) + g(x) \partial _x u(t,x) = 0\) from the dispersive problem \(\partial _t u(t,x) + \partial _x^3 u(t,x) =0\). In the following, for brevity, time and space dependence for the unknown \(u=u(t,x)\) are omitted.

In Sect. 2.1 we present the canonical splitting of (1). This approach illustrates the difficulty to prescribe the inflow condition to the advection equation. In Sect. 2.2 we then propose the modified splitting and show how this problem can be avoided.

2.1 Canonical splitting

Before applying any splitting, a preliminary analysis shows us that the inflow conditions to the advection problem depend on the sign of g(x) at \(x=a\) and \(x=b\). We summarise in Table 1 the four possible outcomes.

Table 1 This table summarises at which boundary points \(\{a,b\}\) the inflow condition needs to be prescribed for the advection problem, depending on the sign of g(x) at the boundaries

For this presentation, we restrict our attention to \(g(x) > 0\) for \(x\in [a,b]\). This setting requires an inflow condition at \(x=a\). Let \(M\in \mathbb {N}\), \(M>0\) be the number of time steps, \(\tau = T/M\) the step size and \(t^m = m\tau \), \(k=0,\dots ,M\). We apply the Strang splitting method to (1), which results in the two sub-problems

$$\begin{aligned}&{\left\{ \begin{array}{ll} \partial _t v + \partial _x^3 v = 0,\\ v(0,x) = v^0(x),\\ \end{array}\right. } \end{aligned}$$
(2a)
$$\begin{aligned}&{\left\{ \begin{array}{ll} \partial _t w + g\partial _x w = 0,\\ w(0,x) = w^0(x).\\ \end{array}\right. } \end{aligned}$$
(2b)

Let \(\varphi _{t}^{[1]}\) be the flow of (2a) and let \(\varphi _{t}^{[2]}\) be the flow of (2b). Let u(tx) be the solution of (1) at time t. Then, the solution to (1) at time \(t + \tau \) is approximated by the Strang splitting

$$\begin{aligned} u(t+\tau , \cdot ) \approx \varphi _{\frac{\tau }{2}}^{[1]} \circ \varphi _{\tau }^{[2]} \circ \varphi _{\frac{\tau }{2}}^{[1]}\left( u(t,\cdot )\right) . \end{aligned}$$
(3)

In order to get a numerical scheme, we apply the Peaceman–Rachford scheme to (3). This consists in computing the first flow \(\varphi _{\frac{\tau }{2}}^{[1]}\) by the explicit Euler method, the middle flow \(\varphi _{\tau }^{[2]}\) by the Crank–Nicolson method and the last flow by the implicit Euler method. Let \(u^m(x) = u(t^m,x)\). Then, we get

$$\begin{aligned} u^*&= \left( I-\frac{\tau }{2}\partial _x^3\right) u^m, \end{aligned}$$
(4)
$$\begin{aligned} \left( I+\frac{\tau }{2}g\partial _x\right) u^{m+1/2}&= \left( I-\frac{\tau }{2}g\partial _x\right) u^*, \end{aligned}$$
(5)
$$\begin{aligned} \left( I+\frac{\tau }{2}\partial _x^3\right) u^{m+1}&= u^{m+1/2}. \end{aligned}$$
(6)

The latter numerical scheme is known to be second-order in time due to its symmetry. Notice that Eq. (5) is a time approximation of

$$\begin{aligned} {\left\{ \begin{array}{ll} \partial _t u + g\partial _x u = 0,\quad (t,x)\in [0,\tau ]\times [a,b],\\ u(0,x) = u^*(x),\\ u(t,a) = f(t).\\ \end{array}\right. } \end{aligned}$$
(7)

The function f(t) encodes the inflow condition at \(x=a\). For \(t\in (0,\tau ]\) the inflow condition is unknown. It can be approximated by extrapolation methods which typically leads to instabilities. The idea to overcome this problem is to formulate the advection problem without any inflow condition. For this purpose we introduce next a modified splitting.

2.2 Modified splitting

Based on the observations in Sect. 2.1, we rewrite the governing equation in (1) as follows

$$\begin{aligned}&\partial _t u + g(x) \partial _x u + \partial _x^3 u = \partial _t u + \left( g(x)-p_g(x) + p_g(x)\right) \partial _x u + \partial _x^3 u, \end{aligned}$$

where \(p_g(x)\) is the line connecting the points \(\left( a,g(a)\right) \) and (bg(b)). We now apply a splitting method that results in the two sub-problems

$$\begin{aligned}&{\left\{ \begin{array}{ll} \partial _t v + p_g(x)\partial _x v + \partial _x^3 v = 0,\\ v(0,x) = v^0(x),\\ \end{array}\right. } \end{aligned}$$
(8a)
$$\begin{aligned}&{\left\{ \begin{array}{ll} \partial _t w + \left( g(x)-p_g(x)\right) \partial _x w = 0,\\ w(0,x) = w^0(x).\\ \end{array}\right. } \end{aligned}$$
(8b)

Let \(\varphi _{t}^{[1]}\) be the flow of (8a) and let \(\varphi _{t}^{[2]}\) be the flow of (8b). Let u(tx) be the solution of (1) at time t. The solution to (1) at time \(t + \tau \) is then approximated by the Strang splitting

$$\begin{aligned} u(t+\tau , \cdot ) \approx \varphi _{\frac{\tau }{2}}^{[1]} \circ \varphi _{\tau }^{[2]} \circ \varphi _{\frac{\tau }{2}}^{[1]}\left( u(t,\cdot )\right) . \end{aligned}$$
(9)

By applying the Peaceman-Rachford scheme to (9), we get

$$\begin{aligned} u^*&= \left( I-\frac{\tau }{2}p_g(x)\partial _x-\frac{\tau }{2}\partial _x^3\right) u^m, \end{aligned}$$
(10)
$$\begin{aligned} \left( I+\frac{\tau }{2}g^*\partial _x\right) u^{m+1/2}&= \left( I-\frac{\tau }{2}g^*\partial _x\right) u^*, \end{aligned}$$
(11)
$$\begin{aligned} \left( I+\frac{\tau }{2}p_g\partial _x + \frac{\tau }{2}\partial _x^3\right) u^{m+1}&= u^{m+1/2}, \end{aligned}$$
(12)

where \(g^*(x) = g(x) - p_g(x)\). Notice that \(g^*(a) = g^*(b) = 0\). This means that no inflow or outflow condition needs to be prescribed to Eq. (11). The modified splitting allows us to solve the advection equation only for the interior points, i.e. \(x\in (a,b)\).

Remark

Notice that both problems (8a), (8b) have a variable coefficient advection. However, as shown in Sect. 5 the matrix associated to the space discretization of Problem (8a), despite the space dependent coefficient \(p_g\), is still banded. This is a property of the spectral space discretization that we employ.

3 Discrete transparent boundary conditions

When it comes to numerical simulations, a finite spatial domain is typically considered. Problem (1) is then transformed into the following boundary value problem

$$\begin{aligned} {\left\{ \begin{array}{ll} \partial _t u + g \partial _x u + \partial _x^3 u = 0, \quad (t,x)\in [0,T]\times (a,b),\\ u(0,x) = u^0(x),\\ u(t,x)|_{x=a} = u(t,a),\\ u(t,x)|_{x=b} = u(t,b),\\ \partial _x u(t,x)|_{x=b} = \partial _x u(t,b). \end{array}\right. } \end{aligned}$$
(13)

Due to the third order dispersion term, three boundary conditions are required. In particular, depending on the sign of the dispersion coefficient, we have either two boundary conditions at the right boundary and one at the left boundary or vice-versa. In this work we consider a positive dispersion coefficient. We assume g(x) constant for \(x\in \mathbb {R}\setminus [a,b]\) and that \(u^0(x)\) is a smooth initial value with compact support in [ab]. Transparent boundary conditions are established by considering (13) on the complementary unbounded domain \(\mathbb {R}\setminus (a,b)\). Let \(g_{a,b}\) be the values of g(x) in \((-\infty , a]\) and \([b,\infty )\), respectively. In the interval \((-\infty , a]\) we consider the problem

$$\begin{aligned} {\left\{ \begin{array}{ll} \partial _t u + g_a \partial _x u + \partial _x^3 u = 0, \quad (t,x)\in [0,T]\times (-\infty , a),\\ u(0,x) = 0,\\ u(t,x)|_{x=a} = u(t,a),\\ \lim _{x\rightarrow -\infty } u(t,x) = 0,\\ \end{array}\right. } \end{aligned}$$
(14)

whereas in the interval \([b,\infty )\) we consider the problem

$$\begin{aligned} {\left\{ \begin{array}{ll} \partial _t u + g_b \partial _x u + \partial _x^3 u = 0, \quad (t,x)\in [0,T]\times (b,\infty ),\\ u(0,x) = 0,\\ u(t,x)|_{x=b} = u(t,b),\\ \lim _{x\rightarrow +\infty } u(t,x) = 0. \end{array}\right. } \end{aligned}$$
(15)

The initial value u(0, x) is set to 0 because \(u^0(x)\) has compact support in [ab]. The boundary conditions at \(x\rightarrow \pm \infty \) are set to 0 because we ask for \(u\in L^2(\mathbb {R})\). Therefore, the solution u must decay for \(x\rightarrow \pm \infty \). We focus our attention on (14) and impose discrete transparent boundary conditions at \(x=a\). A similar procedure can be applied to (15).

The mathematical tool we employ in order to impose discrete transparent boundary conditions to (13) is the \(\mathcal {Z}\)-transform. We recall the definition and the main properties of the \(\mathcal {Z}\)-transform, which are used extensively in this section. For more details we refer the reader to [3]. The \(\mathcal {Z}\)-transform requires an equidistant time discretization. Given a sequence \(\mathbf {u} = \{u^l\}_l\), its \(\mathcal {Z}\)-transform is defined by

$$\begin{aligned} \hat{u}(z):=\mathcal {Z}\left( \mathbf {u}\right) (z) = \sum _{l=0}^{\infty } z^{-l} u^l,\quad z\in \mathbb {C},\,|z|>\rho \ge 1, \end{aligned}$$
(16)

where \(\rho \) is the radius of convergence of the series. The following properties hold

  1. Linearity

    for \(\alpha ,\beta \in \mathbb {R}\), \(\mathcal {Z}(\alpha \mathbf {u}+\beta \mathbf {v})(z) = \alpha \hat{u}(z)+ \beta \hat{v}(z)\);

  2. Time advance

    for \(k>0\), \(\mathcal {Z}(\{u^{l+k}\}_{l\ge 0})(z) = z^k\hat{u}(z)-z^k\sum _{l=0}^{k-1}z^{-l}u^l\);

  3. Convolution

    \(\mathcal {Z}\big (\mathbf {u} *_d \mathbf {v}\big )(z) = \hat{u}(z)\hat{v}(z)\);

where \(*_d\) denotes the discrete convolution

$$\begin{aligned} (\mathbf {u} *_d \mathbf {v})^m:= \sum _{j=0}^m u^jv^{m-j},\quad m\ge 0. \end{aligned}$$

Remark

The Peaceman–Rachford scheme given in (10)–(12) reduces to a Crank–Nicolson scheme outside the computational domain [ab]. Therefore, discrete transparent boundary conditions are derived discretizing (14) by the Crank–Nicolson method.

Discretizing (14) by the Crank–Nicolson method, gives

$$\begin{aligned} \left( I + \frac{\tau g_a}{2}\partial _x + \frac{\tau }{2}\partial _x^3\right) u^{m+1}(x) = \left( I - \frac{\tau g_a}{2}\partial _x - \frac{\tau }{2}\partial _x^3\right) u^{m}(x),\quad u^0(x) = 0. \end{aligned}$$
(17)

Let \(\mathbf {u}(x) = \{u^k(x)\}_k\) be the time sequence (x plays the role of a parameter) associated to the Crank–Nicolson scheme (17). Then its \(\mathcal {Z}\)-transform is given by

$$\begin{aligned} \hat{u}(x,z):=\mathcal {Z}\{\mathbf {u}(x)\}(z) = \sum _{l=0}^{\infty } u^l(x) z^{-l}. \end{aligned}$$

Taking the \(\mathcal {Z}\)-transform of (17) gives

$$\begin{aligned} z\left( I + \frac{\tau g_a}{2}\partial _x + \frac{\tau }{2}\partial _x^3\right) \hat{u}(x) = \left( I - \frac{\tau g_a}{2}\partial _x - \frac{\tau }{2}\partial _x^3\right) \hat{u}(x),\quad x\in (-\infty ,a], \end{aligned}$$
(18)

where we used the time advance property of the \(\mathcal {Z}\)-transform and \(u^0(x) =0\). In particular, (18) is an ODE in the variable x. It can be solved by using the ansatz

$$\begin{aligned} \hat{u}(x,z) = c_1(z)\mathrm {e}^{\lambda _1(z)x} + c_2(z)\mathrm {e}^{\lambda _2(z)x} + c_3(z)\mathrm {e}^{\lambda _3(z)x}, \end{aligned}$$

where \(\lambda _i\), \(i=1,2,3\) are the roots of the characteristic polynomial associated to (18):

$$\begin{aligned} \lambda ^3 + g_a\lambda + \frac{2}{\tau }\frac{1-z^{-1}}{1+z^{-1}}. \end{aligned}$$

The roots \(\lambda _i\) can be ordered such that \(\mathrm {Re}\, \lambda _{1}<0\) and \(\mathrm {Re}\, \lambda _{2,3}>0\), see [6]. By the decay condition \(\hat{u}(x,z)\rightarrow 0\) for \(x\rightarrow -\infty \), we obtain \(c_1(z) = 0\) and

$$\begin{aligned} \hat{u}(x,z)&= c_2(z) \mathrm {e}^{\lambda _2(z)x} + c_3(z)\mathrm {e}^{\lambda _3(z)x},\quad x\in (-\infty ,a]. \end{aligned}$$
(19)

Since \(c_2\) and \(c_3\) are unknown, the way to compute the discrete transparent boundary conditions is to make use of the derivatives of \(\hat{u}\) to derive an implicit formulation. Computing the first and second derivatives of \(\hat{u}\) gives

$$\begin{aligned} \partial _x\hat{u}(x,z)&= \lambda _2(z)c_2(z)\mathrm {e}^{\lambda _2(z)x} + \lambda _3(z)c_3(z)\mathrm {e}^{\lambda _3(z)x},\\ \partial _x^2\hat{u}(x,z)&= \lambda ^2_2(z)c_2(z)\mathrm {e}^{\lambda _2(z)x} + \lambda ^2_3(z)c_3(z)\mathrm {e}^{\lambda _3(z)x}.\\ \end{aligned}$$

We then have

$$\begin{aligned} \partial _x^2\hat{u}(x) = \left( \lambda _2+\lambda _3\right) \partial _x\hat{u}(x) - \lambda _2\lambda _3 \hat{u}(x). \end{aligned}$$
(20)

In the latter equation the z dependence is omitted. The roots \(\lambda _i\), \(i=1,2,3\) satisfy

$$\begin{aligned} \lambda _1 + \lambda _2 + \lambda _3&= 0,\\ \lambda _1\lambda _2 + \lambda _1\lambda _3 + \lambda _2\lambda _3&= g_a. \end{aligned}$$

This allows us to rewrite Eq. (20) in terms of the root \(\lambda _1\) to obtain

$$\begin{aligned} \partial _x^2\hat{u}(x) + \lambda _1\partial _x\hat{u}(x) + (g_a + \lambda _1^2) \hat{u}(x) = 0. \end{aligned}$$
(21)

We can finally determine the value of \(u^{m+1}(a)\) by evaluating (21) at \(x=a\) and taking the inverse \(\mathcal {Z}\)-transform. Let

$$\begin{aligned} \mathbf {Y}_1 = \mathcal {Z}^{-1}\left( z\mapsto \lambda _1(z)\right) \quad \text {and}\quad \mathbf {Y}_2 = \mathcal {Z}^{-1}\left( z\mapsto \lambda _1^2(z)\right) , \end{aligned}$$

then

$$\begin{aligned} \partial _x^2u^{m+1}(a) + \left( \mathbf {Y}_1*_d \partial _x\mathbf {u}(a)\right) ^{m+1} + \left( \mathbf {Y}_2 *_d \mathbf {u}(a)\right) ^{m+1} + g_a u^{m+1}(a) = 0, \end{aligned}$$
(22)

where we used the convolution property of the \(\mathcal {Z}\)-transform. We remark that to compute \(u^{m+1}(a)\) we need to know \(\partial _x u^{m+1}(a)\) and \(\partial _x^2 u^{m+1}(a)\). Similarly, for problem (15), we obtain

$$\begin{aligned} \partial _x u^{m+1}(b) - \left( \mathbf {Y}_3*_d \mathbf {u}(b)\right) ^{m+1}&= 0, \end{aligned}$$
(23)
$$\begin{aligned} \partial _x^2 u^{m+1}(b) - \left( \mathbf {Y}_4*_d \mathbf {u}(b)\right) ^{m+1}&= 0, \end{aligned}$$
(24)

where

$$\begin{aligned} \mathbf {Y}_3 = \mathcal {Z}^{-1}\left( z\mapsto \sigma _1(z)\right) \quad \text {and}\quad \mathbf {Y}_4 = \mathcal {Z}^{-1}\left( z\mapsto \sigma _1^2(z)\right) \end{aligned}$$

with \(\sigma _1\) root of

$$\begin{aligned} \sigma ^3 + g_b \sigma + \frac{2}{\tau }\frac{1-z^{-1}}{1+z^{-1}},\quad \text {Re}\,\sigma _1 < 0. \end{aligned}$$

The time discrete numerical scheme to problem (13) becomes (for \(0\le m\le M-1\))

$$\begin{aligned}&u^* = \left( I-\frac{\tau }{2}p_g(x)\partial _x-\frac{\tau }{2}\partial _x^3\right) u^m, \end{aligned}$$
(25a)
$$\begin{aligned}&\left( I+\frac{\tau }{2}g^*\partial _x\right) u^{m+1/2} = \left( I-\frac{\tau }{2}g^*\partial _x \right) u^*, \end{aligned}$$
(25b)
$$\begin{aligned}&\left( I+\frac{\tau }{2}p_g(x)\partial _x + \frac{\tau }{2}\partial _x^3\right) u^{m+1} = u^{m+1/2}, \end{aligned}$$
(25c)
$$\begin{aligned}&u(0,x) = u^0(x), \end{aligned}$$
(25d)
$$\begin{aligned}&\partial _x^2 u^{m+1}(a) + Y_1^0\partial _x u(a)^{m+1} + (g_a + Y_2^0) u(a)^{m+1} = h_1^{m+1}, \end{aligned}$$
(25e)
$$\begin{aligned}&\partial _x u^{m+1}(b) - Y_3^0u(b)^{m+1} = h_2^{m+1}, \end{aligned}$$
(25f)
$$\begin{aligned}&\partial _x^2 u^{m+1}(b) - Y_4^0 u(b)^{m+1} = h_3^{m+1}, \end{aligned}$$
(25g)

where

$$\begin{aligned} \begin{aligned} h_1^{m+1}&=\sum _{k=1}^{m+1} Y_1^k \partial _x u^{m+1-k}(a) + Y_2^k u^{m+1-k}(a), \\ h_2^{m+1}&= \sum _{k=1}^{m+1} Y_3^k u^{m+1-k}(b),\\ h_3^{m+1}&= \sum _{k=1}^{m+1} Y_4^k u^{m+1-k}(b). \end{aligned} \end{aligned}$$

Equations (25a)–(25c) are the Peaceman–Rachford scheme. Equation (25d) is the initial data and Equations (25e)–(25g) are the discrete transparent boundary conditions.

Remark

(Computation of \(\mathbf {Y}_j\)) The quantities \(\mathbf {Y}_j\), \(j=1,\dots , 4\) are given by the inverse \(\mathcal {Z}\)-transform through Cauchy’s integral formula

$$\begin{aligned} \begin{aligned} \mathbf {Y}_j^m&= \frac{1}{2\pi \mathrm {i}}\oint _{S_r}\lambda _1^j(z)z^{m-1}\mathrm {d}\,z,\quad j=1,2,\\ \mathbf {Y}_{j+2}^m&= \frac{1}{2\pi \mathrm {i}}\oint _{S_r}\sigma _1^{j}(z)z^{m-1}\mathrm {d}\,z,\quad j=1,2, \end{aligned} \end{aligned}$$

where \(S_r\) is a circle with center 0 and radius \(r>\rho \), where \(\rho \) is the radius of convergence in (16). An exact evaluation of the contour integrals might be too complicated or infeasible. Therefore, we employ a numerical procedure in order to approximate these quantities. In this work we use the algorithm described in [13, Sec. 2.3], which results in stable and accurate results.

4 Stability of the semi-discrete scheme

For this section it is convenient to adopt a more compact notation. Thus, we write \(D_3 = p_g\partial _x + \partial _x^3\) and \(D = g^*\partial _x\). Then, the Peaceman–Rachford scheme (25a)–(25c) becomes

$$\begin{aligned} \begin{aligned} u^*&= \left( I-\frac{ \tau }{2}D_3\right) u^m,\\ \left( I+\frac{\tau }{2}D\right) u^{m+1/2}&= \left( I-\frac{\tau }{2}D\right) u^*,\\ \left( I+\frac{\tau }{2}D_3\right) u^{m+1}&= u^{m+1/2} \end{aligned} \end{aligned}$$

for \(m=0,\dots ,M-1\). The scheme can be rewritten separating the first step, i.e. when \(m=0\), as follows:

$$\begin{aligned} \begin{aligned} y^0&= \left( I-\frac{\tau }{2}D_3\right) u^0,\\ \left( I+\frac{\tau }{2}D_3\right) \left( I-\frac{\tau }{2}D_3\right) ^{-1} y^{m+1}&= \left( I+\frac{\tau }{2}D\right) ^{-1}\left( I-\frac{\tau }{2}D\right) y^m,\quad 0\le m\le M-2,\\ \left( I+\frac{\tau }{2}D\right) u^{M-1/2}&= \left( I-\frac{\tau }{2}D\right) y^{M-1},\\ \left( I+\frac{\tau }{2}D_3\right) u^{M}&= u^{M-1/2}. \end{aligned} \end{aligned}$$

Using the commutativity between \(I+\frac{\tau }{2}D_3\) and \(I-\frac{\tau }{2}D_3\) leads to

$$\begin{aligned} \left( I-\frac{\tau }{2}D_3\right) ^{-1} \left( I+\frac{\tau }{2}D_3\right) y^{m+1} = \left( I+\frac{\tau }{2}D\right) ^{-1}\left( I-\frac{\tau }{2}D\right) y^m. \end{aligned}$$
(26)

We now show that the semi-discrete numerical scheme (26) is stable. The proof follows a similar approach as in [13].

Theorem 4.1

(Stability) The semi-discrete numerical scheme (26) is stable if \(\partial _x g^*\in L^{\infty }(a,b)\) and \(\tau < 4/\Vert \partial _x g^*\Vert _{\infty } \).

Proof

Let \((\cdot ,\cdot )\) be the usual inner product on \(L^2(a,b)\) and \(\Vert \cdot \Vert \) the induced norm. We define \(w := \left( I+\frac{\tau }{2}D\right) ^{-1}\left( I-\frac{\tau }{2}D\right) y^m\). Then

$$\begin{aligned} \left( I+\frac{\tau }{2}D_3\right) y^{m+1} = \left( I-\frac{\tau }{2}D_3\right) w. \end{aligned}$$

Applying the inner product with \(y^{m+1} + w\) gives

$$\begin{aligned} (y^{m+1},y^{m+1} + w) + \frac{\tau }{2}(D_3\, y^{m+1},y^{m+1}+w) = (w,y^{m+1}+w)-\frac{\tau }{2}(D_3\,w,y^{m+1}+w) \end{aligned}$$

or equivalently

$$\begin{aligned} \Vert y^{m+1}\Vert ^2 - \Vert w\Vert ^2 = -\frac{\tau }{2} \left( D_3\,(y^{m+1}+w),y^{m+1}+w\right) . \end{aligned}$$

Integrating the right-hand side by parts gives

$$\begin{aligned}&\Vert y^{m+1}\Vert ^2 - \Vert w\Vert ^2 \nonumber \\&= -\frac{\tau }{2}\left[ \partial _x^2(y^{m+1}+w)\cdot (y^{m+1} + w) -\frac{1}{2}\left( \partial _x(y^{m+1} + w)\right) ^2 + \frac{1}{2}p_g(y^{m+1}+w)^2\right] _{x=a}^{x=b}\nonumber \\&\quad + \frac{\tau }{4}\left( \partial _x p_g\right) \cdot \Vert y^{m+1} + w\Vert ^2. \end{aligned}$$
(27)

Notice that \(\partial _x p_g\) is constant since \(p_g\) is a polynomial of degree 1. In order to complete the proof, a bound for \(\Vert w\Vert ^2\) is needed. By definition of w, we have

$$\begin{aligned} \left( I+\frac{\tau }{2}D\right) w = \left( I-\frac{\tau }{2}D\right) y^m. \end{aligned}$$
(28)

Taking the inner product with \(w+y^m\) gives

$$\begin{aligned} \Vert w\Vert ^2-\Vert y^m\Vert ^2 = -\frac{\tau }{2}(D(w+y^m),w+y^m). \end{aligned}$$

Integrating by parts and using the fact that \(g^*(a) = g^*(b) = 0\) gives

$$\begin{aligned} \begin{aligned} \Vert w\Vert ^2-\Vert y^m\Vert ^2&= \frac{\tau }{4}\left( (w+y^m)^2,\partial _x g^*\right) \\&\le \frac{\tau }{4}\Vert \partial _x g^*\Vert _{\infty }\left( \Vert w\Vert ^2 +\Vert y^m\Vert ^2\right) . \end{aligned} \end{aligned}$$

Using the hypothesis \(\tau <4/\Vert \partial _x g^*\Vert _{\infty }\) leads to

$$\begin{aligned} \Vert w\Vert ^2 \le \frac{1 + \frac{\tau }{4}\Vert \partial _x g^*\Vert _{\infty }}{1 - \frac{\tau }{4}\Vert \partial _x g^*\Vert _{\infty }}\Vert y^m\Vert ^2. \end{aligned}$$
(29)

Combining (27) with (29) gives the bound

$$\begin{aligned} \left( 1 -\frac{\tau }{4}|\partial _x p_g|\right) \Vert y^{m+1}\Vert ^2 \le B^m + \left( 1 +\frac{\tau }{4}|\partial _x p_g|\right) \frac{1 + \frac{\tau }{4}\Vert \partial _x g^*\Vert _{\infty }}{1- \frac{\tau }{4}\Vert \partial _x g^*\Vert _{\infty }}\Vert y^m\Vert ^2, \end{aligned}$$
(30)

where

$$\begin{aligned} B^m = -\tau \left[ 2\partial _x^2(u^{m+1})\cdot u^{m+1} -\left( \partial _x u^{m+1}\right) ^2 + g\cdot (u^{m+1})^2\right] _{x=a}^{x=b}. \end{aligned}$$

In the definition of \(B^m\) we used \(p_g(a) = g(a)\), \(p_g(b) = g(b)\) and

$$\begin{aligned} y^{m+1} + w = \left( I-\frac{\tau }{2}D_3\right) u^{m+1} + \left( I+\frac{\tau }{2}D_3\right) u^{m+1} = 2u^{m+1}. \end{aligned}$$

Multiplying both sides of (30) by \(1- \frac{\tau }{4}\Vert \partial _x g^*\Vert _{\infty }\) and taking the sum over m gives

$$\begin{aligned} \Vert y^{M}\Vert ^2 - \Vert y^0\Vert ^2\le c_1\sum _{m=0}^{M-1} B^m + c_2\sum _{m=0}^{M-1} \left( \Vert y^m\Vert ^2 + \Vert y^{m+1}\Vert ^2\right) \end{aligned}$$

with

$$\begin{aligned} c_1 = \frac{\left( 1- \frac{\tau }{4}\Vert \partial _x g^*\Vert _{\infty }\right) }{1 + \frac{\tau ^2}{16}|\partial _x p_g|\cdot \Vert \partial _x g^*\Vert _{\infty }}\ge 0,\quad c_2 = \frac{\frac{\tau }{4}\left( |\partial _x p_g|+ \Vert \partial _x g^*\Vert _{\infty }\right) }{ 1 + \frac{\tau ^2}{16}|\partial _x p_g|\cdot \Vert \partial _x g^*\Vert _{\infty }}\ge 0. \end{aligned}$$

By Lemma 4.1 the quantity \(\sum B^m\) is negative. Therefore,

$$\begin{aligned} \Vert y^{M}\Vert ^2 - \Vert y^0\Vert ^2\le c_2\sum _{m=0}^{M-1} \left( \Vert y^m\Vert ^2 + \Vert y^{m+1}\Vert ^2\right) \end{aligned}$$

and stability follows by Gronwall’s inequality since \(c_2 =\mathcal {O}(\tau )\). \(\square \)

Lemma 4.1

It holds \(\sum _{m=0}^{M-1} B^m \le 0\).

Proof

Consider

$$\begin{aligned} \sum _{m =0}^{M-1} B^m = \tau (B^M_a - B^M_b), \end{aligned}$$

where

$$\begin{aligned} B^M_a := \sum _{m=0}^{M-1} 2\partial _x^2u^{m+1}(a)\cdot u^{m+1}(a) -\left( \partial _xu^{m+1}(a)\right) ^2 + g(a)\,(u^{m+1}(a))^2 \end{aligned}$$

and

$$\begin{aligned} B^M_b :=\sum _{m=0}^{M-1} 2\partial _x^2u^{m+1}(b)\cdot u^{m+1}(b) -\left( \partial _x u^{m+1}(b)\right) ^2 + g(b)\,(u^{m+1}(b))^2. \end{aligned}$$

Inserting the discrete transparent boundary conditions (22)–(24) in \(B^M_a,\) \(B^M_b\) gives

$$\begin{aligned} \begin{aligned} B^M_a&= -\sum _{m=0}^{M-1} \left( 2\left( (\mathbf {Y_1}*_d\partial _x\mathbf {u}(a))^{m+1} +(\mathbf {Y_2}*_d\mathbf {u}(a))^{m+1} + \frac{g(a)}{2} u^{m+1}(a)\right) u^{m+1}(a)\right. \\&\quad \left. +\left( \partial _x u^{m+1}(a)\right) ^2\right) ,\\ B^M_b&= \sum _{m=0}^{M-1} \left( 2(\mathbf {Y_4}*_d\mathbf {u}(b))^{m+1} u^{m+1}(b) -\left( (\mathbf {Y_3}*_d\mathbf {u}(b))^{m+1}\right) ^2 + g(b)\,(u^{m+1}(b))^2\right) . \end{aligned} \end{aligned}$$

Let us extend the sequences \(B^M_a,\) \(B^M_b\) to infinity sequences by zero and apply Parseval’s identity

$$\begin{aligned} \sum _{m=-\infty }^{\infty } v_1^m\cdot \bar{v}_2^m = \frac{1}{2\pi }\int _0^{2\pi } \mathcal {Z}(v_1) (z)\cdot \overline{\mathcal {Z}(v_2)}(z)\Big |_{z = \mathrm {e}^{\mathrm {i}\theta }}\mathrm {d}\theta . \end{aligned}$$

We obtain

$$\begin{aligned} \begin{aligned}&B^M_a = \frac{1}{2\pi } \\&\quad \int _0^{2\pi } |z|^2\left\{ -\left( 2\lambda _1^2(z) + g(a)\right) |\hat{u}(a,z)|^2-|\partial _x\hat{u}(a,z)|^2 - 2\lambda _1(z)\partial _x\hat{u}(a,z) \overline{\hat{u}(a,z)}\right\} \Big |_{z=\mathrm {e}^{\mathrm {i}\theta }}\mathrm {d}\theta ,\\&\quad B^M_b = \frac{1}{2\pi } \int _0^{2\pi } |z|^2 \left\{ 2\sigma _1^2(z) - |\sigma _1(z)|^2 + g(b) \right\} |\hat{u}(b,z)|^2\Big |_{z=\mathrm {e}^{\mathrm {i}\theta }}\mathrm {d}\theta . \end{aligned}\nonumber \\ \end{aligned}$$
(31)

Notice that \(B^M_a\) and \(B^M_b\) are real values, therefore the imaginary parts of the right-hand sides in (31) must integrate to 0. Therefore,

$$\begin{aligned} \begin{aligned} B^M_a&= \frac{1}{2\pi } \int _0^{2\pi } |z|^2\left\{ -\left( 2\cdot \mathrm {Re}\,\lambda _1^2(z) - g(a)\right) |\hat{u}(a,z)|^2-|\partial _x\hat{u}(a,z)|^2 \right\} \Big |_{z=\mathrm {e}^{\mathrm {i}\theta }}\mathrm {d}\theta \\&\quad +\frac{1}{2\pi } \int _0^{2\pi } |z|^2\left\{ -2\cdot \mathrm {Re}\,\left( \lambda _1(z)\partial _x\hat{u}(a,z) \overline{\hat{u}(a,z)}\right) \right\} \Big |_{z=\mathrm {e}^{\mathrm {i}\theta }}\mathrm {d}\theta ,\\ B^M_b&= \frac{1}{2\pi } \int _0^{2\pi } |z|^2 \left( 2\cdot \mathrm {Re}\,\sigma _1^2(z) - |\sigma _1(z)|^2 + g(b) \right) |\hat{u}(b,z)|^2\Big |_{z=\mathrm {e}^{\mathrm {i}\theta }}\mathrm {d}\theta . \end{aligned} \end{aligned}$$
(32)

The quantities \(B^M_a\) and \(B^M_b\) are now in the same form as [13, Sect. 2.2], therefore the result follows by [7, Prop. 2.4]. \(\square \)

5 Spatial discretization: pseudo-spectral approach

The spatial discretization of problem (25a)–(25g) is carried out by a dual Petrov–Galerkin method. In particular, we follow the approach given in [19] for the dispersive part and the approach given in [20] for the variable coefficient advection. It is very well known that pseudo-spectral methods achieve high accuracy even for a modest number of collocation points N, provided the solution is smooth. However, these methods have to be carefully designed in order to obtain sparse mass and stiffness matrices in frequency space. Then, the associated linear system can be solved in \(\mathcal {O}(N)\) operations.

In the following description we assume, without loss of generality, \(a=-1\) and \(b=1\). The idea is to choose the dual basis functions of the dual Petrov–Galerkin formulation in such a manner that boundary terms from integration by parts vanish. Let us introduce a variational formulation for

$$\begin{aligned} u^*&= \left( I-\frac{\tau }{2}p_g\partial _x-\frac{\tau }{2}\partial _x^3\right) u^m, \end{aligned}$$
(33)
$$\begin{aligned} \left( I+\frac{\tau }{2}g^*\partial _x\right) u^{m+1/2}&= \left( I-\frac{\tau }{2}g^*\partial _x\right) u^*, \end{aligned}$$
(34)
$$\begin{aligned} \left( I+\frac{\tau }{2}p_g\partial _x + \frac{\tau }{2}\partial _x^3\right) u^{m+1}&= u^{m+1/2} \end{aligned}$$
(35)

so that the discrete transparent boundary conditions are satisfied. To this goal, let \(\mathcal {P}_N\) be the space of polynomials up to degree N. For (33) and (35) we introduce the dispersive space

$$\begin{aligned} \begin{aligned} V^d_N = \{\phi ^d\in \mathcal {P}_N| \partial _x^2 \phi ^d(a)+Y_1^0\partial _x \phi ^d(a)+\left( g_a+Y_2^0\right) \phi ^d(a)&= 0,\\ \partial _x \phi ^d(b)-Y_3^0\phi ^d(b)&= 0,\\ \partial _x^2 \phi ^d(b)-Y_4^0\phi ^d(b)&= 0\}. \end{aligned} \end{aligned}$$

The conditions in \(V^d_N\) collect the left-hand side of (25e)–(25g). Let \((u,v) = \int _{a}^b u(x)v(x)\,\mathrm {d}x\) be the usual \(L_2\) inner product. The dual space \(V_N^{d,*}\) is defined in the usual way, i.e. for every \(\phi ^d\in V_N^d\) and \(\psi ^d\in V_N^{d,*}\) it holds

$$\begin{aligned} (p_g\partial _x \phi ^d + \partial _x^3 \phi ^d,\psi ^d) = - (\phi ^d, \partial _x (p_g\psi ^d) + \partial _x^3 \psi ^d). \end{aligned}$$

Lemma 5.1

The dual space \(V_N^{d,*}\) of \(V_N^d\) is given by

$$\begin{aligned} \begin{aligned} V^{d,*}_N = \{\psi ^d\in \mathcal {P}_N| \partial _x^2 \psi ^d(b)-Y_3^0\partial _x \psi ^d(b)+\left( g_b+Y_4^0\right) \psi ^d(b)&= 0,\\ \partial _x \psi ^d(a)+Y_1^0\psi ^d(a)&= 0,\\ \partial _x^2 \psi ^d(a) - Y_2^0\psi ^d(a)&= 0\}. \end{aligned} \end{aligned}$$

Proof

Integrating \((p_g\partial _x \phi ^d,\psi ^d)\) by parts and integrating \((\partial _x^3 \phi ^d,\psi ^d)\) by parts three times gives

$$\begin{aligned} \begin{aligned} (p_g\partial _x \phi ^d + \partial _x^3 \phi ^d,\psi ^d)&= \int _{a}^{b} \left( p_g\partial _x \phi ^d(x) + \partial _x^3 \phi ^d(x) \right) \psi ^d(x)\, \mathrm {d}x \\&= p_g\cdot \phi ^d \cdot \psi ^d|_{x=a}^b + \partial _x^2 \phi ^d\cdot \psi ^d|_{x=a}^b - \partial _x \phi ^d \cdot \partial _x \psi ^d |_{x=a}^b \\&\quad +\phi ^d \cdot \partial _x^2 \psi ^d |_{x=a}^b - (\phi ^d, \partial _x (p_g\cdot \psi ^d) + \partial _x^3 \psi ^d). \end{aligned} \end{aligned}$$

We want the boundary terms to vanish. For \(x=b\) we have

$$\begin{aligned} \begin{aligned} 0&= p_g(b) \phi ^d(b) \psi ^d(b) + \partial _x^2 \phi ^d(b)\psi ^d(b) -\partial _x\phi ^d(b)\partial _x\psi ^d(b) + \phi ^d(b)\partial _x^2\psi ^d(b) \\&= \phi ^d(b)\cdot \left( \partial _x^2 \psi ^d(b) -Y_3^0\partial _x\psi ^d(b) + (g_b+Y_4^0)\psi ^d(b)\right) . \end{aligned} \end{aligned}$$

The last equality is obtained by substituting \(p_g(b) = g_b\) and using the relations given by the space \(V_N^d\) for \(\partial _x\phi ^d(b)\) and \(\partial _x^2\phi ^d(b)\). Similarly for \(x=a\) we have

$$\begin{aligned} \begin{aligned} 0&= p_g(a) \phi ^d(a) \psi ^d(a) + \partial _x^2 \phi ^d(a)\psi ^d(a) -\partial _x\phi ^d(a)\partial _x\psi ^d(a) + \phi ^d(a)\partial _x^2\psi ^d(a)\\&= \phi ^d(a)\cdot \left( \partial _x^2\psi ^d(a) - Y_2^0\psi ^d(a)\right) + \partial _x\phi ^d(a)\cdot \left( \partial _x\psi ^d(a) + Y_1^0\psi ^d(a)\right) , \end{aligned} \end{aligned}$$

which leads to the boundary relations of the dual space \(V_N^*\). \(\square \)

We proceed by introducing the advection space for (34):

$$\begin{aligned} V^a_N = \{\phi ^a\in \mathcal {P}_N\}. \end{aligned}$$

Notice that due to the variable coefficient \(g^*\) the space \(V^a_N\) is free from inflow or outflow conditions. The dual space \(V_N^{a,*}\) is defined so that for every \(\phi ^a\in V_N^a\) it holds

$$\begin{aligned} (g^*\partial _x \phi ^a,\psi ^a) = - \left( \phi ^a,\partial _x (g^* \psi ^a)\right) \end{aligned}$$

for every \(\psi ^a\in V_N^{a,*}\). The dual space \(V^{a,*}_N\) is \(\mathcal {P}_N\). Let \(L_j\) be the jth Legendre polynomial. We define

$$\begin{aligned} \begin{aligned} \phi ^d_j(x)&:= L_j(x) + \alpha _jL_{j+1}(x) + \beta _j L_{j+2}(x) + \gamma _j L_{j+3}(x),\quad 0\le j\le N-3,\\ \psi ^d_j(x)&:= L_j(x) + \alpha _j^*L_{j+1}(x) + \beta _j^* L_{j+2}(x) + \gamma _j^* L_{j+3}(x),\quad 0\le j\le N-3,\\ \phi ^a_j(x)&:= L_j(x),\quad 0\le j\le N, \\ \psi ^a_j(x)&:= L_j(x),\quad 0\le j\le N, \\ \end{aligned} \end{aligned}$$
(36)

where the coefficients \(\alpha _j,\beta _j,\gamma _j,\alpha _j^*,\beta _j^*,\gamma _j^*\) are chosen in such a way that \(\phi _j^d\), \(\psi _j^d\) belong to \(V_N^d\), \(V_N^{d,*}\), respectively, see “Appendix A”. The sequences \(\{\phi _j^d\}_{j=0}^{N-3}\) and \(\{\psi _j^d\}_{j=0}^{N-3}\) are a basis of \(V_N^d\) and \(V_N^{d,*}\) respectively. We are now ready to consider the variational formulation.

5.1 Variational formulation

The dual Petrov–Galerkin formulation of (33) reads: find \(u^*\in \mathcal {P}_N\) such that

$$\begin{aligned} (u^*,\psi ^d_j) = \left( \left( I-\frac{\tau }{2}p_g\partial _x-\frac{\tau }{2}\partial _x^3\right) u^m,\psi ^d_j\right) \end{aligned}$$
(37)

holds for every \(\psi ^d_j\in V_N^{d,*}\), \(j=0,\dots ,N-3\). In general the function \(u^m\) does not belong to the space \(V_N^d\). Indeed \(u^m\) satisfies the discrete transparent boundary conditions

$$\begin{aligned} \begin{aligned} \partial _x^2 u^{m}(a) + Y_1^0\partial _x u(a)^{m} +\left( g_a + Y_2^0\right) u(a)^{m}&= h_1^m,\\ \partial _x u^{m}(b) - Y_3^0u(b)^{m}&= h_2^m,\\ \partial _x^2 u^{m}(b) - Y_4^0 u(b)^{m}&= h_3^m. \end{aligned} \end{aligned}$$

However, we can write \(u^m = u^m_h + p_2^m\), where \(u^m_h\in V_N^d\) and \(p_2^m\) is the unique polynomial of degree two such that

$$\begin{aligned} \begin{aligned} \partial _x^2 p_2^{m}(a) + Y_1^0 \partial _xp_2^{m}(a) + \left( g_a + Y_2^0\right) p_2^{m}(a)&= h_1^m,\\ \partial _x p_2^{m}(b) - Y_3^0 p_2^{m}(b)&= h_2^m,\\ \partial _x^2 p_2^{m}(b) - Y_4^0 p_2^{m}(b)&= h_3^m. \end{aligned} \end{aligned}$$
(38)

The function \(u^*\) also does not belong to the space. Similarly, we can write \(u^* = u^*_h + p_2^*\). We assume that \(u^*\) satisfies the same boundary conditions as \(u^m\), therefore \(p^*_2 = p^m_2\). We thus obtain

$$\begin{aligned} (u^*_h,\psi ^d_j) = \left( \left( I-\frac{\tau }{2}p_g\partial _x -\frac{\tau }{2}\partial _x^3\right) u^m_h,\psi ^d_j\right) +\Big (\underbrace{p_2^m-p_2^*}_{=0} -\frac{\tau }{2}p_g\partial _x p_2^m,\psi _j^d\Big ). \end{aligned}$$
(39)

We proceed with the dual Petrov–Galerkin formulation of (34). Find \(u^{m+1/2}\in \mathcal {P}_N\) such that

$$\begin{aligned} \left( \left( I+\frac{\tau }{2}g^*\partial _x\right) u^{m+1/2},\psi ^a_j\right) = \left( \left( I-\frac{\tau }{2}g^*\partial _x\right) u^*,\psi _j^a\right) \end{aligned}$$
(40)

holds for every \(\psi ^a_j\in V_N^{a,*}\), \(j=0,\dots ,N\). Notice that \(u^*, u^{m+1/2}\in V_N^a\). So, differently from the dispersive case, we obtain the solution \(u^{m+1/2}\) without performing any shift.

Similarly to (33), the dual Petrov–Galerkin formulation of (35) reads: find \(u^{m+1}\in \mathcal {P}_N\) such that

$$\begin{aligned} \left( \left( I+\frac{\tau }{2}p_g\partial _x+\frac{\tau }{2}\partial _x^3\right) u_h^{m+1},\psi ^d_j\right) = \left( u^{m+1/2} - p_2^{m+1} -\frac{\tau }{2}p_g\partial _x p^{m+1}_2,\psi _j^d\right) \end{aligned}$$
(41)

holds for every \(\psi ^d_j\in V_N^{d,*}\), \(j=0,\dots ,N-3\).

5.2 Implementation in frequency space

This section is dedicated to compute the mass and stiffness matrices for (39)–(41). When it comes to numerical implementation, the \(L^2\) inner product (uv) needs to be approximated. We use two different discrete inner products for the spaces \(V^d_N\) and \(V_N^a\). This choice is motivated by the fact that the spaces \(V_N^d\) and \(V_N^a\) satisfy different boundary conditions.

Definition

(Dispersive inner product) Let \(\langle \cdot ,\cdot \rangle _N^d\) be the dispersive inner product defined as

$$\begin{aligned} {\begin{matrix} \langle u,v \rangle _N^d := \sum _{\ell = 2}^{N-1} &{} w_{\ell }u(y_{\ell })v(y_{\ell }) \\ &{} + w_1u(-1)v(-1) + w_{N}u(1)v(1) + w'_{N}\partial _y \left( u(y)v(y)\right) \bigg | _{y=1}, \end{matrix}} \end{aligned}$$
(42)

where \(y_l\) are the roots of the Jacobi polynomial \(P^{(2,1)}_{N-2}(y)\) and \(w_l\) the associated weights.

Definition

(Advection inner product) Let \(\langle \cdot ,\cdot \rangle _N^a\) be the advection inner product defined as

$$\begin{aligned} \langle u,v\rangle _N^a := \sum _{\ell = 2}^{N+2}w_{\ell }u(y_{\ell })v(y_{\ell }) \end{aligned}$$
(43)

where \(y_l\) are the roots of the Jacobi polynomial \(P^{(0,0)}_{N+1}(y)\) and \(w_l\) the associated weights.

We have \((u,v) = \langle u,v\rangle _N^d\) for all polynomials u, v such that \(\deg u + \deg v \le 2N-2\) and \((u,v) = \langle u,v\rangle _N^a\) for all polynomials u, v such that \(\deg u + \deg v \le 2N+1\). For more details about generalized quadrature rules, we refer the reader to [16].

Stiffness and mass matrices for (39), (41) Since \(u^m_h\in V_N^d\), we can express it as linear combination of \(V_N^d\) basis functions, i.e.

$$\begin{aligned} u^m_h(x) = \sum _{k=0}^{N-3} \tilde{u}_{h,k}^{m,d}\phi ^d_k(x). \end{aligned}$$
(44)

The first step is to obtain the frequency coefficients \(\tilde{u}_{h,k}^{m,d}\) in (44). We take the dispersive inner product on both sides

$$\begin{aligned} \langle u^m_h,\psi _j^d\rangle ^d_N = \sum _{k=0}^{N-3} \tilde{u}_{h,k}^{m,d} \langle \phi ^d_k,\psi ^d_j\rangle ^d_N. \end{aligned}$$
(45)

The mass matrix is

$$\begin{aligned} \mathbf {M}^d\in \mathbb {R}^{(N-2)\times (N-2)},\quad \mathbf {M}^d_{kj} := \langle \phi ^d_k,\psi ^d_j\rangle _N^d. \end{aligned}$$

Using the orthogonality relation between \(\phi ^d_k\) and \(\psi ^d_j\) gives \(\langle \phi ^d_k,\psi ^d_j\rangle ^d_N = 0\) if \(|k-j|>3\) and \(j+k\le 2N-8\), see “Appendix B”. Then, \(\mathbf {M}^d\) is a 7-diagonal matrix. Equation (45) in matrix form reads

$$\begin{aligned} \langle u^m_h,\psi _j^d\rangle _N^d = [(\mathbf {M}^d)^T\tilde{\mathbf {u}}_{h}^{m,d}]_j. \end{aligned}$$
(46)

The left-hand side of (46) can also be written in matrix form:

$$\begin{aligned} \begin{aligned} \langle u^m_h,\psi _j^d\rangle _N^d&= \sum _{\ell = 2}^{N-1} w_{\ell }u^m_h(y_{\ell })\psi _j^d(y_{\ell }) \\&\quad + \underbrace{w_1u^m_h(-1)\psi ^d_j(-1) + w_{N}u^m_h(1)\psi ^d_j(1) + w'_{N}\partial _y\left( u^m_h(y)\psi ^d_j(y)\right) \bigg |_{y=1}}_{\mathbf {b}_j} \\&= [\Psi ^{d^T}\Omega \,\mathbf {u}^m_h]_j + \mathbf {b}_j, \end{aligned} \end{aligned}$$

where

$$\begin{aligned} \Psi ^d = \begin{bmatrix} \psi ^d_0(y_2) &{} \dots &{} \psi ^d_{N-3}(y_2)\\ \psi ^d_0(y_3) &{} \dots &{}\psi ^d_{N-3}(y_3)\\ \vdots &{} &{} \vdots \\ \psi ^d_0(y_{N-1}) &{} \dots &{} \psi ^d_{N-3}(y_{N-1}) \end{bmatrix},\quad \Omega = \text {diag}\begin{bmatrix} w_2\\ \vdots \\ w_{N-1} \end{bmatrix},\quad \mathbf {u}^m_h = \begin{bmatrix} u^m_h(y_2)\\ \vdots \\ u^m_h(y_{N-1})\\ \end{bmatrix}. \end{aligned}$$

We obtain the frequency coefficients

$$\begin{aligned} \tilde{\mathbf {u}}_h^{d,m} = (\mathbf {M}^{d})^{-T}\left( \Psi ^{d^T}\Omega \,\mathbf {u}^m_h+\mathbf {b}\right) . \end{aligned}$$

The second step is to compute the stiffness matrix and the frequency coefficients of the second term of the addition in (39). The stiffness matrix is

$$\begin{aligned} \mathbf {S}^d\in \mathbb {R}^{(N-2)\times (N-2)},\quad \mathbf {S}^d_{kj} =\langle p_g\partial _x \phi _k^d + \partial ^3_x\phi ^d_k,\psi ^d_j\rangle _N^d. \end{aligned}$$

Lemma 5.2

\(\mathbf {S}^d\) is a 7-diagonal matrix.

Proof

We now that \(\phi ^d_k\) is a polynomial of degree \(k+3\). Therefore, \( q(x):= p_g(x)\partial _x \phi _k^d(x) + \partial ^3_x\phi ^d_k(x)\) is a polynomial of degree \(\le k+3\). We write q as a linear combination of Legendre polynomials up to degree \(k+3\):

$$\begin{aligned} q(x) = \sum _{i=0}^{k+3} q_i L_i(x). \end{aligned}$$

Let us consider the dispersive inner product \(\langle q,\psi ^d_j\rangle ^d_N\) and \(k+3<j\). Then,

$$\begin{aligned} \langle q,\psi ^d_j \rangle ^d_N = \sum _{i=0}^{k+3}q_i \langle L_i,\psi ^d_j \rangle ^d_N = \sum _{i=0}^{k+3}q_i \langle L_i,L_j + \alpha ^*_j L_{j+1} + \beta ^*_jL_{j+2} + \gamma ^*_j L_{j+3}\rangle ^d_N = 0. \end{aligned}$$

The last equation follows from the definition of \(\psi ^d_j\) and the orthogonality property of the Legendre polynomials. Let \(j < k+3\) with \(k+j\le 2N-8\), then (see “Appendix B”)

$$\begin{aligned} \langle q,\psi ^d_j\rangle ^d_N = \langle p_g\partial _x \phi _k^d + \partial ^3_x\phi ^d_k, \psi ^d_j\rangle ^d_N = -\langle \phi _k^d, \partial _x(p_g\psi _j^d)+\partial _x^3\psi _j^d\rangle ^d_N. \end{aligned}$$

The polynomial \(\tilde{q} = \partial _x(p_g\psi _j^d)+\partial _x^3\psi _j^d\) is of degree j. Similarly to q, we obtain \(\langle \phi _k^d,\tilde{q}\rangle ^d_N=0\) and the result follows. \(\square \)

The frequency coefficients of the second term on the right-hand side of (39) are given by

$$\begin{aligned} \tilde{\mathbf {p}}^m\in \mathbb {R}^{N-2},\quad \tilde{\mathbf {p}}^m_j = \langle p_g\partial _x p_2^m,\psi _j^d\rangle _N^d,\quad j=0,\dots ,N-3. \end{aligned}$$

Notice that \(p_g\partial _xp_2^m\) is a polynomial of degree 2. Therefore, it can be written as a linear combination of the Legendre polynomials \(L_0\), \(L_1\) and \(L_2\). Using the orthogonality property of Legendre polynomials we obtain \(\langle p_g\partial _xp_2^m,\psi _j^d\rangle _N^d=0\) for \(j>2\). Problem (39) is equivalent to

$$\begin{aligned} (\mathbf {M}^d)^{T} \tilde{\mathbf {u}}^{*,d}_h = \left( \mathbf {M}^d-\frac{\tau }{2} \mathbf {S}^d\right) ^T\tilde{\mathbf {u}}^{m,d}_h -\frac{\tau }{2}\tilde{\mathbf {p}}^m. \end{aligned}$$
(47)

A similar procedure applies to (41), where we obtain

$$\begin{aligned} \left( \mathbf {M}^d + \frac{\tau }{2}\mathbf {S}^d\right) ^T\tilde{\mathbf {u}}^{m+1,d}_h = \tilde{\mathbf {u}}^{m+1/2,d}-\tilde{\mathbf {p}}_2^{m+1} -\frac{\tau }{2}\tilde{\mathbf {p}}^{m+1} \end{aligned}$$
(48)

with

$$\begin{aligned} \tilde{\mathbf {p}}^{m+1}_{2}\in \mathbb {R}^{N-2},\quad \tilde{\mathbf {p}}^{m+1}_{2,j} = \langle p^{m+1}_2,\psi ^d_j\rangle ^d_N\quad \text {for } j = 0,\dots ,N-3. \end{aligned}$$

Both linear systems (47)-(48) can be solved in \(\mathcal {O}(N)\) operations since \(\mathbf {M}^d\) and \(\mathbf {S}^d\) are 7-diagonal matrices.

Stiffness and mass matrices for (40) We can express the functions \(u^*\) and \(u^{m+1/2}\) as linear combinations of \(V_N^a\) basis functions, i.e.

$$\begin{aligned} u^*(x)&= \sum _{k=0}^{N} \tilde{u}_{k}^{*,a}\phi ^a_k(x), \end{aligned}$$
(49)
$$\begin{aligned} u^{m+1/2}(x)&= \sum _{k=0}^{N} \tilde{u}_{k}^{m+1/2,a}\phi ^a_k(x). \end{aligned}$$
(50)

Similarly to the dispersive case, we need the frequency coefficients in (49), (50). We take the advection inner product in (49), (50) on both sides

$$\begin{aligned} \langle u^*,\psi _j^a\rangle ^a_N&= \sum _{k=0}^{N} \tilde{u}_{k}^{*,a}\langle \phi ^a_k,\psi ^a_j\rangle ^a_N, \end{aligned}$$
(51)
$$\begin{aligned} \langle u^{m+1/2},\psi ^a_j\rangle _N^a&= \sum _{k=0}^{N} \tilde{u}_{k}^{m+1/2,a}\langle \phi ^a_k,\psi ^a_j\rangle _N^a. \end{aligned}$$
(52)

Using the orthogonality relation between \(\phi ^a_k\) and \(\psi ^a_j\) gives \(\langle \phi ^a_k,\psi ^a_j\rangle ^a_N = 0\) if \(k\ne j\). Then, the mass matrix

$$\begin{aligned} \mathbf {M}^a\in \mathbb {R}^{(N+1)\times (N+1)},\quad \mathbf {M}^a_{kj} = \langle \phi _k^a,\psi _j^a\rangle _N^a \end{aligned}$$

is a diagonal matrix. Finally, Problem (40) is equivalent to

$$\begin{aligned} \left( \mathbf {M}^a + \frac{\tau }{2}\mathbf {S}^a\right) ^T\tilde{\mathbf {u}}^{m+1/2,a} = \left( \mathbf {M}^a - \frac{\tau }{2}\mathbf {S}^a\right) ^T\tilde{\mathbf {u}}^{*,a} \end{aligned}$$
(53)

with the stiffness matrix \(\mathbf {S}^a\in \mathbb {R}^{(N+1)\times (N+1)}\) defined by

$$\begin{aligned} \mathbf {S}^a_{kj} = \langle g^*\partial _x \phi _k^a,\psi _j^a\rangle _N^a. \end{aligned}$$
(54)

The stiffness matrix \(\mathbf {S}^a\) is in general a full matrix. A direct inversion of (53) requires \(\mathcal {O} (N^3)\) operations, thus is not advisable. Applying an iterative scheme is preferable, but multiplying the matrix \(\mathbf {S}^a\) with a vector costs \(\mathcal O(N^2)\) operations. A more efficient way is to compute \(g^*\partial _x u^*\) (and \(g^*\partial _x u^{m+1/2}\)) in the physical space at the advection collocation points. The point-wise multiplication with \(g^*\) costs only \(\mathcal O(N)\) operations. The result is then transformed back to the frequency space. Transforming back and forth to the frequency space can be done efficiently by employing the discrete Lagrange transform (DLT) and the inverse discrete Lagrange transform (IDLT) developed in [14], see “Appendix C”.

Remark

For the special case where \(g^*\) is a polynomial of degree n, the stiffness matrix \(\mathbf {S}^a\) is banded with bandwidth less or equal to 2n. This implies that for a small n the linear system (53) is sparse and can be solved in \(\mathcal O(N)\) operations without switching from the frequency to the physical space.

Transition matrices In order to connect (53) to (47) and (48), it is necessary to transfer information from the dispersive space to the advection space and vice-versa. In particular, the aim is to translate the frequency coefficients from the dispersive space to the advection space in an efficient way. Let

$$\begin{aligned} \begin{aligned}&\mathbf {M}^{da}\in \mathbb {R}^{(N-2)\times (N+1)},\quad \mathbf {M}^{da}_{kj} = \langle \phi _k^d,\psi _j^a\rangle _N^a,\\&\mathbf {M}^{ad}\in \mathbb {R}^{(N+1)\times (N-2)},\quad \mathbf {M}^{ad}_{kj} = \langle \phi _k^a,\psi _j^d\rangle _N^d. \end{aligned} \end{aligned}$$

By using the orthogonality property of Legendre polynomials, one can prove that \(\mathbf {M}^{da}\) and \(\mathbf {M}^{ad}\) are 4-diagonal matrices. Consider

$$\begin{aligned} \langle u^*,\psi ^a_j\rangle _N^a = \sum _{k=0}^{N} \tilde{u}_{k}^{*,a}\langle \phi ^a_k,\psi ^a_j\rangle _N^a\quad \text {and}\quad \langle u^*,\psi ^a_j\rangle _N^a= \sum _{k=0}^{N-3} \tilde{u}_{k}^{*,d}\langle \phi ^d_k,\psi ^a_j\rangle _N^a, \end{aligned}$$

for \(j=0,\dots ,N.\) Then,

$$\begin{aligned} (\mathbf {M}^a)^T\tilde{\mathbf {u}}^{*,a} = (\mathbf {M}^{da})^T\tilde{\mathbf {u}}^{*,d}. \end{aligned}$$

The frequency coefficients \(\tilde{\mathbf {u}}^{*,a}\) are obtained directly from the coefficients \(\tilde{\mathbf {u}}^{*,d}\) in \(\mathcal {O}(N)\) operations. Similarly, consider

$$\begin{aligned}&\langle u^{m+1/2,d},\psi ^d_j\rangle _N^d = \sum _{k=0}^{N-3}\tilde{u}_{k}^{m+1/2,d}\langle \phi ^d_k,\psi ^d_j\rangle _N^d\quad \text {and}\\&\quad \langle u^{m+1/2},\psi ^d_j\rangle _N^d=\sum _{k=0}^{N-1}\tilde{u}_{k}^{m +1/2,a}\langle \phi ^a_k,\psi ^d_j\rangle _N^d, \end{aligned}$$

for \(j=0,\dots , N-3\). Then

$$\begin{aligned} (\mathbf {M}^d)^T\tilde{\mathbf {u}}^{m+1/2,d} = (\mathbf {M}^{ad})^T\tilde{\mathbf {u}}^{m+1/2,a}. \end{aligned}$$

The coefficients \(\tilde{\mathbf {u}}^{m+1/2,d}\) can be directly obtained from \(\tilde{\mathbf {u}}^{m+1/2,a}\) in \(\mathcal {O}(N)\) operations.

Full discretization The implementation in frequency space results in

$$\begin{aligned} (\mathbf {M}^d)^T \tilde{\mathbf {u}}^{*,d}_h&= \left( \mathbf {M}^d-\frac{\tau }{2} \mathbf {S}^d\right) ^T\tilde{\mathbf {u}}^{m,d}_h -\frac{\tau }{2}\tilde{\mathbf {p}}^m, \end{aligned}$$
(55)
$$\begin{aligned} (\mathbf {M}^a)^T\tilde{\mathbf {u}}^{*,a}&= (\mathbf {M}^{da})^T(\tilde{\mathbf {u}}^{*,d}_h + \tilde{\mathbf {p}}_2^{m}), \end{aligned}$$
(56)
$$\begin{aligned} \left( \mathbf {M}^a + \frac{\tau }{2}\mathbf {S}^a\right) ^T\tilde{\mathbf {u}}^{m+1/2,a}&= \left( \mathbf {M}^a - \frac{\tau }{2}\mathbf {S}^a\right) ^T\tilde{\mathbf {u}}^{*,a} \end{aligned}$$
(57)
$$\begin{aligned} (\mathbf {M}^d)^T\tilde{\mathbf {u}}^{m+1/2,d}&= (\mathbf {M}^{ad})^T\tilde{\mathbf {u}}^{m+1/2,a}, \end{aligned}$$
(58)
$$\begin{aligned} \left( \mathbf {M}^d + \frac{\tau }{2}\mathbf {S}^d\right) ^T\tilde{\mathbf {u}}^{m+1,d}_h&= \tilde{\mathbf {u}}^{m+1/2,d}-\tilde{\mathbf {p}}_2^{m+1} -\frac{\tau }{2}\tilde{\mathbf {p}}^{m+1}. \end{aligned}$$
(59)

The solution \(u^{m+1}(x)\) can be reconstructed by

$$\begin{aligned} u^{m+1}(x) = \sum _{k=0}^{N-3}\tilde{\mathbf {u}}_{h,k}^{m+1}\phi ^d_k(x) + p^{m+1}_2(x). \end{aligned}$$
(60)

6 Numerical results

In this section, we present numerical results that illustrate the theoretical investigations of the previous chapters. For that purpose, we consider

$$\begin{aligned} {\left\{ \begin{array}{ll} \partial _t u + g \partial _x u + \partial _x^3 u = 0, \quad (t,x)\in [0,T]\times \mathbb {R},\\ u(0,x) = u^0(x)\\ \end{array}\right. } \end{aligned}$$
(61)

with final time \(T=1\) and initial value \(u^0(x)=\mathrm {e}^{-x^2}\). We restrict (61) to the interval \((-6,6)\) and impose transparent boundary conditions at \(x=\pm 6\). The initial data is chosen such that \(|u^0(\pm 6)|\le 10^{-15}\).

For the numerical simulations, we employ a time discretization with constant step size

$$\begin{aligned} \tau = T/M,\quad t^m = \tau m,\quad 0\le m\le M \end{aligned}$$

and a space discretization given by the dual-Petrov–Galerkin variational formulation with N collocation points. We consider the error \(\ell ^2\) of the full discretization defined as

$$\begin{aligned} \Vert \text {err}\Vert _{\ell ^2} = \sqrt{\tau \sum _{m=1}^M (\text {err}^m)^2}, \end{aligned}$$

where

$$\begin{aligned} \text {err}^m = \sqrt{ \frac{ \sum _{j} \left( u^m_{\text {ref}}(x_j)-u^m_N(x_j)\right) ^2}{\sum _{j} \left( u^m_{\text {ref}}(x_j)\right) ^2} } \end{aligned}$$

is the relative \(\ell ^2\) spatial error computed at time \(t^m = \tau m\). The points \(x_j\) are chosen to be equidistant in \([-6,6]\) with \(0\le j\le J=2^7\). Finally, the function \(u^m_{\text {ref}}\) is either a reference solution or the exact solution, if available. The function \(u^m_N\) is the numerical solution at time \(t^m\) employing N collocation points.

Example 1

(Constant advection) We consider (61) with constant advection \(g(x)=6\). This is the same problem which is considered in [6]. The setting reduces the advection equation in the modified splitting (8b) to the identity map. Even if the time-splitting is trivial, for this particular problem the exact solution can be computed via Fourier transform, see [6]. Consequently the constant advection problem offers a good benchmark for testing the convergence of the proposed numerical method in that context.

Fig. 1
figure 1

Snapshots of the exact solution \(u_{\mathrm {ex}}\) and the numerical solution \(u^m_N\) for \(g=6\) and \(t=\frac{1}{4}\), \(\frac{1}{2}\), \(\frac{3}{4}\), 1 with \(\tau =2^{-12}\). The number of collocation points is set to \(N=2^6\). We notice that the cross marks representing the exact solution lie on the numerical solution

In Fig. 1 snapshots of the numerical solution \(u^m_N\) for \(t = \frac{1}{4},\) \(\frac{1}{2},\) \(\frac{3}{4}\), 1 and \(\tau = 2^{-12}\) are shown. Notice that the numerical solution “leaves” the domain at the boundary \(x=-6\) without any reflection. As time increases the solution moves to the right and re-enters the computational domain. Finally, the solution matches the boundary at \(x=6\) without any reflection.

In Table 2 the full discretization error between the numerical solution and the exact solution varying N and M is reported. In particular, in Table 2 (left) the number of time steps M is fixed to \(2^{12}\) and the number of collocation points N is varying from 24 to 40. In this way the time discretization error is small enough to be negligible with respect to the spatial error. The value \(\alpha \) denotes the slope of the line obtained by connecting two subsequent error values and varying N in a semi-logarithmic plot. More specifically, let \(N_1\) and \(N_2\) with \(N_1<N_2\) be two subsequent values of N and \(\Vert \mathrm {err}_1\Vert _{\ell ^2}\), \(\Vert \mathrm {err}_2\Vert _{\ell ^2}\) the associated error values. Then

$$\begin{aligned} \frac{\Vert \mathrm {err}_2\Vert _{\ell ^2}}{\Vert \mathrm {err}_1\Vert _{\ell ^2}} = \exp \left( -\alpha \cdot (N^2_2-N^2_1)\right) . \end{aligned}$$

Notice that \(\alpha \) remains constant when N is varying, which confirms the spectral accuracy of the numerical scheme.

In Table 2 (right) the number of collocation points is fixed to \(2^6\) and the number of time steps M is varying from \(2^5\) to \(2^8\). In this way the space error is small enough to be negligible with respect to the time error. The value \(\beta \) denotes the slope of the line obtained connecting two subsequent error values and varying M in a double-logarithmic plot. More specifically, let \(M_1\) and \(M_2\) with \(M_1<M_2\) be two subsequent values of M and \(\Vert \mathrm {err}_1\Vert _{\ell ^2}\), \(\Vert \mathrm {err}_2\Vert _{\ell ^2}\) the associated error values. Then

$$\begin{aligned} \frac{\Vert \mathrm {err}_2\Vert _{\ell ^2}}{\Vert \mathrm {err}_1\Vert _{\ell ^2}}= \left( \frac{M_2}{M_1}\right) ^{-\beta }. \end{aligned}$$

We can clearly see \(\beta \approx 2\), which confirms second order accuracy in time.

Table 2 We present the full discretization error \(\Vert \mathrm {err}\Vert _{\ell ^2}\) for constant g

Example 2

We consider (61) with \(g(x) = - x^3/54 + x + 3\). As mentioned in Sect. 5.2, for g being a low degree polynomial, the stiffness matrix \({\mathbf {S}}^{a}\) results in a banded matrix. Therefore, the linear system associated to the advection equation can be solved in O(N) operations. The exact solution for this problem is not known, so we test the numerical solution \(u^m_N\) against a reference solution \(u^m_{\mathbf {\text {ref}}}\) computed using a significantly greater number of points (both in time and space).

Fig. 2
figure 2

Snapshots of the numerical solution \(u^m_N\) for \(g(x) = - x^3/54 + x + 3\) and \(t=\frac{1}{4}\), \(\frac{1}{2}\), \(\frac{3}{4}\), 1 with \(\tau =2^{-12}\). The number of collocation points is set to \(N=2^6\)

In Fig. 2 snapshots of the numerical solution \(u^m_N\) for \(t = \frac{1}{4}\), \(\frac{1}{2}\), \(\frac{3}{4}\), 1 are shown. The solution is dragged to the right with an increasing speed. No appreciable reflections can be seen at the boundaries. Similarly to example 1, we report in Table 3 full discretization errors varying N and M with respect to a reference solution \(u^m_{\text {ref}}\) computed using \(N_{\text {ref}}=2^6\) and \(M_{\text {ref}}=2^{12}\).

Example 3

We consider (61) with \(g(x) = \mathrm {e}^{-(x+6)^2} + \mathrm {e}^{-x^2} + \mathrm {e}^{-(x-6)^2}-\frac{1}{2}\). This example is interesting because of g is not polynomial and its sign alternates. The produced effects are a concentration of mass at the points \(\bar{x}\) such that \(g(\bar{x}) = 0\), \(\partial _x g(\bar{x}) < 0\) and a thinning out where \(g(\bar{x})=0\), \(\partial _x g(\bar{x}) >0\). Snapshots of the numerical solution that illustrate this phenomena are shown in Fig. 3. No reflections are detected at the boundaries, as expected.

Table 3 We present the full discretization error \(\Vert \mathrm {err}\Vert _{\ell ^2}\) for \(g(x) = -x^3/54+x+3\)
Fig. 3
figure 3

Snapshots of the numerical solution \(u^m_N\) for \(g(x) = \mathrm {e}^{-(x+6)^2} + \mathrm {e}^{-x^2} + \mathrm {e}^{-(x-6)^2}-\frac{1}{2}\) and \(t=\frac{1}{4}\), \(\frac{1}{2}\), \(\frac{3}{4}\), 1 with \(\tau =2^{-12}\). The number of collocation points is set to \(N=2^6\)

Fig. 4
figure 4

Dotted lines show the full discretization errors \(\Vert \text {err}\Vert _{\ell ^2}\) between numerical solutions and a reference solutions for examples 1 (blue circles), 2 (red stars) and 3 (yellow squares). (Left plot). On the x-coordinate the number of collocation points N, squared, varying from 24 to 40. On the y-coordinate the full discretization error \(\Vert \mathrm {err}\Vert _{\ell ^2}\) with \(M=2^{12}\) fixed. For \(N=40\) collocation points accuracy to \(10^{-6}\) is achieved for examples 1 and 2, while for example 3 the accuracy is \(10^{-4}\). (Right plot). On the x-coordinate the number of time steps M varying from \(2^5\) to \(2^9\). On the y-coordinate the full discretization error \(\Vert \mathrm {err}\Vert _{\ell ^2}\) with \(N=2^6\) fixed. In black, a solid line of slope \(-2\). Second order in time is observed for examples 1, 2 and 3

Similarly to example 2, we report in Table 4 the full discretization error by varying N and M with respect to a reference solution \(u^m_{\text {ref}}\) computed using \(N_{\text {ref}}=2^6\) and \(M_{\text {ref}}=2^{12}\). In Table 4 (left) we observe a smaller value \(\alpha \) with respect to Tables 2 and  3. Therefore, spatial convergence is slower with respect to examples 1 and 2, but still spectral accuracy is achieved. The slower convergence rate is related to the variations of the function \(g^*\), which are greater in magnitude than in examples 1 and 2.

Table 4 We present full error \(\Vert \mathrm {err}\Vert _{\ell ^2}\) for \(g(x) = \mathrm {e}^{-(x+6)^2} + \mathrm {e}^{-x^2} + \mathrm {e}^{-(x-6)^2}-\frac{1}{2}\)

In Fig. 4 we collect error plots for examples 1, 2 and 3. For all numerical tests we observe second order in time and the typical exponential convergence \(\mathrm {exp}(-\alpha N^2)\), \(\alpha >0\) in space.

The numerical experiments confirm that the proposed approach performs well in the one dimensional case. However, the extension to higher dimensions is not straightforward. Transparent boundary conditions together with the pseudo-spectral discretization become more involved to compute. This poses a real challenge and is object of future studies.