INTRODUCTION

Improving the accuracy of numerical methods for solving problems of mathematical physics on minimal stencils has always been a topical problem in numerical analysis (see, e.g., [1,2,3,4]). A special place among the methods for constructing difference schemes of higher approximation order is occupied by so-called compact schemes, which are written on a stencil that differs insignificantly from the ones traditional for the equation in question [5]. The fundamental paper [6] on this topic for classical equations of mathematical physics with a self-adjoint elliptic operator was published by Samarskii more than 50 years ago. Compact difference schemes for other classes of equations, including convection–diffusion type equations, nonlinear equations without mixed derivatives, and aerohydrodynamic problems were constructed in [7,8,9].

In the present paper, we study compact difference schemes of approximation order \(4+2 \) on the usual three-point stencil for various types of the Klein–Gordon equation. This equation plays an important role in mathematical physics; in particular, it is used in the study of solitons and in condensed matter physics [10]. Compact difference schemes for this equation were constructed and studied, e.g., in [9, 11]. Some results on the topic were also announced in [12, 13]. For this equation, although the differential and difference problems with variable coefficients are linear, one fails to obtain relevant a priori estimates by applying well-known results from Samarskii’s stability theory of three-level operator-difference schemes [1, Ch. VI, Sec. 3]. In the present paper, we apply the method of energy inequalities to compact difference schemes approximating the Klein–Gordon equations with variable coefficients to obtain a priori estimates for the stability and convergence of the difference solution in the mesh norms of \(L_{2}(\omega _{h})\), \(W_{2}^{1}(\omega _{h})\), \(C(\omega _{h}) \), or \(L_{\infty }(\omega _{h}) \). We use a numerical experiment for a quasilinear equation that is a corollary of the system of gasdynamic equations as an example shown how to use the Runge rule for determining various orders of the convergence rate of the solution of a difference scheme in the case of two independent variables.

1. NECESSARY AND SUFFICIENT CONDITIONS FOR THE STABILITY OF TWO- AND THREE-LEVEL OPERATOR-DIFFERENCE SCHEMES

When studying compact difference schemes approximating linear Klein–Gordon equations, it is natural to use Samarskii’s general theory [1, Ch. VI, Sec. 3] of operator-difference schemes. Below, we suggest to use some other canonical forms of operator-difference schemes, for which the stability conditions are much simpler and do not contain conditions on the relationship between the operators.

Consider a real finite-dimensional Euclidean space \(H \) and a time mesh \(\overline {\omega }_{\tau }=\{t_{n}=n\tau \), \(n={0,\ldots ,N_{0}} \), \(\tau N_{0}=T\}=\omega _{\tau }\cup \{0\} \). Let the inner product on \(H \) be denoted by \((\cdot ,\cdot ) \), and let \(A, B, D: H\to H \) be linear operators independent of \(\tau \) and \(t_{n} \).

Consider the Cauchy problem for the two-level operator-difference scheme

$$ B y_{t}+A y^{(0.5)}=\varphi (t),\quad t\in \omega _{\tau },$$
(1)
$$ y_{0}=u_{0},$$
(2)

where \( y^{n}=y(t_{n})\in H\) is the desired vector function, \(\varphi ^{n}=\varphi (t_n)\) and \(u_{0} \) are given, and \(y^{(\sigma )}=\sigma y^{n+1}+(1-\sigma )y^{n}\), \(y^{n}\in H \). Then the Samarskii criterion (see [1, p. 333]) can be stated for \(\varphi (t)\equiv 0 \) as follows.

Theorem 1.

The conditions

$$ B=B(t)\geq 0,\quad A=A^{*}>0,\quad A\text { is a constant operator}, $$

are necessary and sufficient for the stability of the solution of the difference problem (1), (2) in \(H_{A} \) with respect to the initial data, i.e., for the estimate

$$ \|y^{n}\|_{A}\leq \|u_0\|_{A},\quad n={1,\ldots ,N_{0}}, $$

where, as usual, \( \|v\|_A=(Av,v)^{1/2}\) for each \(v\in H\).

We will use the following canonical form for three-level operator-difference schemes:

$$ D y_{\overline {t}t}+A_{1} y^{(0.5,\,0.5)}=\varphi (t),\quad 0<t\in \omega _{\tau },$$
(3)
$$ y_{0}=u_{0},\quad y_{1}=u_{1}, $$
(4)

where \(y^{(\sigma _{1},\sigma _{2})}=\sigma _{1}y^{n+1} +(1-\sigma _{1}-\sigma _{2})y^{n}+\sigma _{2}y^{n-1} \), \(0\leq \sigma _{1},\sigma _{2}\leq 1 \).

In the present paper, we use the notation in [1, 2]. In what follows, we assume that \(D\) and \(A_{1} \) are positive, self-adjoint, and constant operators,

$$ D=D^{*}>0,\quad A_{1}^{*}=A_{1}>0. $$
(5)

Then the following assertion holds.

Theorem 2.

The difference scheme (3), (4) is stable in \(H_{A_{1}}\) with respect to the initial data and the right-hand side, and one has the a priori estimate

$$ Q^{n+1}\leq Q^{1}+\sum ^{n}_{k=1}\tau \big \|\varphi (t_{k})\big \|_{D^{-1}}. $$

Here \( Q^{n}=\{\|y_{\overline {t}}\|_{D}^{2} +(\|y\|^2_{A_{1}}+\|\check {y}\|^2_{A_{1}})/2\}^{1/2}\).

Proof. Multiplying Eq. (3) by \(2\tau y_{\overset {\circ }t}=\tau (y_{t}+y_{\overline {t}})\) in the sense of the inner product on \(H \), we arrive at the energy relation

$$ Q_{n+1}^2-Q_{n}^2=2\tau (y_{\overset {\circ }t},\varphi )\leq \tau \big (\|y_{t}\|_{D} +\|y_{\overline {t}}\|_{D}\big )\|\varphi \|_{D^{-1}}\leq \tau (Q_{n+1}+Q_{n})\big \|\varphi (t_{n})\big \|_{D^{-1}}.$$

