van der Pol System

← Numerical Methods

Source inspiration: (Mathew 2000-2019).

Description

The van der Pol equation \(x'' - \mu (1 - x^2)\, x' + x = 0\), with a constant \(\mu \ge 0\), is an oscillator whose damping depends on the displacement \(x\). For \(\mu > 0\), while \(|x| < 1\) the damping coefficient \(-\mu(1 - x^2)\) is negative and pumps energy in, and while \(|x| > 1\) it is positive and drains energy out. For \(\mu = 0\) the equation is the harmonic oscillator \(x'' + x = 0\), whose solutions other than \(x = 0\) run round circles in the phase plane. For every \(\mu > 0\) there is exactly one periodic solution, a closed curve called the limit cycle, and every other solution except the equilibrium at the origin winds onto it, from outside or from inside.

For \(\mu > 0\) Mathews computes the solutions numerically. With \(y = x'\) the equation becomes the first-order system \(x' = y\), \(y' = -x + \mu(1 - x^2)\, y\), and Mathews solves that system with the fourth-order Runge-Kutta method in vector form. With the vector \(\mathbf{Z} = (x, y)\), the right-hand side \(\mathbf{F}(t, \mathbf{Z}) = \bigl(y,\ -x + \mu(1 - x^2)\, y\bigr)\) and a fixed step \(h = (b - a)/n\), each step is

\[ \mathbf{Z}_{j+1} = \mathbf{Z}_j + \frac{1}{6}\bigl(\mathbf{k}_1 + 2\mathbf{k}_2 + 2\mathbf{k}_3 + \mathbf{k}_4\bigr), \]

where the four vectors \(\mathbf{k}_i\) are \(h\) times \(\mathbf{F}\) evaluated at the start, twice at the middle and once at the end of the step (equation (5) below). Mathews’ module has six examples, \(\mu = 0, \tfrac{1}{16}, \tfrac14, \tfrac12, 1, 4\), and plots the solution of Example 1 as a path in the \(xy\)-plane. Example 1 (\(\mu = 0\)) survives in full: it starts at \((x, y) = (0, 3)\) and takes \(n = 400\) steps over one turn, \(0 \le t \le 6.283185\). For Examples 2 to 6 the archive keeps only the value of \(\mu\), so this page keeps Example 1’s starting point and integrates over \(0 \le t \le 60\) with \(n = 6000\) steps (\(h = 0.01\)). Every number below has been recomputed.

Animations

Each animation below traces Runge-Kutta solutions (5) in the phase plane, the \(xy\)-plane in which Mathews draws his solutions: the computed points \(\mathbf{Z}_j\) are joined by straight segments, as in his plot, and a large dot marks the current point. Cases 1 and 3 also plot the computed \(x\) and \(y\) against \(t\). The limit cycles (black, dashed) are computed separately, with the Runge-Kutta method at \(h = 0.001\) run for \(200\) time units from \((2, 0)\) before one period is drawn. Maxima of \(x\) and the other marked times are located by bisection on the size of one Runge-Kutta step from the last computed point, not read off the grid, and agree with the values in the examples below. The last frame of each animation is held for about three seconds.

Mathews’ module links no animation, and his animation archive has none for the van der Pol equation, so all three animations are new, with no Mathews original. Case 1 animates Example 1 with Mathews’ values and his plot style (magenta, axes marked from \(-3\) to \(3\), aspect ratio \(1\)). Cases 2 and 3 animate Examples 2 to 6, whose intervals, starting points and plots are lost, with this page’s choices: the start \((0, 3)\) over \(0 \le t \le 60\) with \(n = 6000\), together with the run from \((0, 0.5)\) of “Starting inside the cycle”. Every example of the module is animated; not animated are the page’s verification tables (Example 1’s errors for \(n = 100\) to \(1600\) and the comparison of Examples 2 to 6 with the order-8 reference solver), which are checks rather than pictures.

Julia source scripts that generated these animations are linked under each case.

Case 1 — Example 1: \(\mu = 0\), from \((0, 3)\) over \(0 \le t \le 6.283185\), \(n = 400\)

Behavior: Four steps per frame, the computed points run clockwise round the circle of radius \(3\) from its top point \((0, 3)\) and close it up after \(400\) steps at \((-9.31101 \times 10^{-7},\ 2.99999999987)\), Mathews’ printed end point \(\{-9.31101 \times 10^{-7}, 3.\}\). In the time panel they lie on \(3 \sin t\) and \(3 \cos t\). The error panel shows, on a logarithmic scale, the distance of each point from the exact point \((3 \sin t_j, 3 \cos t_j)\), which never decreases and reaches \(9.563 \times 10^{-9}\) at the end, and the amount by which its distance from the origin falls short of \(3\), which also never decreases and reaches \(1.252 \times 10^{-10}\): the method loses a tiny amount of energy each step, as the verification of Example 1 explains.

Julia source

Runge-Kutta solution of x′′ + x = 0 (μ = 0) from (x, y) = (0, 3) with n = 400 steps over 0 ≤ t ≤ 6.283185, traced four steps per frame in Mathews’ style (magenta, axes −3 to 3, aspect ratio 1) clockwise round the dashed exact circle of radius 3 to the end point (−9.31101e−7, 2.99999999987), with x(t) and y(t) on the exact 3 sin t and 3 cos t, and on a log scale the error, growing to 9.563e−9, and the shrink of the distance from the origin, growing to 1.252e−10

Case 2 — Examples 2 to 5: \(\mu = \tfrac{1}{16}, \tfrac14, \tfrac12, 1\), from \((0, 3)\) and \((0, 0.5)\), \(h = 0.01\) on \(0 \le t \le 60\)

Behavior: The four examples advance together, \(0.25\) time units per frame. In each panel the run from \((0, 3)\) (magenta) winds inwards onto the limit cycle from outside and the run from \((0, 0.5)\) (blue) winds outwards onto it from inside. The diamonds on the positive \(x\)-axis are the maxima of \(x\): from outside they decrease and from inside they increase towards the cycle’s largest \(x\), which the panel title prints with the factor \(\rho\) by which the gap shrinks per turn. The larger \(\mu\), the faster the approach. For \(\mu = \tfrac{1}{16}\) (\(\rho = 0.6751\)) the tenth maxima, \(2.014879\) and \(1.692056\) near \(t = 58.12\), are still \(0.0148\) above and \(0.308\) below the cycle’s \(2.000041\), and the run from inside is a slowly widening spiral; for \(\mu = \tfrac14\) the tenth maxima are \(2.000644\) and \(2.000637\); for \(\mu = \tfrac12\) both runs equal the cycle’s \(2.002488\) to seven figures from their sixth and seventh maxima, and for \(\mu = 1\) they equal \(2.008620\) from their third and fourth. As \(\mu\) grows the cycle changes from a near circle of radius \(2\) into a lopsided loop, with largest \(|y|\) \(2.6784\) for \(\mu = 1\).

Julia source

Four phase-plane panels, one each for μ = 1/16, 1/4, 1/2 and 1, in which Runge-Kutta solutions of x′ = y, y′ = −x + μ(1 − x²)y with h = 0.01 from (0, 3) (magenta, outside) and (0, 0.5) (blue, inside) wind onto the dashed limit cycle over 0 ≤ t ≤ 60, with diamonds at the maxima of x closing in on the cycle’s largest x (2.000041, 2.000644, 2.002488, 2.008620) from both sides; the approach is slowest for μ = 1/16, where the tenth maxima are still 2.014879 and 1.692056, and fastest for μ = 1

Case 3 — Example 6: \(\mu = 4\), the relaxation oscillation, from \((0, 3)\) and \((0, 0.5)\), \(h = 0.01\) on \(0 \le t \le 60\)

Behavior: Both starts are inside this cycle, \(0.2\) time units per frame. The run from \((0, 3)\) reaches its first maximum of \(x\), \(1.957\) at \(t = 0.6541\), below the cycle’s \(2.023\), and its second, at \(t = 10.47\), is on the cycle; the run from \((0, 0.5)\) joins it at its own second maximum, after which both repeat the same oscillation, the run from \((0, 0.5)\) \(0.9736\) time units ahead. On the cycle \(x\) drifts slowly from \(2.023\) down to \(1\) in \(3.86\) time units (yellow band), while the path in the phase plane stays within \(0.022\) of the curve \(y' = 0\) (orange) for \(1.5 \le x \le 2\); then \(x\) falls from \(1\) to \(-1\) in only \(0.829\) (red band), and during the fall \(|y|\) peaks at \(6.344\) at \(x = -0.9805\) (star). The other half of the cycle is the same half turned through \(180^\circ\) about the origin. So the dots crawl along the slow parts and jump across the fast parts in about four frames, and \(y(t)\) is a narrow spike on each fall.

Julia source

Runge-Kutta solutions of x′ = y, y′ = −x + 4(1 − x²)y with h = 0.01 from (0, 3) (magenta) and (0, 0.5) (blue) over 0 ≤ t ≤ 60, in the phase plane with the dashed limit cycle, the curve y′ = 0 and the lines x = ±1, beside x(t) and y(t): the runs reach the cycle at their second maxima of x and then repeat the relaxation oscillation, x drifting from 2.023 to 1 in 3.86 time units and falling from 1 to −1 in 0.829, with |y| peaking at 6.344 at x = −0.9805

The van der Pol Equation

NoteDefinition — van der Pol equation

The van der Pol equation is the second-order differential equation

\[ x'' - \mu \left(1 - x^2\right) x' + x = 0, \tag{1} \]

where \(\mu\) is a constant. Mathews takes \(\mu > 0\) in the definition, and his first example uses \(\mu = 0\).

When \(\mu = 0\) the equation reduces to \(x'' + x = 0\), which has the familiar solution

\[ x(t) = c_1 \cos t + c_2 \sin t . \]

For \(\mu > 0\) the middle term \(-\mu(1 - x^2)\, x'\) acts like friction or resistance where its coefficient \(-\mu(1 - x^2)\) is positive, that is where \(|x| > 1\). Where \(|x| < 1\) the coefficient is negative, the case of “negative resistance”, which feeds energy into the motion. Mathews notes that vacuum-tube circuits of early radios showed such negative resistance; the equation is named after Balthasar van der Pol (1889–1959), who studied it, and its solutions show orbital stability: nearby solutions are drawn onto the same closed path.

The equivalent first-order system

With \(y = x'\), equation (1) becomes the system

\[ x' = y, \qquad y' = -x + \mu\left(1 - x^2\right) y . \tag{2} \]

Energy

The energy of the harmonic oscillator, \(E = \tfrac12 (x^2 + y^2)\), is the squared distance from the origin, halved. Along a solution of (2),

\[ \frac{dE}{dt} = x x' + y y' = x y + y\bigl(-x + \mu(1 - x^2)\, y\bigr) = \mu \left(1 - x^2\right) y^2 . \tag{3} \]

For \(\mu = 0\) the energy is constant, so every solution runs round a circle centred at the origin. For \(\mu > 0\) the energy grows while \(|x| < 1\) and decays while \(|x| > 1\) (wherever \(y \ne 0\)), so small oscillations are pushed outwards and large ones pulled inwards.

The equilibrium at the origin

The only equilibrium of (2) is \((0, 0)\), since \(x' = 0\) forces \(y = 0\) and then \(y' = 0\) forces \(x = 0\). The Jacobian matrix of (2) at the origin and its eigenvalues are

\[ \mathbf{J}(0, 0) = \begin{pmatrix} 0 & 1 \\ -1 & \mu \end{pmatrix}, \qquad \lambda^2 - \mu \lambda + 1 = 0, \qquad \lambda = \frac{\mu \pm \sqrt{\mu^2 - 4}}{2} . \]

For \(\mu = 0\) the eigenvalues are \(\pm i\) and the origin is a centre, surrounded by the circles. For \(0 < \mu < 2\) they are complex with positive real part \(\mu/2\), so solutions spiral away from the origin; for \(\mu = 2\) there is the double eigenvalue \(1\), and for \(\mu > 2\) both eigenvalues are real and positive, so solutions leave the origin without spiralling. In every case with \(\mu > 0\) the origin repels.

\(\mu\) eigenvalues of \(\mathbf{J}(0, 0)\) type of the origin
\(0\) \(\pm i\) centre
\(\tfrac{1}{16}\) \(0.03125 \pm 0.99951\, i\) unstable spiral
\(\tfrac14\) \(0.125 \pm 0.99216\, i\) unstable spiral
\(\tfrac12\) \(0.25 \pm 0.96825\, i\) unstable spiral
\(1\) \(0.5 \pm 0.86603\, i\) unstable spiral
\(4\) \(2 - \sqrt3 = 0.26795\) and \(2 + \sqrt3 = 3.73205\) unstable node

The limit cycle

NoteDefinition — Limit cycle

A limit cycle of a system \(x' = f_1(x, y)\), \(y' = f_2(x, y)\) is a closed path traced by a periodic solution that has no other closed paths arbitrarily close to it. It is stable when the solutions that start near it approach it as \(t \to \infty\).

The circles of the case \(\mu = 0\) are closed paths, but each has others arbitrarily close to it, so none of them is a limit cycle.

TipTheorem — Liénard’s theorem, applied to the van der Pol equation (general)

Write (1) as \(x'' + f(x)\, x' + g(x) = 0\) with \(f(x) = \mu(x^2 - 1)\) and \(g(x) = x\), and let \(F(x) = \int_0^x f(s)\, ds = \mu\bigl(\tfrac13 x^3 - x\bigr)\). Liénard’s theorem gives a unique stable limit cycle when \(F\) and \(g\) have continuous derivatives, \(g\) is odd with \(x g(x) > 0\) for \(x \ne 0\), \(F\) is odd with \(F'(0) < 0\), \(F\) has a single positive zero \(x = a\), and \(F\) increases to \(\infty\) for \(x \ge a\). For \(\mu > 0\) all of these hold, with \(F'(0) = -\mu\), \(a = \sqrt3\) and \(F'(x) = \mu(x^2 - 1) > 0\) for \(x \ge \sqrt3\). So for every \(\mu > 0\) the van der Pol equation has exactly one periodic solution up to a shift in time, and every solution other than the equilibrium \(x = 0\) approaches it as \(t \to \infty\).

The theorem does not say where the cycle is. Its size for small \(\mu\) follows from the energy equation (3): when \(\mu\) is small a solution is nearly a circle \(x = A \sin t\), \(y = A \cos t\) over one turn, and the net energy gained over that turn is

\[ \int_0^{2\pi} \mu \left(1 - A^2 \sin^2 t\right) A^2 \cos^2 t \, dt = \frac{\pi \mu A^2}{4}\left(4 - A^2\right) . \tag{4} \]

This is positive for \(A < 2\) and negative for \(A > 2\), so for small \(\mu\) the limit cycle is close to the circle of radius \(2\). This is an approximation for small \(\mu\); the computed cycles below have their largest \(x\) between \(2.00004\) (for \(\mu = \tfrac{1}{16}\)) and \(2.02296\) (for \(\mu = 4\)), and their period grows from close to \(2\pi\) to \(10.2035\).

\(\mu\) period \(P\) largest \(x\) on the cycle largest \(\lvert y \rvert\) on the cycle gap factor per turn \(\rho\)
\(\tfrac{1}{16}\) \(6.284719\) \(2.000041\) \(2.0046\) \(0.6751\)
\(\tfrac14\) \(6.307688\) \(2.000644\) \(2.0670\) \(0.2053\)
\(\tfrac12\) \(6.380676\) \(2.002488\) \(2.2270\) \(0.03918\)
\(1\) \(6.663287\) \(2.008620\) \(2.6784\) \(8.597 \times 10^{-4}\)
\(4\) \(10.203524\) \(2.022963\) \(6.3442\) \(1.3 \times 10^{-25}\)

The cycles were computed with an adaptive Runge-Kutta method of order 8 at tolerance \(10^{-13}\), run for \(200\) time units from \((2, 0)\) before measuring, and the periods and largest \(x\) were confirmed to all the digits shown by an independent implicit (Radau) solver. The last column is the factor by which the gap between a nearby solution and the cycle shrinks in one turn. For a periodic solution of a plane system, that factor is (a general result) the exponential of the integral of the divergence \(\partial f_1/\partial x + \partial f_2/\partial y = \mu(1 - x^2)\) over one period,

\[ \rho = \exp\!\left( \mu \int_0^P \bigl(1 - x(t)^2\bigr)\, dt \right), \]

and for small \(\mu\), where \(x \approx 2 \cos t\), the integral is close to \(-2\pi\mu\) and \(\rho \approx e^{-2\pi\mu}\) (\(0.6752\) for \(\mu = \tfrac{1}{16}\)). The cycle attracts slowly for small \(\mu\) and extremely fast for \(\mu = 4\), as the examples show.

The Runge-Kutta Method for a System

NoteInitial value problem in the plane

Compute approximations to the solution of

\[ x' = f_1(t, x, y), \quad x(a) = \alpha, \qquad y' = f_2(t, x, y), \quad y(a) = \beta, \qquad a \le t \le b, \]

at a discrete set of points \(t_0 = a < t_1 < \cdots < t_n = b\). In vector form, with \(\mathbf{Z} = (x, y)\) and \(\mathbf{F}(t, \mathbf{Z}) = \bigl(f_1(t, x, y),\ f_2(t, x, y)\bigr)\), the problem is \(\mathbf{Z}' = \mathbf{F}(t, \mathbf{Z})\), \(\mathbf{Z}(a) = (\alpha, \beta)\).

The Runge-Kutta method in two dimensions is the “vector form” of the one-dimensional method: the function \(f\) is replaced by the vector function \(\mathbf{F}\), and every stage is computed for both components at once.

ImportantRunge-Kutta method of order 4 for a system

With \(h = (b - a)/n\), \(t_j = a + j h\) and \(\mathbf{Z}_0 = (\alpha, \beta)\), for \(j = 0, 1, \ldots, n - 1\):

\[ \begin{aligned} \mathbf{k}_1 &= h\, \mathbf{F}(t_j, \mathbf{Z}_j), \\ \mathbf{k}_2 &= h\, \mathbf{F}\bigl(t_j + \tfrac{h}{2},\ \mathbf{Z}_j + \tfrac12 \mathbf{k}_1\bigr), \\ \mathbf{k}_3 &= h\, \mathbf{F}\bigl(t_j + \tfrac{h}{2},\ \mathbf{Z}_j + \tfrac12 \mathbf{k}_2\bigr), \\ \mathbf{k}_4 &= h\, \mathbf{F}\bigl(t_j + h,\ \mathbf{Z}_j + \mathbf{k}_3\bigr), \\ \mathbf{Z}_{j+1} &= \mathbf{Z}_j + \tfrac16 \bigl(\mathbf{k}_1 + 2\mathbf{k}_2 + 2\mathbf{k}_3 + \mathbf{k}_4\bigr). \end{aligned} \tag{5} \]

Mathews’ subroutine builds the list of times \(t_j\) and the list of points \(\mathbf{Z}_j\) and returns the points, which are then joined by line segments to draw the path in the \(xy\)-plane. For a smooth \(\mathbf{F}\) the method has global error of order \(h^4\) (a general result): doubling \(n\) divides the error by about \(16\), as both sets of examples below confirm. For the van der Pol system \(\mathbf{F}\) does not depend on \(t\), so the times \(t_j\) only label the points.

Example 1 — \(\mu = 0\): the harmonic oscillator

Solve the van der Pol equation with \(\mu = 0\),

\[ x'' + x = 0, \qquad x(0) = 0, \quad x'(0) = 3, \]

over \(0 \le t \le 6.283185\) with \(n = 400\) steps. These are the values in Mathews’ notebook.

Step 1: Write the equation as the system (2) with \(\mu = 0\):

\[ x' = y, \qquad y' = -x, \qquad \mathbf{F}(t, (x, y)) = (y, -x), \qquad \mathbf{Z}_0 = (0, 3). \]

Step 2: The step size is

\[ h = \frac{6.283185 - 0}{400} = 0.0157079625 . \]

Step 3: The first step, from \(t_0 = 0\):

\[ \begin{aligned} \mathbf{k}_1 &= h\,\mathbf{F}(0, (0, 3)) = h\,(3, 0) = (0.0471238875,\ 0), \\ \mathbf{k}_2 &= h\,\mathbf{F}\bigl(\tfrac{h}{2}, (0.02356194375,\ 3)\bigr) = (0.0471238875,\ -0.000370110129), \\ \mathbf{k}_3 &= h\,\mathbf{F}\bigl(\tfrac{h}{2}, (0.02356194375,\ 2.999814945)\bigr) = (0.0471209807,\ -0.000370110129), \\ \mathbf{k}_4 &= h\,\mathbf{F}\bigl(h, (0.0471209807,\ 2.999629890)\bigr) = (0.0471180738,\ -0.000740174597), \\ \mathbf{Z}_1 &= \mathbf{Z}_0 + \tfrac16 (\mathbf{k}_1 + 2\mathbf{k}_2 + 2\mathbf{k}_3 + \mathbf{k}_4) = (0.0471219496,\ 2.999629897). \end{aligned} \]

The exact value \(\bigl(3\sin h, 3\cos h\bigr) = (0.0471219496, 2.999629897)\) agrees to all the digits shown; the error in \(x\) is \(-2.4 \times 10^{-11}\).

Step 4: Repeating the step \(400\) times gives the end point

\[ \mathbf{Z}_{400} = \bigl(-9.311010 \times 10^{-7},\ 2.99999999987\bigr) \approx \bigl(-9.31101 \times 10^{-7},\ 3.\bigr), \]

which is the end point Mathews prints, \(\{-9.31101 \times 10^{-7}, 3.\}\).

The exact solution is \(x(t) = 3 \sin t\), \(y(t) = 3 \cos t\), the circle of radius \(3\) traced clockwise from its top point \((0, 3)\). Mathews plots the \(400\) segments in the \(xy\)-plane with both axes marked from \(-3\) to \(3\), and they close up into that circle.

Verification: The right end \(b = 6.283185\) is \(3.07 \times 10^{-7}\) short of \(2\pi\), so the exact solution there is not \((0, 3)\):

\(x(b)\) \(y(b)\)
Runge-Kutta, \(n = 400\) \(-9.311010 \times 10^{-7}\) \(2.9999999998747\)
exact, \(3\sin b\) and \(3\cos b\) \(-9.215388 \times 10^{-7}\) \(2.9999999999999\)
error \(-9.56 \times 10^{-9}\) \(-1.25 \times 10^{-10}\)

Most of the small \(x\) value in Mathews’ end point is the shortfall of \(b\), not error of the method. Over all \(401\) points the distance from the exact solution is at most \(9.56 \times 10^{-9}\), and the distance from the origin stays between \(3 - 1.3 \times 10^{-10}\) and \(3\). The method loses a tiny amount of energy each step: for \(\mathbf{F} = (y, -x)\) one Runge-Kutta step multiplies the distance from the origin by \(1 - 1.04 \times 10^{-13}\), which over \(400\) steps shrinks the radius by \(1.25 \times 10^{-10}\), the error in \(y(b)\) above. Over one full turn \(0 \le t \le 2\pi\) the largest error falls by a factor of \(16.0\) each time \(n\) is doubled, the order \(h^4\) of the method:

\(n\) \(100\) \(200\) \(400\) \(800\) \(1600\)
largest error on \([0, 2\pi]\) \(2.448 \times 10^{-6}\) \(1.530 \times 10^{-7}\) \(9.563 \times 10^{-9}\) \(5.977 \times 10^{-10}\) \(3.736 \times 10^{-11}\)

Examples 2 to 6 — \(\mu = \tfrac{1}{16}, \tfrac14, \tfrac12, 1, 4\)

Mathews solves the van der Pol equation with \(\mu = \tfrac{1}{16}\) (Example 2), \(\tfrac14\) (Example 3), \(\tfrac12\) (Example 4), \(1\) (Example 5) and \(4\) (Example 6):

\[ x'' - \tfrac{1}{16}\left(1 - x^2\right) x' + x = 0, \quad \ldots, \quad x'' - 4\left(1 - x^2\right) x' + x = 0 . \]

Each is the system (2) with \(\mathbf{F}(t, (x, y)) = \bigl(y,\ -x + \mu(1 - x^2)\, y\bigr)\), solved by (5). For these examples the archive keeps only the value of \(\mu\); the notebook cells with the interval, the number of steps and the starting point, and the plots, are lost. This page therefore keeps Example 1’s starting point \((x, y) = (0, 3)\), that is \(x(0) = 0\), \(x'(0) = 3\), and integrates over \(0 \le t \le 60\) with \(n = 6000\) steps, \(h = 0.01\).

Each solution is followed through the points where \(x\) has a local maximum, which are the points where the path crosses the positive \(x\)-axis (\(y = 0\), \(x > 0\)). Comparing those maxima with the largest \(x\) on the cycle (the table above) measures how far the solution still is from the limit cycle after each turn. The maxima below are located exactly (to the digits shown) with the order-8 reference solver; the Runge-Kutta points agree with it to within the errors listed in the verification table at the end of this section.

Example 2 — \(\mu = \tfrac{1}{16}\)

The cycle passes through the positive \(y\)-axis at \(y = 2.0007\), so \((0, 3)\) is outside it, and the solution spirals inwards. The ten maxima of \(x\) in \(0 \le t \le 60\) are

\[ 2.849009,\ 2.464188,\ 2.279308,\ 2.175986,\ 2.113772,\ 2.074697,\ 2.049523,\ 2.033042,\ 2.022140,\ 2.014879, \]

decreasing towards the cycle’s \(2.000041\). The gap shrinks by the factors \(0.547, 0.602, 0.630, \ldots, 0.671\) per turn, approaching \(\rho = 0.675\), so at the tenth maximum (\(t = 58.12\)) the solution is still \(0.0148\) outside the cycle. This is the slowest approach of the five: it takes many turns of a nearly circular path.

Example 3 — \(\mu = \tfrac14\)

The cycle crosses the positive \(y\)-axis at \(y = 2.0111\), so the solution again starts outside it. The maxima of \(x\) are

\[ 2.593435,\ 2.083519,\ 2.016735,\ 2.003912,\ 2.001313,\ 2.000781,\ 2.000672,\ 2.000650,\ 2.000645,\ 2.000644, \]

decreasing to the cycle’s \(2.000644\); from the sixth maximum on each gap is \(\rho = 0.2053\) times the one before (to four digits), down to \(2.4 \times 10^{-7}\) at the tenth maximum.

Example 4 — \(\mu = \tfrac12\)

The cycle crosses the positive \(y\)-axis at \(y = 2.0441\). The maxima of \(x\) are

\[ 2.418210,\ 2.012688,\ 2.002883,\ 2.002503,\ 2.002489,\ 2.002488, \ldots \]

and from the sixth on they equal the cycle’s \(2.002488\) to six decimals. From the fourth maximum on each gap is \(\rho = 0.0392\) times the one before, down to \(5.6 \times 10^{-14}\) at the tenth maximum.

Example 5 — \(\mu = 1\)

The cycle crosses the positive \(y\)-axis at \(y = 2.1727\). The maxima of \(x\) are

\[ 2.240070,\ 2.008728,\ 2.008620, \ldots \]

and from the third on (at \(t = 14.70\)) they equal the cycle’s \(2.008620\) to six decimals. The gaps are \(0.23\), \(1.1 \times 10^{-4}\), \(9.3 \times 10^{-8}\), \(8.0 \times 10^{-11}\) and \(6.8 \times 10^{-14}\), and from the third on each is about \(\rho \approx 8.6 \times 10^{-4}\) times the one before; from the sixth maximum on the solution is on the cycle to rounding level. The cycle is visibly no longer a circle: on it \(|y|\) reaches \(2.6784\) while \(|x|\) stays below \(2.0087\).

Example 6 — \(\mu = 4\)

Now the cycle crosses the positive \(y\)-axis at \(y = 3.7623\), so the starting point \((0, 3)\) is inside the cycle. The first maximum of \(x\) is \(1.956754\), below the cycle’s \(2.022963\), and the second, at \(t = 10.47\), already equals \(2.022963\) to rounding level (\(\rho = 1.3 \times 10^{-25}\)). The cycle is a relaxation oscillation, made of slow and fast parts. From its largest value \(2.023\), \(x\) takes \(3.860\) time units, \(76\%\) of the half period \(5.102\), to drift down to \(x = 1\); it then falls from \(1\) to \(-1\) in only \(0.829\) time units, and during that fall, at \(x = -0.9805\), \(|y|\) peaks at \(6.3442\). The other half of the cycle is this half turned through \(180^\circ\) about the origin, since (2) is unchanged when \((x, y)\) is replaced by \((-x, -y)\). Over the whole cycle \(|y|\) exceeds \(2\) only \(10.8\%\) of the time.

Starting inside the cycle

To see the cycle attract from inside as well, the same computation was repeated from \((x, y) = (0, 0.5)\), which is inside the cycle for all five values of \(\mu\). The maxima of \(x\) now increase towards the same values until they reach them: for \(\mu = \tfrac14\) they are \(0.606543, 1.140036, 1.664822, 1.913297, 1.981599, \ldots\), reaching \(2.000637\) at the tenth maximum. For \(\mu = \tfrac{1}{16}\) the approach is again the slowest, with the tenth maximum still at \(1.692056\); for \(\mu = \tfrac12\) the tenth maximum is within \(2.0 \times 10^{-12}\) of the cycle, and for \(\mu = 1\) and \(4\) the solution reaches the cycle to rounding level within \(0 \le t \le 60\), as from outside.

Verification of Examples 2 to 6

The table compares the Runge-Kutta solution (\(n = 6000\), \(h = 0.01\)) with the order-8 reference solution at all \(6001\) points. The last column is the ratio of the largest errors for \(n = 6000\) and \(n = 12000\); a ratio near \(16\) is the order \(h^4\) of the method. The ratios are measured against a sharper reference, Runge-Kutta itself with \(n = 192000\) and \(384000\) in \(256\)-bit arithmetic combined by Richardson extrapolation, because for \(\mu = \tfrac14\) the error at \(n = 12000\), \(1.3 \times 10^{-9}\), is only about \(120\) times the order-8 solver’s own error of \(1.1 \times 10^{-11}\).

Example \(\mu\) Runge-Kutta end point at \(t = 60\) reference end point largest error ratio
2 \(\tfrac{1}{16}\) \((-0.549830,\ -1.969337)\) \((-0.549830,\ -1.969337)\) \(1.1 \times 10^{-8}\) \(16.00\)
3 \(\tfrac14\) \((0.008656,\ -2.008874)\) \((0.008656,\ -2.008874)\) \(2.1 \times 10^{-8}\) \(15.98\)
4 \(\tfrac12\) \((1.237782,\ -1.228926)\) \((1.237782,\ -1.228926)\) \(6.1 \times 10^{-8}\) \(15.96\)
5 \(1\) \((-0.362932,\ 1.791347)\) \((-0.362932,\ 1.791347)\) \(4.1 \times 10^{-7}\) \(15.94\)
6 \(4\) \((-1.1428,\ 0.5101)\) \((-1.1428,\ 0.5101)\) \(2.0 \times 10^{-4}\) \(15.69\)

With the same step \(h = 0.01\) the largest error grows with \(\mu\), from \(1.1 \times 10^{-8}\) for \(\mu = \tfrac{1}{16}\) to \(2.0 \times 10^{-4}\) for \(\mu = 4\).

Implementation Notes

  • Step size. The fixed-step method spends the same effort on the slow and the fast parts of a relaxation oscillation. For large \(\mu\) an adaptive method such as the Runge-Kutta-Fehlberg method puts small steps only where the solution changes quickly.
  • Interval length. How long to integrate depends on \(\mu\): the gap to the cycle shrinks by the factor \(\rho\) per turn, which is \(0.675\) for \(\mu = \tfrac{1}{16}\) but \(8.6 \times 10^{-4}\) for \(\mu = 1\).
  • End of the interval. A right end written to a few decimals, such as \(6.283185\) for \(2\pi\), shifts the exact end point; compare a computed value with the exact solution at the same \(t\), as in Example 1.
  • Symmetry check. The system (2) is unchanged when \((x, y)\) is replaced by \((-x, -y)\), so the computed cycle should be symmetric about the origin; its largest and smallest \(x\) agree to all the digits computed (\(\pm 2.022963\) for \(\mu = 4\)).

References

Mathew, John H. 2000-2019. Numerical Analysis - Numerical Methods Modules. https://web.archive.org/web/20190808102217/http://mathfaculty.fullerton.edu/mathews/n2003/NumericalUndergradMod.html.