Skip to content

A traveling wave gives a useful calibration for a soliton code before adding nonlinear scattering. Transport a unit Gaussian at unit speed for unit time. The exact solution on the line is u(x,1)=e−(x−1)2u(x,1)=e^{-(x-1)^2}. Replacing the line by a periodic box, replacing the derivative by a difference, and stepping forward in time are three separate choices. By introducing an exact reference between consecutive choices we can measure the contribution from each.

Required background. Residuals and forward errors defines the discrepancy between an approximate solution and the chosen reference.

Consider ut+ux=0u_t+u_x=0 with smooth data. On a circle of length LL choose the exact periodic initial profile

gL(x)=∑j∈Ze−(x+jL)2.g_L(x)=\sum_{j\in\mathbb Z}e^{-(x+jL)^2}.

The periodic solution at time one is gL(x−1)g_L(x-1). At the peak x=1x=1 its difference from the line solution is 2∑j=1∞e−j2L22\sum_{j=1}^\infty e^{-j^2L^2}. For L=2,3,4L=2,3,4 this is respectively 3.66315×10−23.66315\times10^{-2}, 2.46820×10−42.46820\times10^{-4} and 2.25070×10−72.25070\times10^{-7}. There is no integration scheme in this computation. The change is a modeling error if the intended experiment is on the line. It is part of the correct solution if the experiment is on a ring. Away from the peak use the image sum at the actual observation point.

One box can resolve the peak and miss the tail

Section titled “One box can resolve the peak and miss the tail”

Compare the line and circle on one cell centered at the moving peak. At its opposite point x=1+L/2x=1+L/2, two periodic copies contribute equally. Subtracting the isolated line Gaussian leaves the nearest image and pairs of more distant images. Writing BL(d)=gL(d)−e−d2B_L(d)=g_L(d)-e^{-d^2} for the image bias at offset dd gives

BL(L/2)=e−L2/4+2∑j=1∞e−(j+1/2)2L2. B_L(L/2)=e^{-L^2/4} +2\sum_{j=1}^\infty e^{-(j+1/2)^2L^2}.

At L=4L=4 the peak bias is 2.25×10−72.25\times10^{-7}, while the bias opposite the peak is 1.83×10−21.83\times10^{-2}. The isolated tail there is itself e−4e^{-4}, so the box has almost doubled the field in that measurement. As LL grows, the leading peak bias decays as 2e−L22e^{-L^2} and the opposite-point bias as e−L2/4e^{-L^2/4}. The latter tends to zero in absolute units while its ratio to the isolated tail tends to one. An error tolerance for a tail measurement therefore needs both an observation point and a choice of absolute or relative units.

There is also a precision limit to subtracting two peak values. At L=7L=7, adding the images to the unit peak and subtracting one returns zero in binary64. Summing the images directly gives 1.04858×10−211.04858\times10^{-21}. This deficit is already smaller than half the spacing between one and the next larger floating-point value. Reproduce both observation points and the cancellation (Python)

Keep the spatial model fixed while testing time

Section titled “Keep the spatial model fixed while testing time”

Take h=L/Nh=L/N and use the periodic centered difference (uj+1−uj−1)/(2h)(u_{j+1}-u_{j-1})/(2h). A Fourier grid mode eijθe^{ij\theta} then has time generator λh=−isin⁡(θ)/h\lambda_h=-i\sin(\theta)/h, compared with −iθ/h-i\theta/h for a resolved continuum Fourier mode. The expansion sin⁡θ=θ−θ3/6+⋯\sin\theta=\theta-\theta^3/6+\cdots explains the leading second-order phase error for a fixed physical wave number. At θ=π\theta=\pi on an even grid the alternating nodal mode is stationary under the centered scheme. Its amplitude remains exactly constant while the continuum mode changes phase. Trefethen’s plane-wave calculation uses the opposite transport direction, ut=uxu_t=u_x. Trefethen, §5.1, p. 193, equations (5.1.1)–(5.1.3), chapter PDF

Using an FFT of the sampled initial data, multiply each mode by exp⁡(λh)\exp(\lambda_h) to integrate the semidiscrete problem exactly to time one. To test the usual fourth-order Runge–Kutta method on the same spatial problem, use mm equal steps and replace this multiplier by

(1+z+z22+z36+z424)m,z=λh/m.\left(1+z+\frac{z^2}{2}+\frac{z^3}{6}+\frac{z^4}{24}\right)^m, \qquad z=\lambda_h/m .

The polynomial follows by applying the four stages to the scalar test equation y′=λhyy'=\lambda_h y. It is stable along the imaginary axis for ∣Im⁡z∣≤8|\operatorname{Im}z|\leq\sqrt8, as follows by multiplying it by its complex conjugate. Check stability again when refining the space grid at a fixed time step.

A refinement matrix with a known reference in each column

Section titled “A refinement matrix with a known reference in each column”

For L=8L=8 measure the spatial error as the maximum over grid points of the difference between the exactly evolved centered scheme and gL(xj−1)g_L(x_j-1). Measure the temporal error separately on 64 spatial points by comparing RK4 with the exact evolution of that grid. Each row shows two independent experiments.

Spatial pointsSpatial sup errorTime steps on 64 pointsTemporal sup error
320.0396895985.766×10−55.766\times10^{-5}
640.01013910163.618×10−63.618\times10^{-6}
1280.00253593322.278×10−72.278\times10^{-7}
2560.00063545641.425×10−81.425\times10^{-8}

Second-order spatial convergence reduces the error by about four on doubling NN. Fourth-order temporal convergence reduces it by about sixteen on doubling mm. At N=64N=64 the total error against the exact periodic wave is 0.010139330.01013933 at 32 steps and 0.010139110.01013911 at 64 steps. Space already contributes 0.010139100.01013910. A time solver can agree to seven digits with its own spatial reference while a field value still differs from the periodic wave by about 10−210^{-2}. In a total-error comparison the two contributions can also cancel at a particular point. Preserve the componentwise comparisons before taking a norm. Reproduce the three refinements (Python)

For a nonlinear wave, replace the exactly evolved spatial system by a much tighter time solve and independently test that reference. A Fourier-mode cutoff, a rapidity cutoff, the number of physical particles, and arithmetic precision each change a different object. Vary them separately while holding the physical density, boundary data and observation time appropriate to the stated limit. A changed-input exercise is to track the width or phase of the pulse instead of its height; those observables weight the Fourier modes differently. A fully nonlinear worked transfer is the two-soliton collision laboratory.

  • L. N. Trefethen, Finite Difference and Spectral Methods for Ordinary and Partial Differential Equations, unpublished text, 1996, chapters 2–5. Author’s text