This implies the desired estimate.

2. KLEIN–GORDON EQUATION WITH CONSTANT COEFFICIENTS

2.1. Statement of the Problem and the Difference Scheme

In the domain \(\overline {Q}_T=\{(x,t): 0\le x\le l,\; 0\le t\le T\} \), we consider the initial–boundary value problem for the Klein–Gordon equation with constant coefficients

$$ \frac {\partial ^2u}{\partial t^2}=\frac {\partial ^2 u}{\partial x^2}- mu+f(x,t),\quad m=\mathrm {const}>0, $$
(6)
$$ u(x,0)=u_{0}(x),\quad \frac {\partial u}{\partial t}(x,0)=\overline {u}_0(x),$$
(7)
$$ u(0,t)=\mu _{1}(t),\quad u(l,t)=\mu _{2}(t). $$
(8)

Note that Eq. (6) is a generalization of the wave equation and is used to describe rapidly moving particles with nonzero rest mass. From now on, we assume that there exists a unique solution of the differential problem and that all of its derivatives needed in the exposition are continuous in \(\overline {Q}_{T} \).

On the uniform mesh of grid points \(\overline {\omega }=\overline {\omega }_h\times \overline {\omega }_{\tau }=\{(x_{i},t_{n})\in \overline {Q}_{T}\}\), where \(\overline {\omega }_h=\{x_{i}=ih\), \(0\le i\le N \), \(h=l/N\}=\omega _h\cup \{0, l\} \) and \(\overline {\omega }_{\tau }=\{t_{n}=n\tau \), \(0\le n\le N_{0} \), \(\tau =T/N_{0}\}=\omega _{\tau }\cup \{0\} \), we replace the differential problem by the difference problem

$$ y_{\overline {t}t}=\Lambda y^{(\sigma ,\sigma )}- m\biggl (y+\frac {h^2}{12}\Lambda y\biggr )+\varphi ,\quad (x,t)\in \omega _{h}\times \omega _{\tau },$$
(9)
$$ y(x,0)=u_{0}(x),\quad x\in \overline {\omega }_{h},\quad y_{t}(x,0)=u_{1}(x),\quad x\in \omega _{h},$$
(10)
$$ y(0,t)=\mu _{1}(t),\quad y(l,t)=\mu _{2}(t),\quad t\in \omega _{\tau },$$
(11)

where

$$ \begin {gathered} \hat {y}=y^{n+1},\quad \check {y}=y^{n-1},\quad y^{n}_{i}=y(x_{i}, t_{n}),\\ \Lambda y=y_{\overline {x}x},\quad \varphi =f+\frac {h^2}{12}\Lambda f,\quad \sigma =\overline {\sigma }-\frac {h^2}{12\tau ^2},\\ u_{1}(x)=\overline {u}_0(x)+\frac {\tau }{2}\big [u^{\prime\prime}_{0}(x)- m u_{0}(x)+f(x,0)\big ],\quad x\in \omega _{h}. \end {gathered}$$

Just as in the monograph [1, p. 309], one can readily show that the discrepancy

$$ \psi =- u_{\overline {t}t}+\Lambda u^{(\sigma ,\sigma )}- m\biggl (u+\frac {h^2}{12}\Lambda u\biggr )+\varphi$$

and the approximation error in the second initial condition satisfy the a priori estimates

$$ \|\psi \|\leq M(h^{4}+\tau ^2),\quad M=\mathrm {const}>0, $$
(12)
$$ \|\overset {\circ }\psi \|=\|u_{1}-u_{t}^{0}\|\leq M_{1}\tau ^2,\quad M_{1}=\mathrm {const}>0;$$
(13)

i.e., the difference scheme (9)–(11) approximates the original differential problem with the fourth order in space and the second order in time.

2.2. Stability with Respect to the Initial Data and the Right-Hand Side

To study these issues in the linear case, one usually applies the theory of three-level operator-difference schemes developed by Samarskii [1, Ch. VI, Sec. 3]. The requirement for the main spatial operator to be self-adjoint,

$$ (Ay)_i=-(\Lambda y)_i,\quad i={1,\ldots ,N-1},\quad (Ay)_0=0,\quad (Ay)_N=0,$$
(14)

results in stringent restrictions on the homogeneity of the boundary conditions. To avoid this, consider the perturbed solution \(\tilde {y}\) produced by the difference scheme (9)–(11) with perturbed right-hand side \(\tilde {f} \) and perturbed initial conditions \(\tilde {u}_{0} \), \(\tilde {u}_{1}\). Then the problem for the perturbation \(\overline {y}=\tilde {y}-y \) can be written in the operator form

$$ D\overline {y}_{\overline {t}t}+A_{1}\overline {y}=\overline {\varphi },\quad \overline {\sigma }=1, $$
(15)
$$ \overline {y}(0)=\overline {u}_{0},\quad \overline {y}_{t}(0)=\overline {u}_{1},$$
(16)
$$ D=E+\sigma \tau ^2 A,\quad A_{1}=mE+\biggl (1-\frac {m h^2}{12}\biggr )A.$$

Here \(\overline {u}_{0}=\tilde {u}_{0}-u_{0}\), \(\overline {u}_{1}=\tilde {u}_{1}-u_{1}\), and \(\overline {\varphi }=\tilde {\varphi }-\varphi \).

The operator \(A\) defined by relation (14) is constant, positive, and self-adjoint, \(0<A^{*}=A: H\to H\); here \(H \) is the space of mesh functions defined on \(\overline {\omega }_{h}\) and vanishing for \(x=0 \) and \(x=l \). Therefore, the operators \(D \) and \(A_{1} \) are positive, constant, and self-adjoint as well, \(D=D^{*}>E \) and \(A_{1}=A^{*}_{1}>A \).

Note the following well-known properties of the operator \(A \) [1, Ch. II, Sec. 3]:

