Linear equations in time

This page explains how pdemagic solves equations of first order in time,

\[\frac{\partial u}{\partial t} = A u + f(\mathbf{x}, t), \qquad u(\mathbf{x}, t_0) = u_0(\mathbf{x}),\]

where \(A\) is a linear operator with constant coefficients that acts in space. The heat equation is the case \(A = a \nabla^2\). First derivatives in space make the solution drift, the unknown itself makes it grow or decay, and on a periodic box \(A\) can be any operator at all. The coefficients and the unknown may be complex: the Schrödinger equation of a free particle is the case \(A = \tfrac{i}{2} \nabla^2\).

Equations of second order in time, with the wave equation first among them, are solved in the same way. They have a section of their own below.

The method

\(A\) multiplies each wave \(e^{i\mathbf{k}\cdot\mathbf{x}}\) by a number \(\sigma(\mathbf{k})\), its symbol (as for stationary equations). In Fourier space the equation therefore falls apart into one ordinary differential equation per wave, \(\hat u' = \sigma \hat u + \hat f\), with the exact solution

\[\hat u(t + h) = e^{\sigma h}\, \hat u(t) + \int_0^h e^{\sigma (h - s)}\, \hat f(t + s)\, ds .\]

pdemagic evaluates this formula. It does not step through time with a difference scheme.

  • Without a source nothing is approximated in time. The solution at any time follows from the initial state in one step, however far away, and however stiff the equation is.

  • With a source that does not depend on time the integral has a closed form, and the same holds.

  • With a source that depends on time the time between two recorded times is divided into steps. Within each step the source is replaced by the cubic polynomial in time through its values at the four Gauss points of the step, and the integral of that polynomial is evaluated exactly, for every wave. The only error in time is that of the interpolation.

Free directions

On an unbounded domain the solution spreads beyond any box, and a transform on the box alone would let it come back in from the opposite side. The transform is therefore padded by the distance the solution can travel in the time span: \(\sqrt{4 a T \ln(1/\epsilon)}\) by diffusion with the coefficient \(a\), and \(|b| T\) by drift with the velocity \(b\).

With this padding, what lies in the box is the solution of the problem in free space, even after part of it has left the box. The diagnostics report how much of the solution has reached the faces of the box at the end (solution_boundary_ratio). That is a statement about what the box shows, not about an error.

These distances are known for \(A\) of the form \(\sum_j \left(a_j \partial_j^2 + b_j \partial_j\right) + c\) with \(\operatorname{Re} a_j \ge 0\) and real \(b_j\). For any other operator the distance is bounded. Periodic directions can be mixed in.

Dispersion

An imaginary part of \(a_j\), as in the Schrödinger equation, neither damps a wave nor moves all waves alike. The wave \(e^{ikx}\) travels with its group velocity \(2 k \operatorname{Im} a\), the faster the finer it is. How far the solution travels therefore depends on which waves it is made of. pdemagic takes the transform of the initial state and of the source, finds the lowest and the highest wave number whose amplitude exceeds \(10^{-12}\) of the largest, and pads by the distance that those two waves travel. This comes on top of the padding for diffusion and drift.

For a Gaussian wave packet this is what the exact solution does at late times: it has fallen to \(10^{-12}\) where the fastest of these waves has arrived.

A state given as an array with noise up to the finest waves of its grid has waves that travel very far. If the padded transform would exceed \(2 \cdot 10^8\) points, pdemagic refuses the solve and says so.

Any other operator

A third derivative, a fourth, a mixed one: for these the distance has no closed form. It can be large on one side and small on the other. In the linear Korteweg–de Vries equation \(u_t + u_{xxx} = 0\) the wave \(e^{ikx}\) runs to the left with \(3k^2\), and to the right there is only the tail of an Airy function. A fourth derivative that damps, \(u_t = -u_{xxxx}\), spreads the solution like diffusion, but with another law.

pdemagic bounds the distance from the symbol \(\lambda(k)\) of the operator, by which the wave \(e^{ikx}\) grows as \(e^{\lambda(k) t}\). Along one axis the path of the Fourier integral is moved off the real axis by \(\kappa\). The wave \(k + i\kappa\) decays in space as \(e^{-\kappa x}\), and grows in time at the rate \(\operatorname{Re}\lambda(k + i\kappa)\) at most. So at the distance \(d\) beyond a face of the box the solution is at most

\[e^{-\kappa d} \sum_k |W_\kappa(k)|\; e^{\operatorname{Re}\lambda(k + i\kappa)\,T},\]

where \(W_\kappa\) is the transform of what is given, weighted by \(e^{\kappa x}\) with \(x\) counted from that face. The sum runs over the waves that the initial state and the source contain above \(10^{-12}\) of the largest, as for dispersion of second order. The path may be moved only as far as the waves at the edge of that band stay small on the way, which asks that \(d \ge \operatorname{Re}\lambda(k + is)\,T/s\) for every \(s\) up to \(\kappa\): for a wave that neither grows nor decays, the limit of small \(s\) is its group velocity times \(T\). Every \(\kappa\) gives a distance beyond which the solution is below the tolerance, and the smallest is taken, over a ladder of values of \(\kappa\). An equation of second order in time has two rates for each wave, and the faster one counts.

For the heat equation this gives the distance at which its Gaussian has fallen to the tolerance, and for the Schrödinger equation the travel of its fastest wave. Measured for \(e^{-x^2}\) on a box from \(-8\) to \(8\): the padding that the bound asks for, and how far beyond the box the solution is in fact above \(10^{-12}\) of its start.

Equation

\(T\)

Padding

Travelled, left

right

\(u_t = -u_{xxx}\)

0.1

32

25

1

\(u_t = -u_{xxx}\)

1

321

303

9

\(u_t = \tfrac1{10}u_{xx} - u_{xxx}\)

1

272

215

9

\(u_t = -u_{xxxx}\)

1

34

25

25

\(u_{tt} = -u_{xxxx}\)

1

21

13

13

With that padding the solutions agree with their Fourier integrals to \(10^{-11}\) and better, in the box that the planner chooses and in a narrow one that the solution has long left: see accuracy.

The bound costs a transform along one axis for each \(\kappa\) that can matter, a few for each face of the box. In three dimensions that is felt: the bound takes about as long as the propagation.

Waves: second order in time

The equation is

\[\frac{\partial^2 u}{\partial t^2} + \gamma \frac{\partial u}{\partial t} = A u + f(\mathbf{x}, t),\]

with the unknown and its rate of change given at the start. The wave equation is the case \(A = c^2 \nabla^2\) and \(\gamma = 0\). A positive \(\gamma\) damps the waves (the telegraph equation), and a term \(-m^2 u\) in \(A\) gives them a mass (the Klein–Gordon equation).

Each Fourier wave is now an oscillator, \(\hat u'' + \gamma \hat u' = \sigma \hat u + \hat f\), with the two exponents \(\lambda_\pm = -\gamma/2 \pm \sqrt{\gamma^2/4 + \sigma}\). Its state, \(\hat u\) and \(\hat u'\), is propagated exactly over any length of time, and a source is treated as before. The energy of the wave equation is therefore conserved to rounding error: over 40 recorded times it changes by less than \(10^{-13}\) of itself.

The formulas contain differences such as \((e^{\lambda_+ h} - e^{\lambda_- h})/(\lambda_+ - \lambda_-)\). Where the two exponents come close, as for the constant wave of the wave equation or at critical damping, the difference is evaluated as the integral of the derivative between them, which has no cancellation.

Free directions. Waves have a sharp front that moves with the speed \(c = \sqrt{a}\), where \(a\) is the coefficient of the second derivative. The transform is padded by \(cT\), which is exact: nothing is cut off. Lower derivatives and damping do not change the speed of the front.

For \(u_0 = e^{-r^2}\) at rest in three dimensions, whose solution is a spherical shell that leaves the centre, on a box of half-width 5.5 after one unit of time with \(c = 1.5\):

Points per axis

Error

16

5.6e-4

24

9.3e-7

32

1.0e-10

48

1.4e-15

With a source that depends on time the convergence in the number of steps is the same as for the first order.

An equation of second order in time whose waves grow the faster the finer they are is not a wave equation. \(\partial^2 u/\partial t^2 = -\nabla^2 u\) is Laplace’s equation in disguise, and has no initial value problem. It is refused in the same way as the heat equation backwards.

Accuracy

In space the method is spectral. For the heat equation in two dimensions with \(u_0 = e^{-r^2}\) on a box of half-width 5.5, after one unit of time:

Points per axis

Error

12

8.1e-4

16

3.0e-6

24

3.0e-13

32

1.1e-16

For the Schrödinger equation of a free particle in one dimension, with the wave packet \(u_0 = e^{-x^2 + 2ix}\) after one unit of time:

Points

Error

48

3.1e-3

64

1.7e-5

96

1.6e-12

128

1.5e-15

For the linear Korteweg–de Vries equation \(u_t + u_{xxx} = 0\) on the line, with \(u_0 = e^{-x^2}\), against the Fourier integral of the solution: \(8\cdot10^{-14}\) after a tenth of a unit of time, on the 128 points of the planner, and \(4\cdot10^{-12}\) after one unit, on 512. A beam, \(u_{tt} = -u_{xxxx}\), comes out to \(6\cdot10^{-14}\) after one unit, and a plate in the plane, \(u_{tt} = -\nabla^4 u\), to \(10^{-15}\).

In time there is an error only for a source that depends on time. For \(u = \cos(x) \sin(3t)\) on a ring, with the two units of time divided into two intervals:

Steps per interval

Error

1

9.2e-6

2

2.7e-8

4

1.0e-10

8

3.9e-13

Every halving of the step gains a factor of about 300, which is the eighth order of the Gauss points. For waves that decay much faster than the source changes the order falls to four, but those waves respond to the source in proportion to their decay time, so their error is small in absolute terms.

What the planner chooses

  • The box holds the initial state and the source, to \(10^{-12}\) of their maximum. Along free directions it is extended by the distance over which the solution spreads until the end of the time span, down to \(10^{-6}\) of its maximum. The values are exact wherever the box ends, so this is a choice of what is worth looking at. With dispersion the box is extended by the distance that the waves of the initial state travel, down to those with \(10^{-6}\) of the largest amplitude, and for any other operator by its bound for \(10^{-6}\).

  • The grid resolves the initial state and the source.

  • The recorded times are 21, evenly spaced over the time span. On large grids there are fewer, so that the record stays below 160 MB. They are the entry times of the plan, and can be any times within the time span.

  • The steps between two recorded times are one, unless the source depends on time. Then the planner doubles them until the integral of the source over the time span no longer changes.

Equations that are refused

Forwards in time, the heat equation smooths. Backwards, it amplifies every wave the more the finer it is, and rounding errors grow without bound. If any wave on the grid would grow by more than a factor of \(e^{36}\) beyond what the constant wave does, pdemagic refuses the problem as ill-posed. Plain growth, as in \(\partial u/\partial t = u\), is fine.

With free directions and an operator above the second order, the form of an equation no longer says whether it is well-posed. There the waves of the grid are compared with waves that are two, four and eight times finer: if a finer wave grows faster than every wave of the grid, the equation is refused, however short the time span is. Growth that ends is taken: in \(u_t = -u_{xx} - u_{xxxx}\) the long waves grow and the short ones decay.

Cost

One padded transform for the initial state, and one for every recorded time. A source that depends on time costs four more per step. In three dimensions, the heat equation on a 128³ grid with nine recorded times takes about three seconds, and the wave equation on a 64³ grid with 21 recorded times a second and a half.

Limits

  • First or second order in time.

  • Linear, with constant coefficients.

  • Cartesian coordinates, without bodies. On a box with boundary conditions the same propagation runs in the modes of the box in place of Fourier waves, and on round domains with boundary conditions in theirs: see collocation. On a region of the plane it runs in the modes of the shape, for heat, waves and the Schrödinger equation, also with a density, in a medium and with a potential that vary in space, and with a drift that is not too strong: see spectral elements.

  • One unknown. Systems are propagated with a small matrix for each wave: see coupled systems.

  • With free directions, an operator above the second order stands alone. Terms that are stepped beside it, as the nonlinear term of the Korteweg–de Vries equation, need a periodic box.

  • A solution that travels far needs a large box. Short waves of a third derivative are fast, and the box that shows a millionth of the start grows with them. An automatic grid has 512 points along a side at most: beyond that the plan says that its grid does not resolve what is given, and grid.shape or a smaller box is the remedy.