$$ \lambda _{1}E\leq A\leq \lambda _{2}E,\quad A^{-1}\leq \frac {1}{\delta }E,\quad \delta =\frac {8}{l^2},$$
(17)
$$ \lambda _{1}=\frac {4}{h^2}\sin ^2\frac {\pi h}{2l}\geq \delta ,\quad \lambda _{2}=\frac {4}{h^2}\cos ^2\frac {\pi h}{2l}<\frac {4}{h^2}. $$
(18)

We need the following assertion.

Lemma 1 [1, p. 373].

Assume that the operators \(D\) and \(A_{1}\) in the canonical form (15), (16) are constant, positive, and self-adjoint in \(H\) and satisfy the inequality

$$ D\geq \frac {1+\varepsilon }{4}\tau ^2A_{1},\quad \text{where}\quad \varepsilon >0\text{ is some number.} $$
(19)

Then the solution of the scheme (15), (16) satisfies the a priori estimate

$$ \|\overline {y}^{n+1}\|_{D}\leq \sqrt {\frac {1+\varepsilon }{\varepsilon }}\left (\big \|\overline {y}(0)\big \|_{D}+ \big \|D\overline {y}_{t}(0)\big \|_{A_{1}^{-1}}+ \sum ^{n}_{s=1}\tau \|\overline {\varphi }_{s}\|_{A_{1}^{-1}}\right ).$$
(20)

In particular, if \(\varepsilon =1 \), \( D\geq E\), and \( A_{1}^{-1}<A^{-1}\leq \delta ^{-1}E \), then the estimate (20) acquires the form

$$ \|\overline {y}^{n+1}\|\leq \sqrt {2}\left (\big \|\overline {y}(0)\big \|_{D}+\frac {1}{\delta }\big \|D\overline {y}_{t}(0)\big \|+ \frac {1}{\delta }\sum ^{n}_{s=1}\tau \|\overline {\varphi }_{s}\|\right ). $$
(21)

Let us apply the estimate (21) to the stability analysis of the compact difference scheme (9)–(11). In what follows, we assume that

$$ \frac {h}{\sqrt {6}}\leq \tau \leq \frac {1}{\sqrt {m}},\quad \sigma =1-\frac {h^2}{12\tau ^2}.$$
(22)

Then condition (19) is satisfied. Indeed,

$$ D-\frac {\tau ^2}{2}A_{1}=\frac {1}{2}E+\biggl (\frac {1}{2}-\frac {m\tau ^2}{2}\biggr )E+ \tau ^2\Bigg [\sigma -\frac {1}{2}\biggl (1-\frac {mh^2}{12}\biggr )\Bigg ]A\geq \frac {1}{2}E.$$

Thus, the following assertion holds.

Theorem 3.

Let condition (22) be satisfied. Then the difference scheme with the inhomogeneous boundary conditions (9)(11) is conditionally stable with respect to the initial data and the right-hand side, and its solution satisfies the a priori estimate

$$ \|\tilde {y}^{n+1}-y^{n+1}\|\leq \sqrt {2}\left (\|\tilde {u}_{0}-u_{0}\|_{D} +\frac {1}{\delta }\|D(\tilde {u}_{1}-u_{1})\|+ \frac {1}{\delta }\sum ^{n}_{s=1}\tau \|\tilde {\varphi }_{s} -\varphi _{s}\|\right ). $$

Remark.

In the linear case, the change of variables

$$ u=v+\frac {x}{l}\mu _{2}(t)+\frac {l-x}{l}\mu _{1}(t) $$

reduces the original differential problem to a problem with homogeneous boundary conditions for \(v\). Further, the stability of the solution of difference schemes for these problems with respect to the boundary conditions and the right-hand side takes place simultaneously for both problems. However, this change of variables may fail to produce the desired result for the nonlinear Klein–Gordon equation.

Thus, we have proved the stability of solution of the difference scheme in the weak \(L_{2}(\omega _{h})\) energy norm under rather weak constraints on the function weight \(\sigma \). Such estimates are useful when studying the convergence of difference schemes with generalized solutions [14]. To produce a priori estimates in the stronger \( W^{1}_{2}(\omega _{h})\) and \(C(\omega _{h}) \) norms, we will use Theorem 2 and the embedding (see [1, p. 107])

$$ \|\tilde {y}-y\|_{C}\leq \frac {\sqrt {l}}{2}\|\tilde {y}_{\overline {x}}-y_{\overline {x}}]|.$$
(23)

Let us write the difference scheme for the perturbation \(\overline {y}=\tilde {y}-y \) in the canonical form (3) for \(h/\sqrt {6}\le \tau \le 1/\sqrt {m} \) and \(\sigma =1-h^2/(12\tau ^2) \),

$$ D\overline {y}_{\overline {t}t}+A_{1}\overline {y}^{(0.5,0.5)}=\overline {\varphi },\quad t\in \omega _{\tau }, $$
(24)
$$ \overline {y}(0)=\overline {u}_{0},\quad \overline {y}_{t}(0)=\overline {u}_{1},$$
(25)

where

$$ D=E+\tau ^2(\sigma -0.5)A_1=D^{*}\geq \frac {1}{2}E,\quad D^{-1}\leq 2E,\quad A_{1}^{*}=A_{1}=mE+\biggl (1-\frac {m h^2}{12}\biggr ) A>A\geq \delta E. $$

Then the following assertion holds.

Theorem 4.

The solution of the difference scheme (24), (25) for \( h/\sqrt {6}\le \tau \le 1/\sqrt {m} \) and \( \sigma =1-h^2/(12\tau ^2)\) is stable with respect to the initial data and the right-hand side, and for all \( n={2,\ldots ,N_{0}}\) one has the a priori estimates

$$ \begin {aligned} \frac {1}{\sqrt {2}}\big (\|\overline {y}^{n}_{\overline {x}}]|^{2}+ \|\overline {y}^{n-1}_{\overline {x}}]|^{2}\big )^{1/2}&\leq Q^{1}+2\sum ^{n-1}_{k=1}\tau \big \|\tilde {\varphi }(t_{k})-\varphi (t_{k})\big \|,\\ \|\tilde {y}^{n}-y^{n}\|_{C}&\leq \sqrt {\frac {l}{2}}\left \{Q^{1}+2\sum ^{n-1}_{k=1}\tau \big \|\tilde {\varphi }(t_{k})- \varphi (t_{k})\big \|\right \}. \end {aligned}$$
(26)

Proof. If \(h/\sqrt {6}\le \tau \le 1/\sqrt {m}\) and \(\sigma =1-h^2/(12\tau ^2) \), then condition (5) is satisfied; therefore, by Theorem 2,

$$ \frac {1}{\sqrt {2}}\big (\|\overline {y}^{n}\|^2_{A_{1}}+ \|\overline {y}^{n-1}\|^2_{A_{1}}\big )^{1/2}\leq Q^{1}+\sum ^{n-1}_{k=1}\tau \big \|\overline {\varphi }(t_{k})\big \|_{D^{-1}}. $$

Since \(A_{1}>A\) and \(D^{-1}\leq 2E \), we have the estimate

$$ \frac {1}{\sqrt {2}}\big (\|\overline {y}^{n}_{\overline {x}}]|^2+ \|\overline {y}^{n-1}_{\overline {x}}]|^2\big )^{1/2}\leq Q^{1}+2\sum ^{n-1}_{k=1}\tau \big \|\overline {\varphi }(t_{k})\big \|.$$

Consequently, it follows from the lemma and the embedding (23) that

$$ \|\tilde {y}^{n}-y^{n}\|_{C}\leq \sqrt {\frac {l}{2}}\left \{Q^{1}+2\sum ^{n-1}_{k=1}\tau \big \|\tilde {\varphi }(t_{k})- \varphi (t_{k})\big \|\right \}.$$

The proof of the theorem is complete.

2.3. Strong Stability

When studying the well-posedness of difference schemes, attention is mainly paid to the stability of the solution with respect to the initial data and the right-hand side [1, 2]. However, when solving a differential problem numerically, it may turn out that the coefficients of the equation are given approximately rather than exactly. This shows how important it is to study schemes with perturbed coefficients. By strong stability we mean the stability of the solution of the difference problem with respect to small perturbations in the initial conditions, right-hand side, and coefficients of the equation [15].

Along with the difference scheme (9)–(11), consider the corresponding perturbed problem

$$ \tilde {y}_{\overline {t}t}=\Lambda \tilde {y}^{(\sigma ,\sigma )}- \tilde {m}\biggl (\tilde {y}+\frac {h^2}{12}\Lambda \tilde {y}\biggr )+\tilde {\varphi },\quad (x,t)\in \omega _{h}\times \omega _{\tau }, $$
(27)
$$ \tilde {y}(x,0)=\tilde {u}_{0}(x),\quad x\in \overline {\omega }_{h},\quad \tilde {y}_{t}(x,0)=\tilde {u}_{1}(x),\quad x\in \omega _{h}, $$
(28)
$$ \tilde {y}(0,t)=\mu _{1}(t),\quad \tilde {y}(l,t)=\mu _{2}(t),\quad t\in \omega _{\tau }.$$
(29)

We subtract Eqs. (9)–(11) from the respective equations (27)–(29) and obtain a problem for the perturbation \(\overline {y}=\tilde {y}-y \), which we write in the operator form (15), (16),

$$ \begin {gathered} D\overline {y}_{\overline {t}t}+\tilde {A}_{1}\overline {y}= \overline {\varphi }-(\tilde {A}_{1}-A_{1})y,\\ \overline {y}(0)=\overline {u}_{0},\quad \overline {y}_{t}(0)=\overline {u}_{1},\\ \tilde {A}_{1}=\tilde {m}E+\biggl (1-\frac {\tilde {m} h^2}{12}\biggr )A. \end {gathered} $$

Here \(D=D^{*}>E\) and \(\tilde {A}_{1}=\tilde {A}_{1}^{*}>A\geq \delta E\) are positive constant self-adjoint operators.

Note that condition (19) is satisfied for \( h/\sqrt {6}\leq \tau \leq \sqrt {1/\tilde {m}} \); therefore, we obtain the inequality

$$ \|\overline {y}^{n+1}\|\leq \sqrt {2}\left (\big \|\overline {y}(0)\big \|_{D}+\frac {1}{\delta }\big \|D\overline {y}_{t}(0)\big \|+ \frac {1}{\delta }\sum ^{n}_{s=1}\tau \Big \{\|\overline {\varphi }_{s}\|+ \big \|(\tilde {A}_{1}-A_{1})y_{s}\big \|\Big \}\right )$$

for \(\overline {y} \) based on the a priori estimate (21). By virtue of relations (17) and (18), we have \(\|A\|<4/h^2 \), and consequently, the estimate (21) implies the estimate

$$ \big \|(\tilde {A}_{1}-A_{1})y_{s}\big \|= \bigg \|(\tilde {m}-m)\biggl (E-\frac {h^2}{12}A\biggr )y_{s}\bigg \|< \frac {4}{3}K_{s}|\tilde {m}-m|,$$

where

$$ K_{s}=\sqrt {2}\left (\|u_{0}\|_{D}+\frac {1}{\delta }\|Du_{1}\|+ \frac {1}{\delta }\sum ^{s-1}_{r=1}\tau \|\varphi _{r}\|\right ).$$

Thus, we are now in a position to state the strong stability theorem.

Theorem 5.

Assume that the grid increments satisfy the condition

$$ \frac {h}{\sqrt {6}}\leq \tau \leq \frac {1}{\sqrt {\overline {m}}},\quad \overline {m}=\max \{m,\tilde {m}\}.$$

Then the solution of the difference scheme (9)(11) is strongly stable, and the perturbation of the solution satisfies the a priori estimate

$$ \begin {gathered} \|\tilde {y}^{n+1}-y^{n+1}\|\leq \sqrt {2}\left \{\|\tilde {u}_{0}-u_{0}\|_{D}+\frac {1}{\delta }\big \|D(\tilde {u}_{1}-u_{1})\big \|+ \frac {1}{\delta }\sum ^{n}_{s=1}\tau \biggl (\|\tilde {\varphi }_{s}-\varphi _{s}\|+ \frac {4}{3}K_{s}|\tilde {m}-m|\biggr )\right \},\\ n={1,\ldots ,N_{0}-1}. \end {gathered}$$

2.4. Convergence Theorem

Let us denote the method error by \(z=y-u\). We substitute \(z+u \) for \(y \) into the difference equations (9)–(11) and obtain the problem

$$ z_{\overline {t}t}= \Lambda z^{(\sigma ,\sigma )}-m\biggl (z+\frac {h^2}{12}\Lambda z\biggr )+\psi ,\quad (x,t)\in \omega _{h}\times \omega _{\tau },$$
(30)
$$ z(x,0)=0,\quad x\in \overline {\omega }_{h},\quad z_{t}(x,0)=\overset {\circ }\psi ,\quad x\in \omega _{h}, $$
(31)
$$ z(0,t)=0,\quad z(l,t)=0,\quad t\in \omega _{\tau }, $$
(32)

for \(z\).

Since problems (9)–(11) and (30)–(32) are identical, we can use Theorem 4 to estimate the method error.

Theorem 6.

Let the assumptions of Theorem 4 be satisfied. Then the solution of the difference problem (9)(11) converges to the exact solution of the differential problem (6)(8) in the \(C(\omega _{h}) \) mesh norm, and the solution satisfies the error estimate

$$ \underset {t\in \overline {\omega }_{\tau }}\max \|y^{n}-u^{n}\|_{C}\leq M_{2}(h^4+\tau ^2),\quad M_{2}=\mathrm {const}>0. $$

Proof. Indeed, the a priori estimates (12), (13), and (26) imply the inequality

$$ \|y^{n}-u^{n}\|_{C}\leq \sqrt {\frac {l}{2}}\left \{Q(z^{1})+2\sum ^{n-1}_{k=1}\tau \big \|\psi (t_{k})\big \|\right \}\leq M_{2}(h^4+\tau ^2). $$

Consequently, the difference solution converges to the exact solution with the fourth order in space and the second order in time.

3. KLEIN–GORDON EQUATION WITH VARIABLE COEFFICIENTS

3.1. Statement of the Problem and the Difference Scheme

In the domain \(\overline {Q}_T=\{(x,t): 0\le x\le l \), \(0\le t\le T\}\), consider the initial–boundary value problem for the Klein–Gordon equation with variable coefficients

$$ \frac {\partial ^2u}{\partial t^2}=\frac {\partial }{\partial x}\biggl (k(x,t) \frac {\partial u}{\partial x}\biggr )-mu+f(x,t),\quad m=\mathrm {const}>0,$$
(33)
$$ u(x,0)=u_{0}(x),\quad \frac {\partial u}{\partial t}(x,0)=\overline {v}_0(x),$$
(34)
$$ u(0,t)=\mu _{1}(t),\quad u(l,t)=\mu _{2}(t), $$
(35)

where \(0<k_{1}\leq k(x,t)\leq k_{2} \), \(u(x,t)\in C^{4,6}(\overline {Q}_{T}) \), \(p\in C^{0,5}(\overline {Q}_{T}) \), and \(f\in C^{0,4}(\overline {Q}_{T}) \).

We approximate the original differential problem by the difference scheme

$$ y_{\overline {t}t}= \Lambda y^{(\sigma ,\sigma )}-\frac {h^2}{12}\Lambda (py_{\overline {t}t})- m\bigg [y^{(\sigma ,\sigma )}+\frac {h^2}{12}\Lambda (py^{(\sigma ,\sigma )})\bigg ]+\varphi ,\quad (x,t)\in \omega _{h}\times \omega _{\tau },$$
(36)
$$ y(x,0)=u_{0}(x),\quad x\in \overline {\omega }_{h},\quad y_{t}(x,0)=u_{1}(x),\quad x\in \omega _{h},$$
(37)
$$ y(0,t)=\mu _{1}(t),\quad y(l,t)=\mu _{2}(t),\quad t\in \omega _{\tau },$$
(38)

on the mesh \(\overline {\omega } \) constructed above. Here

$$ \begin {gathered} \Lambda y=\big (a(x,t_{n})y_{\overline {x}}\big )_{x},\quad \sigma =0.5,\quad \varphi =f+\frac {h^2}{12}\Lambda (pf),\quad p(x,t)=\frac {1}{k(x,t)},\\ a(x,t)=6\bigg [p(x-h,t)+4 p\biggl (x-\frac {h}{2},t\biggr )+p(x,t)\bigg ]^{-1},\quad 0<c_{1}\leq a(x,t)\leq c_{2},\\ u_{1}(x)=\overline {v}_0(x)+\frac {\tau }{2}\Big [\big (k(x,0)u^{\prime}(x,0)\big )^{\prime}-m u(x,0)+f(x,0)\Big ],\quad x\in \omega _{h}. \end {gathered}$$

Following the papers [5, 6, 8], one can readily show that the difference scheme (36)–(38) approximates the original problem (33)–(35) with the fourth order in space and the second order in time; i.e., the discrepancy

$$ \psi = -u_{\overline {t}t}+\Lambda u^{(\sigma ,\sigma )}- \frac {h^2}{12}\Lambda (pu_{\overline {t}t})- m\bigg [u^{(\sigma ,\sigma )} +\frac {h^2}{12}\Lambda (pu^{(\sigma ,\sigma )})\bigg ]+\varphi$$

and the second initial condition satisfy the a priori estimates

$$ \begin {aligned} \|\psi \|&\leq M(h^{4}+\tau ^2),&\quad M&=\mathrm {const}>0,\\ \|\overset {\circ }\psi \|&=\|u_{1}-u_{t}^{0}\|\leq M_{1}\tau ^2,&\quad M_{1}&=\mathrm {const}>0. \end {aligned} $$

3.2. Stability

To avoid cumbersome calculations, we restrict ourselves to the case in which the coefficient \(k=k(x) \) depends on the spatial variable alone. Consider the perturbed solution \(\tilde {y}\) produced by the difference scheme (36)–(38) with perturbed right-hand side \(\tilde {f} \) and perturbed initial conditions \(\tilde {u}_{0} \) and \(\tilde {u}_{1} \). Then the problem for the perturbation \(\overline {y}=\tilde {y}-y\) acquires the form

$$ \overline {y}_{\overline {t}t}=\Lambda \overline {y}^{(\sigma ,\sigma )}- \frac {h^2}{12}\Lambda (p\overline {y}_{\overline {t}t})- m\bigg [\overline {y}^{(\sigma ,\sigma )}+ \frac {h^2}{12}\Lambda (p\overline {y}^{(\sigma ,\sigma )})\bigg ]+\overline {\varphi },\quad (x,t)\in \omega _{h}\times \omega _{\tau },$$
(39)
$$ \overline {y}(x,0)=\overline {u}_{0}(x),\quad x\in \overline {\omega }_{h},\quad \overline {y}_{t}(x,0)=\overline {u}_{1}(x),\quad x\in \omega _{h},$$
(40)
$$ \overline {y}(0,t)=0,\quad \overline {y}(l,t)=0,\quad t\in \omega _{\tau }.$$
(41)

Here \(\overline {u}_{0}=\tilde {u}_{0}-u_{0}\), \(\overline {u}_{1}=\tilde {u}_{1}-u_{1}\), and \(\overline {\varphi }=\tilde {\varphi }-\varphi \).

Unfortunately, although the difference problem is linear, the Samarskii theory of three-level operator-difference schemes [1] does not apply. We will use the method of energy inequalities; in addition to some well-known facts from the theory of difference schemes such as the first difference Green’s formula, the Cauchy–Schwarz inequality with \(\varepsilon \) [1, Ch. II, Sec. 3], and the difference analog of Gronwall’s lemma [16, Ch. III, Sec. 1], we also need the following assertion.

Lemma 2.

The expression

$$ Q^{n}=\|\overline {y}_{\overline {t}}\|^2+ \frac {1}{2}(a,\overline {y}_{\overline {x}}^2+\check {\overline {y}}_{\overline {x}}^2]+ \frac {m}{2}\big (\|\overline {y}\|^2+\|\check {\overline {y}}\|^2\big )- \frac {h^2}{12}(ap_{(-1)},\overline {y}_{\overline {x}\overline {t}}^2]- \frac {m h^2}{24}(ap_{(-1)},\overline {y}_{\overline {x}}^2+ \check {\overline {y}}_{\overline {x}}^2], $$

where \( p_{(-1)}=p_{i-1}\) , is nonnegative, \(Q^{n}\geq 0 \) , if the conditions

$$ h\leq h_{0},\quad h_{0}=\sqrt {\frac {3k_{1}}{m}},\quad \tau \geq \frac {2h}{\sqrt {3k_{1}}}$$
(42)

are satisfied.

Proof. It suffices to show that the expression

$$ I_{1}=\frac {1}{4}(a,\overline {y}_{\overline {x}}^2+\check {\overline {y}}_{\overline {x}}^2]- \frac {h^2}{12}(ap_{(-1)},\overline {y}_{\overline {x}\overline {t}}^2]- \frac {m h^2}{24}(ap_{(-1)},\overline {y}_{\overline {x}}^2+ \check {\overline {y}}_{\overline {x}}^2]$$
(43)

is nonnegative. In view of the obvious inequalities

$$ -\frac {h^2}{12}(ap_{(-1)},\overline {y}_{\overline {x}\overline {t}}^2]\geq -\frac {h^2}{6k_{1}\tau ^2}(a,\overline {y}_{\overline {x}}^2+ \check {\overline {y}}_{\overline {x}}^2]\quad \text {and}\quad {}-\frac {m h^2}{24}(ap_{(-1)},\overline {y}_{\overline {x}}^2+ \check {\overline {y}}_{\overline {x}}^2]\geq -\frac {m h^2}{24k_{1}}(a,\overline {y}_{\overline {x}}^2+ \check {\overline {y}}_{\overline {x}}^2], $$

the expression (43) satisfies the estimate

$$ I_{1}\geq c_{3}(a,\overline {y}_{\overline {x}}^2+\check {\overline {y}}_{\overline {x}}^2],\quad c_{3}=\frac {1}{4}-\frac {h^2}{6k_{1}\tau ^2}-\frac {m h^2}{24k_{1}}.$$

Under the first condition in (42), the inequality

$$ \frac {1}{4}-\frac {m h^2}{24k_{1}}\geq \frac {1}{8}$$

holds. Consequently, we have

$$ c_{3}\geq -\frac {h^2}{6k_{1}\tau ^2}+\frac {1}{8}\geq 0$$

under the second condition in (42). The proof of the lemma is complete.

To obtain an a priori estimate for \(\overline {y} \), we multiply the difference equation (39) by \(2\tau y_{\overset {\circ }t} \) in the sense of the inner product and apply the first Green’s difference formula to obtain the energy relation

$$ Q^{n+1}-\frac {h^2}{12}\big (ap_{\overline {x}}(\overline {y}_{t}-\overline {y}_{\overline {t}}), \overline {y}_{\overline {x}t}+\overline {y}_{\overline {x}\overline {t}}\big ]= Q^{n}+ \frac {m\tau h^2}{12}\big (ap_{\overline {x}}(\hat {\overline {y}}+\check {\overline {y}}), \overline {y}_{\overset {\circ }t\overline {x}}\big ]+ 2\tau (\overline {\varphi },\overline {y}_{\overset {\circ }t}).$$
(44)

Consider the terms other than \(Q^{n} \) and \(Q^{n+1} \) in (44). We apply the Cauchy–Schwarz inequality with \(\varepsilon \) and readily obtain the estimates

$$ -\frac {h^2}{12}\big (ap_{\overline {x}}(\overline {y}_{t}-\overline {y}_{\overline {t}}), \overline {y}_{\overline {x}t}+\overline {y}_{\overline {x}\overline {t}}\big ]\geq - c h\big (\|\overline {y}_{t}\|^2+\|\overline {y}_{\overline {t}}\|^2\big ), $$
(45)
$$ \frac {m\tau h^2}{12}\big (ap_{\overline {x}}(\hat {\overline {y}}+\check {\overline {y}}), \overline {y}_{\overset {\circ }t\overline {x}}\big ]\leq c h\bigg [\frac {m}{2}\big (\|\hat {\overline {y}}\|^2+\|\overline {y}\|^2\big )+ \frac {m}{2}\big (\|\overline {y}\|^2+\|\check {\overline {y}}\|^2\big )\bigg ],$$
(46)
$$ 2\tau (\overline {\varphi },\overline {y}_{\overset {\circ }t})\leq \varepsilon \tau \|\overline {\varphi }\|^2+ \frac {\tau }{2\varepsilon }\big (\|\overline {y}_{t}\|^2+ \|\overline {y}_{\overline {t}}\|^2\big ),$$
(47)

where \(c>0 \) is a case-specific constant depending on \(m \), \(\varepsilon \), and \(\underset {x\in \overline {\omega }_{h}}\max |p_{\overline {x}}(x)|\).

We take into account inequalities (45)–(47) in (44) and, under conditions (42), arrive at the recursion relation

$$ Q^{n+1}\leq (1+\tau c)Q^{n}+\tau c\|\overline {\varphi }\|^2\leq e^{c\tau } Q^{n}+\tau c\|\overline {\varphi }\|^2. $$
(48)

Thus, the following assertion holds.

Theorem 7.

Let the condition

$$ \tau \geq \max \bigg \{1,\sqrt {\frac {2}{3k_{1}}}\bigg \}h$$

be satisfied. Then one has the estimate

$$ Q^{n+1}\leq e^{ct_{n}}\biggl (Q^{1}+c\sum ^{n}_{k=1} \tau \|\overline {\varphi }^{k}\|^2\biggr ),$$
(49)

which implies the \(\rho \)-stability of the solution of the difference scheme (36)(38) with respect to the initial data and the right-hand side in the \(L_{2}(\omega _{h}) \), \( W_{2}^{1}(\omega _{h})\), and \(C(\overline {\omega }_{h}) \) mesh norms.

The proof of the theorem follows from inequality (48), the Gronwall lemma, and the embedding [1, p. 107]

$$ \|\tilde {y}-y\|_{C}\leq \frac {\sqrt {l}}{2}\|\tilde {y}_{\overline {x}}-y_{\overline {x}}]|. $$

3.3. Convergence of the Difference Scheme in the \(C(\overline {\omega }_{h}) \) Mesh Norm

We substitute \(z+u\) for \(y \) into the difference equations (36)–(38), where \(u \) is the solution of problem (33)–(35), and obtain the problem

$$ z_{\overline {t}t}=\Lambda z^{(\sigma ,\sigma )}- \frac {h^2}{12}\Lambda (pz_{\overline {t}t})-m\bigg [z^{(\sigma ,\sigma )}+ \frac {h^2}{12}\Lambda (pz^{(\sigma ,\sigma )})\bigg ]+\psi ,\quad (x,t)\in \omega _{h}\times \omega _{\tau },$$
(50)
$$ z(x,0)=0,\quad x\in \overline {\omega }_{h},\quad z_{t}(x,0)=\overset {\circ }\psi ,\quad x\in \omega _{h},\quad \overset {\circ }\psi =O(\tau ^2),$$
(51)
$$ z(0,t)=0,\quad z(l,t)=0,\quad t\in \omega _{\tau }, $$
(52)

for the error \(z \).

Problems (50)–(52) and (39)–(41) are identical. Therefore, we can apply Theorem 7 to estimate the method error. Then, in accordance with inequality (49), we obtain the estimate

$$ \|z\|^2_{C}\leq M_{1}\bigg \lbrace \|\overset {\circ }\psi \|^2+ \frac {4{c}_{2}}{c^2}\|\overset {\circ }\psi _{\overline {x}}]|^2+ \frac {4m}{c^2}\|\overset {\circ }\psi \|^2+ cT\underset {t\in \omega _{\tau }}\max \big \|\psi (t)\big \|^2\bigg \rbrace , $$

where \(M_{1}=\mathrm {const}>0 \).

Thus, we are now in a position to formulate the convergence theorem.

Theorem 8.

Let the assumptions of Theorem 7 be satisfied. Then the solution of the difference scheme (36)(38) converges to the exact solution of the differential problem (33)(35) in the \(C(\overline {\omega }_{h}) \) mesh norm, and the solution satisfies the error estimate

$$ \|y^{n}-u^{n}\|_{C}\leq M_{2}(h^4+\tau ^2),\quad n=0,\dots ,N_{0},$$

where \( M_{2}=\mathrm {const}>0\).

4. QUASILINEAR KLEIN–GORDON EQUATIONS

For equations with variable coefficients, the compact difference schemes proposed by Samarskii have the disadvantage that it is impossible to generalize them to the case of quasilinear equations, because the corresponding stencil functional must be calculated at a half-integer point, which does not exist in the quasilinear case. Nevertheless, compact schemes of order \(4+2 \), similar to schemes for the case of constant coefficients, can also be constructed for the quasilinear Klein–Gordon equations

$$ \frac {\partial ^2 u}{\partial t^2}= \frac {\partial ^2\phi (u)}{\partial x^2}-mf_{1}(u)+f(x,t),\quad m=\mathrm {const}>0,$$
$$ u(x,0)=u_{0}(x),\quad \frac {\partial u}{\partial t}(x,0)=\overline {u}_0(x),$$
$$ u(0,t)=\mu _{1}(t),\quad u(l,t)=\mu _{2}(t)$$

with the condition \(\phi ^{\prime}_{u}=k(u)\geq k_{1}>0\).

The difference scheme of approximation order \(4+2 \) on the standard stencil has the form

$$ \begin {gathered} y_{\overline {t}t}=\big [\phi (y)\big ]_{\overline {x}x}^{(\sigma ,\sigma )}- m\overline {f}_{1}(y)+\overline {f}-\frac {h^2}{12}y_{\overline {t}t\overline {x}x},\quad (x,t)\in \omega _{h}\times \omega _{\tau },\\ y(x,0)=u_{0}(x),\quad x\in \overline {\omega }_{h},\quad y_{t}(x,0)=u_{1}(x),\quad x\in \omega _{h},\\ y(0,t)=\mu _{1}(t),\quad y(l,t)=\mu _{2}(t),\quad t\in \omega _{\tau }, \end {gathered}$$

where

$$ \begin {gathered} \overline {v}=v+\frac {h^2}{12}v_{\overline {x}x}= \frac {5}{6}v+\frac {1}{12}(v_{+1}+v_{-1}),\quad 0<\sigma \leq 1,\\ u_{1}(x)=\overline {u}_0(x)+\frac {\tau }{2}\Big [\phi ^{\prime\prime}\big (u_{0}(x)\big )-mf_{1}\big (u_{0}(x)\big )+f(x,0)\Big ],\quad x\in \omega _{h}. \end {gathered}$$

To implement this scheme, one needs to use the Newton iteration method.

5. COMPUTATIONAL EXPERIMENT

Here we present the results of numerical calculations obtained when solving an initial–boundary value problem for the equation

$$ \frac {\partial ^2 u}{\partial t^2}= -\frac {1}{\gamma }\frac {\partial ^2 u^{-\gamma }}{\partial x^2}$$
(53)

with parameter values \(\gamma =5\), \(l=2 \), and \(T=2 \). The initial and boundary conditions are determined from the exact solution

$$ u(x,t)=\biggl (\frac {t+1}{x+1}\biggr )^{\!2/(1+\gamma )}.$$

Equation (53) is a corollary of the system of equations of gas dynamics in Lagrangian variables with the equation of state for a polytropic gas, where \(u=\eta \) is the specific volume.

The difference scheme of approximation order \(4+2 \) for Eq. (53) has the form

$$ y_{\overline {t}t}=\sigma \big (\phi (\hat {y})\big )_{\overline {x}x}+ (1-2\sigma )\big (\phi (y)\big )_{\overline {x}x}+\sigma \big (\phi (\check {y})\big )_{\overline {x}x}- \frac {h^2}{12}y_{\overline {t}t\overline {x}x},$$
(54)

where \(\sigma =1 \) and \(\phi (u)=-u^{-\boldsymbol \gamma }/{\boldsymbol \gamma }\).

Table 1. Convergence rate in the spatial direction
Table 2. Convergence rate in the time direction

To find the solution of the difference scheme (54), we apply the Newton iteration method

$$ \begin {gathered} \overset {(k+1)}{\hat {y}}-2y+\check {y}= \tau ^2\big [\phi (\overset {(k)}{\hat {y}})\!+\phi ^{\prime}_{y}(\overset {(k)}{\hat {y}}) (\overset {(k+1)}{\hat {y}}-\overset {(k)}{\hat {y}})\big ]_{\overline {x}x}\!- \tau ^2\big [\phi (y)\big ]_{\overline {x}x}\!+\tau ^2\big [\phi (\check {y})\big ]_{\overline {x}x}\!- \frac {h^2}{12}(\overset {(k+1)}{\hat {y}}-2y+\check {y})_{\overline {x}x},\\ \overset {(0)}{\hat {y}}=2y-\check {y},\quad k=0,1,2,\ldots \text { is the iteration number.} \end {gathered}$$

On each layer, this process stops when the following condition is satisfied for some \(M \):

$$ \|\overset {(M+1)}{\hat {y}}-\overset {(M)}{\hat {y}}\|_{C}\leq \varepsilon ,\quad \varepsilon =10^{-7}. $$

The order of convergence in the time and space variables in the \(L_{\infty }=C \) norm is determined by the formulas

$$ p^{h}_{\infty }=\log _{2} \frac {\big \|z(2h,\tau )\big \|_{L_{\infty }}}{\big \|z(h,\tau )\big \|_{L_{\infty }}},\quad p^{\tau }_{\infty }=\log _{2}\frac {\big \|z(h,2\tau )\big \|_{L_{\infty }}}{\big \|z(h,\tau )\big \|_{L_{\infty }}}.$$
(55)

Since the difference solution converges to the exact solution with the fourth order in space and the second order in time, we select steps \(h \) and \(\tau \) satisfying the inequality \(h^{4}\leq \tau ^2 \) to verify the rate of convergence in the time variable. Then we obtain an \(O(\tau ^2)\) scheme and deal with the second Runge rule (55).

In a similar way, when considering the order with respect to \(h \), we take care that the inequality \(h^{4}\geq \tau ^2 \) holds in the calculations. Then we can apply the first Runge rule (55).

Tables 1 and 2 list the rates of convergence of the approximate solution to the exact one.

Fig. 1.
figure 1

Numerical (a) and exact (b) solutions for \(h=0.5\) and \(\tau =0.5 \).

Fig. 2.
figure 2

Numerical (a) and exact (b) solutions for \(h=0.25\) and \(\tau =0.125 \).

Hence we see that the constructed difference scheme has the fourth order of accuracy in the spatial variable and the second order of accuracy in the time variable.

In addition, in Figs. 1 and 2 one can clearly see by colors and figures that the approximate solution converges to the exact solution as the grid increments \(h \) and \(\tau \) are refined. For convenience of visual observation, the above results were produced in the domain \(0\leq x\leq 10\), \(0\leq t\leq 10 \).

The computational experiment confirms our theoretical conclusions.