"SymplecticPartitionedRungeKutta" Method for NDSolve

Introduction

When numerically solving Hamiltonian dynamical systems it is advantageous if the numerical method yields a symplectic map.

If the Hamiltonian can be written in separable form, H(p,q)==T(p)+V(q), there exists an efficient class of explicit symplectic numerical integration methods.

An important property of symplectic numerical methods when applied to Hamiltonian systems is that a nearby Hamiltonian is approximately conserved for exponentially long times (see [BG94], [HL97], and [R99]).

Hamiltonian Systems

Consider a differential equation

(dy/dt)==F(t,y),y((Subscript[t, 0]))==(Subscript[y, 0]).

A d-degree of freedom Hamiltonian system is a particular instance of () with y==((((Subscript[p, 1]),…,(Subscript[p, d]),(Subscript[q, 1])…,(Subscript[q, d])))^T), where

(dy/dt)==(J^(-1))∇ H.

Here ∇ represents the gradient operator:

and J is the skew symmetric matrix:

where I and 0 are the identity and zero d×d matrices.

The components of q are often referred to as position or coordinate variables and the components of p as the momenta.

If H is autonomous, dH/dt==0. Then H is a conserved quantity that remains constant along solutions of the system. In applications, this usually corresponds to conservation of energy.

A numerical method applied to a Hamiltonian system () is said to be symplectic if it produces a symplectic map. That is, let ((SuperStar[p]),(SuperStar[q]))==ψ(p,q) be a (C^1) transformation defined in a domain Ω.:

where the Jacobian of the transformation is:

The flow of a Hamiltonian system is depicted together with the projection onto the planes formed by canonically conjugate coordinate and momenta pairs. The sum of the oriented areas remains constant as the flow evolves in time.

Partitioned Runge–Kutta Methods

It is sometimes possible to integrate certain components of () using one Runge–Kutta method and other components using a different Runge–Kutta method. The overall s-stage scheme is called a partitioned Runge–Kutta method and the free parameters are represented by two Butcher tableaux:

({{ , (Subscript[a, 11]), ⋯, (Subscript[a, 1s])}, { , ⋮, ⋱, ⋮}, { , (Subscript[a, s1]), ⋯, (Subscript[a, ss])}, { , (Subscript[b, 1]), ⋯, (Subscript[b, s])}})      ({{ , (Subscript[A, 11]), ⋯, (Subscript[A, 1s])}, { , ⋮, ⋱, ⋮}, { , (Subscript[A, s1]), ⋯, (Subscript[A, ss])}, { , (Subscript[B, 1]), ⋯, (Subscript[B, s])}}).

Symplectic Partitioned Runge–Kutta (SPRK) Methods

For general Hamiltonian systems, symplectic Runge–Kutta methods are necessarily implicit.

However, for separable Hamiltonians H(p,q,t)==T(p)+V(q,t) there exist explicit schemes corresponding to symplectic partitioned Runge–Kutta methods.

Instead of () the free parameters now take either the form:

({{ , 0, ⋯, 0, 0}, { , (Subscript[b, 1]), 0, ⋯, ⋮}, { , ⋮, ⋱, ⋱, ⋮}, { , (Subscript[b, 1]), ⋯, (Subscript[b, s-1]), 0}, { , (Subscript[b, 1]), ⋯, (Subscript[b, s-1]), (Subscript[b, s])}})        ({{ , (Subscript[B, 1]), ⋯, 0, 0}, { , (Subscript[B, 1]), (Subscript[B, 2]), ⋯, ⋮}, { , ⋮, ⋮, ⋱, ⋮}, { , (Subscript[B, 1]), (Subscript[B, 2]), ⋯, (Subscript[B, s])}, { , (Subscript[B, 1]), (Subscript[B, 2]), ⋯, (Subscript[B, s])}})

or the form:

({{ , (Subscript[b, 1]), ⋯, 0, 0}, { , (Subscript[b, 1]), (Subscript[b, 2]), ⋯, ⋮}, { , ⋮, ⋮, ⋱, ⋮}, { , (Subscript[b, 1]), (Subscript[b, 2]), ⋯, (Subscript[b, s])}, { , (Subscript[b, 1]), (Subscript[b, 2]), ⋯, (Subscript[b, s])}})       ({{ , 0, ⋯, 0, 0}, { , (Subscript[B, 1]), 0, ⋯, ⋮}, { , ⋮, ⋱, ⋱, ⋮}, { , (Subscript[B, 1]), ⋯, (Subscript[B, s-1]), 0}, { , (Subscript[B, 1]), ⋯, (Subscript[B, s-1]), (Subscript[B, s])}}).

The 2d free parameters of () are sometimes represented using the shorthand notation [(Subscript[b, 1]),…,(Subscript[b, s])]((Subscript[B, 1]),…,(Subscript[B, s])).

The differential system for a separable Hamiltonian system can be written as:

In general the force evaluations -∂V(q,t)/∂q are computationally dominant and () is preferred over () since it is possible to save one force evaluation per time step when dense output is required.

Standard Algorithm

The structure of () permits a particularly simple implementation (see for example [SC94]).

Algorithm 1 (Standard SPRK)

The time-weights are given by: (Subscript[C, j])==(∑_(i=1)^(j-1))(Subscript[B, i]),j==1,…,s.

If (Subscript[B, s])==0 then Algorithm 1 effectively reduces to an s-1 stage scheme since it has the First Same As Last (FSAL) property.

Example

This loads some useful packages:

Needs["DifferentialEquations`NDSolveProblems`"];
Needs["DifferentialEquations`NDSolveUtilities`"];

The Harmonic Oscillator

The Harmonic oscillator is a simple Hamiltonian problem that models a material point attached to a spring. For simplicity consider the unit mass and spring constant for which the Hamiltonian is given in separable form:

The equations of motion are given by:

(dp/dt)==-((∂H)/(∂q))==-q,    (dq/dt)==((∂H)/(∂p))==p,    q(0)==1,    p(0)==0.

Input

system = GetNDSolveProblem["HarmonicOscillator"];
eqs = {system["System"],system["InitialConditions"]};
vars = system["DependentVariables"];
H = system["Invariants"];
time = {T, 0, 100};
step = 1/25;

Explicit Euler Method

Numerically integrate the equations of motion for the Harmonic oscillator using the explicit Euler method:

solee = NDSolve[eqs,vars,time, Method->"ExplicitEuler", StartingStepSize->step,MaxSteps->Infinity];

Since the method is dissipative, the trajectory spirals into or away from the fixed point at the origin:

ParametricPlot[Evaluate[vars /. First[solee]],Evaluate[time],PlotPoints->100]

A dissipative method typically exhibits linear error growth in the value of the Hamiltonian:

InvariantErrorPlot[H, vars, T, solee, PlotStyle->Green]

Symplectic Method

Numerically integrate the equations of motion for the Harmonic oscillator using a symplectic partitioned Runge–Kutta method:

sol = NDSolve[eqs,vars,time, Method->{"SymplecticPartitionedRungeKutta", "DifferenceOrder"->2, "PositionVariables"->{(Subscript[Y, 1])[T]}}, StartingStepSize->step, MaxSteps->Infinity];

The solution is now a closed curve:

ParametricPlot[Evaluate[vars /. First[sol]],Evaluate[time]]

In contrast to dissipative methods, symplectic integrators yield an error in the Hamiltonian that remains bounded:

InvariantErrorPlot[H, vars,T, sol, PlotStyle->Blue]

Rounding Error Reduction

In certain cases, lattice symplectic methods exist and can avoid step-by-step roundoff accumulation, but such an approach is not always possible [ET92].

Consider the previous example where the combination of step size and order of the method is now chosen such that the error in the Hamiltonian is around the order of unit roundoff in IEEE double-precision arithmetic:

solnoca = NDSolve[eqs,vars,time, Method->{"SymplecticPartitionedRungeKutta", "DifferenceOrder"->10, "PositionVariables"->{(Subscript[Y, 1])[T]}}, StartingStepSize->step, MaxSteps->Infinity,"CompensatedSummation"->False];

InvariantErrorPlot[H, vars,T, solnoca, PlotStyle->Blue]

There is a curious drift in the error in the Hamiltonian that is actually a numerical artifact of floating-point arithmetic.

This phenomenon can have an impact on long time integrations.

This section describes the formulation used by "SymplecticPartitionedRungeKutta" in order to reduce the effect of such errors.

There are two types of errors in integrating a flow numerically, those along the flow and those transverse to the flow. In contrast to dissipative systems, the rounding errors in Hamiltonian systems that are transverse to the flow are not damped asymptotically.

Many numerical methods for ordinary differential equations involve computations of the form

where the increments (Subscript[δ, n]) are usually smaller in magnitude than the approximations (Subscript[y, n]).

Let e(x) denote the exponent and m(x), 1>m(x)≥1/β, the mantissa of a number x in precision p radix β arithmetic: x==m(x)×(β^(e(x))).

Then you can write:

and

Aligning according to exponents these quantities can be represented pictorially as

where numbers on the left have a smaller scale than numbers on the right.

Of interest is an efficient way of computing the quantities (Subscript[δ, n]^l) that effectively represent the radix β digits discarded due to the difference in the exponents of (Subscript[y, n]) and (Subscript[δ, n]).

Compensated Summation

The basic motivation for compensated summation is to simulate 2n bit addition using only n bit arithmetic.

Example

This repeatedly adds a fixed amount to a starting value. Cumulative roundoff error has a significant influence on the result:

reps = (10^6);
base = 0.;
inc = 0.1;
Do[base = base + inc,{reps}];
InputForm[base]

In many applications the increment may vary and the number of operations is not known in advance.

Algorithm

Compensated summation (see for example [B87] and [H96]) computes the rounding error along with the sum so that

is replaced by:

Algorithm 2 (Compensated Summation)

The algorithm is carried out component-wise for vectors.

Example

The function CompensatedPlus (in the Developer` context) implements the algorithm for compensated summation.

By repeatedly feeding back the rounding error from one sum into the next, the effect of rounding errors is significantly reduced:

err = 0.;
base = 0.;
inc = 0.1;
Do[
{base,err} = 
Developer`CompensatedPlus[base ,inc,err],
{reps}];
InputForm[base]

An undocumented option CompensatedSummation controls whether built-in integration methods in (RefLink[NDSolve, paclet:ref/NDSolve]) use compensated summation.

An Alternative Algorithm

There are various ways that compensated summation can be used.

One way is to compute the error in every addition update in the main loop in Algorithm 1.

An alternative algorithm, which was proposed because of its more general applicability, together with reduced arithmetic cost, is given next. The essential ingredients are the increments Δ (Subscript[P, i])==(Subscript[P, i])-(Subscript[p, n]) and Δ (Subscript[Q, i])==(Subscript[Q, i])-(Subscript[q, n]).

Algorithm 3 (Increment SPRK)

The desired values (Subscript[p, n+1])==(Subscript[p, n])+Δ(Subscript[p, n+1]) and (Subscript[q, n+1])==(Subscript[q, n])+Δ (Subscript[q, n+1]) are obtained using compensated summation.

Compensated summation could also be used in every addition update in the main loop of Algorithm 3, but our experiments have shown that this adds a non-negligible overhead for a relatively small gain in accuracy.

Numerical Illustration

Rounding Error Model

The amount of expected roundoff error in the relative error of the Hamiltonian for the harmonic oscillator () will now be quantified. A probabilistic average case analysis is considered in preference to a worst case upper bound.

For a one-dimensional random walk with equal probability of a deviation, the expected absolute distance after N steps is O((Sqrt[n])).

The relative error for a floating-point operation +, -, *, / using IEEE round to nearest mode satisfies the following bound [K93]:

where the base β==2 is used for representing floating-point numbers on the machine and p==53 for IEEE double-precision.

Therefore the roundoff error after n steps is expected to be approximately

for some constant k.

In the examples that follow a constant step size of 1/25 is used and the integration is performed over the interval [0, 80000] for a total of 2×(10^6) integration steps. The error in the Hamiltonian is sampled every 200 integration steps.

The 8(^th)-order 15-stage (FSAL) method D of Yoshida is used. Similar results have been obtained for the 6(^th)-order 7-stage (FSAL) method A of Yoshida with the same number of integration steps and a step size of 1/160.

Without Compensated Summation

The relative error in the Hamiltonian is displayed here for the standard formulation in Algorithm 1 (green) and for the increment formulation in Algorithm 3 (red) for the Harmonic oscillator ().

Algorithm 1 for a 15-stage method corresponds to n==15×2×(10^6)==3×(10^7).

In the incremental Algorithm 3 the internal stages are all of the order of the step size and the only significant rounding error occurs at the end of each integration step; thus n==2×(10^6), which is in good agreement with the observed improvement.

This shows that for Algorithm 3, with sufficiently small step sizes, the rounding error growth is independent of the number of stages of the method, which is particularly advantageous for high order.

With Compensated Summation

The relative error in the Hamiltonian is displayed here for the increment formulation in Algorithm 3 without compensated summation (red) and with compensated summation (blue) for the Harmonic oscillator ().

Using compensated summation with Algorithm 3, the error growth appears to satisfy a random walk with deviation h ϵ so that it has been reduced by a factor proportional to the step size.

Arbitrary Precision

The relative error in the Hamiltonian is displayed here for the increment formulation in Algorithm 3 with compensated summation using IEEE double-precision arithmetic (blue) and with 32-decimal-digit software arithmetic (purple) for the Harmonic oscillator ().

However, the solution obtained using software arithmetic is around an order of magnitude slower than machine arithmetic, so strategies to reduce the effect of roundoff error are worthwhile.

Examples

Electrostatic Wave

Here is a non-autonomous Hamiltonian (it has a time-dependent potential) that models n perturbing electrostatic waves, each with the same wave number and amplitude, but different temporal frequencies (Subscript[ω, i]) (see [CR91]).

H(p,q)==((p^2)/2)+((q^2)/2)+ϵ(∑_(i=1)^n)(cos(q-(Subscript[ω, i])))

This defines a differential system from the Hamiltonian () for dimension n==3 with frequencies (Subscript[ω, 1])==7, (Subscript[ω, 2])==14, (Subscript[ω, 3])==21:

H = p[t]^2/2 + q[t]^2/2 + Sum[Cos[q[t] - 7 i t],{i, 3}];
eqs = {p'[t] ==-D[H, q[t]], q'[t]==D[H, p[t]]};
ics = {p[0]==0, q[0]==4483/400};
vars = {q[t], p[t]};
time = {t, 0, 10000 2 π};
step = 2 π/105;

A general technique for computing Poincaré sections is described within "Events and Discontinuities in Differential Equations". Specifying an empty list for the variables avoids storing all the data of the numerical integration.

The integration is carried out with a symplectic method with a relatively large number of steps, and the solutions are collected using (RefLink[Sow, paclet:ref/Sow]) and (RefLink[Reap, paclet:ref/Reap]) when the time is a multiple of 2π:

sprkmethod = {"SymplecticPartitionedRungeKutta", "DifferenceOrder"->4,"PositionVariables"->{q[t]}};

sprkdata=
Block[{k = 1},
Reap[
NDSolve[{eqs,ics, WhenEvent[Mod[t,2 Pi]==0,Sow[{q[t],p[t]}]]},{},time,Method->sprkmethod,StartingStepSize->step,MaxSteps->Infinity
];
]
];

This displays the solution at time intervals of 2π:

ListPlot[sprkdata[[-1,1]],Axes->False,Frame->True,AspectRatio->1,PlotRange->All]

For comparison a Poincaré section is also computed using an explicit Runge–Kutta method of the same order:

rkmethod={"FixedStep",Method->{"ExplicitRungeKutta","DifferenceOrder"->4}};

rkdata=
Block[{k = 1},
Reap[
NDSolve[{eqs,ics,WhenEvent[Mod[t,2 Pi]==0,Sow[{q[t],p[t]}]]},{},time,Method->rkmethod,StartingStepSize->step,MaxSteps->Infinity
];
]
];

Fine structural details are clearly resolved in a less satisfactory way with this method:

ListPlot[rkdata[[-1,1]],Axes->False,Frame->True,AspectRatio->1,PlotRange->All]

Toda Lattice

The Toda lattice models particles on a line interacting with pairwise exponential forces and is governed by the Hamiltonian:

Consider the case when periodic boundary conditions (Subscript[q, n+1])==(Subscript[q, 1]) are enforced.

The Toda lattice is an example of an isospectral flow. Using the notation

then the eigenvalues of the following matrix are conserved quantities of the flow:

Define the input for the Toda lattice problem for n==3:

n = 3;

periodicRule =  {(Subscript[q, n+1])[t]->(Subscript[q, 1])[t]};

H =(∑_(k=1)^n)(((((Subscript[p, k])[t])^2)/2)+(Exp[(Subscript[q, k+1])[t]-(Subscript[q, k])[t]]-1)) /.periodicRule;

eigenvalueRule = {(Subscript[a, k_])[t]:>-(Subscript[p, k])[t]/2,(Subscript[b, k_])[t]:>1/2Exp[1/2((Subscript[q, k+1])[t]-(Subscript[q, k])[t])]};

L = (({{(Subscript[a, 1])[t], (Subscript[b, 1])[t], (Subscript[b, 3])[t]}, {(Subscript[b, 1])[t], (Subscript[a, 2])[t], (Subscript[b, 2])[t]}, {(Subscript[b, 3])[t], (Subscript[b, 2])[t], (Subscript[a, 3])[t]}}))/. eigenvalueRule/.periodicRule;

eqs = {(Subscript[q, 1])'[t]==D[H,(Subscript[p, 1])[t]],(Subscript[q, 2])'[t]==D[H,(Subscript[p, 2])[t]],(Subscript[q, 3])'[t]==D[H,(Subscript[p, 3])[t]],(Subscript[p, 1])'[t]==-D[H,(Subscript[q, 1])[t]],(Subscript[p, 2])'[t]==-D[H,(Subscript[q, 2])[t]],(Subscript[p, 3])'[t]==-D[H,(Subscript[q, 3])[t]]};
ics = {(Subscript[q, 1])[0]==1,(Subscript[q, 2])[0]==2,(Subscript[q, 3])[0]==4,(Subscript[p, 1])[0]==0,(Subscript[p, 2])[0]==1,(Subscript[p, 3])[0]==1/2};
eqs = {eqs,ics};
vars = {(Subscript[q, 1])[t],(Subscript[q, 2])[t],(Subscript[q, 3])[t],(Subscript[p, 1])[t],(Subscript[p, 2])[t],(Subscript[p, 3])[t]};
time = {t, 0, 50};

Define a function to compute the eigenvalues of a matrix of numbers, sorted in increasing order. This avoids computing the eigenvalues symbolically:

NumberMatrixQ[m_]:=MatrixQ[m, NumberQ];
NumberEigenvalues[m_?NumberMatrixQ]:= Sort[Eigenvalues[m]];

Integrate the equations for the Toda lattice using the "ExplicitMidpoint" method:

emsol = NDSolve[eqs,vars,time,Method->"ExplicitMidpoint",StartingStepSize->1/10];

The absolute error in the eigenvalues is now plotted throughout the integration interval.

Options are used to specify the dimension of the result of NumberEigenvalues (since it is not an explicit list) and that the absolute error specified using InvariantErrorFunction should include the sign of the error (the default uses (RefLink[Abs, paclet:ref/Abs])).

The eigenvalues are clearly not conserved by the "ExplicitMidpoint" method:

InvariantErrorPlot[NumberEigenvalues[L],vars,t,emsol,InvariantErrorFunction->(#1-#2&),
InvariantDimensions->{n}, PlotStyle->{Red,Blue,Green}]

Integrate the equations for the Toda lattice using the "SymplecticPartitionedRungeKutta" method:

sprksol = NDSolve[eqs,vars,time,Method->{"SymplecticPartitionedRungeKutta", DifferenceOrder->2,"PositionVariables"->{(Subscript[q, 1])[t],(Subscript[q, 2])[t],(Subscript[q, 3])[t]}},StartingStepSize->1/10];

The error in the eigenvalues now remains bounded throughout the integration:

InvariantErrorPlot[NumberEigenvalues[L],vars,t,sprksol,InvariantErrorFunction->(#1-#2&),
InvariantDimensions->{n}, PlotStyle->{Red,Blue,Green}]

Some recent work on numerical methods for isospectral flows can be found in [CIZ97], [CIZ99], [DLP98a], and [DLP98b].

Available Methods

Default Methods

The following table lists the current default choice of SPRK methods.

({{Order, f evaluations, Method, Symmetric, FSAL}, {1, 1, Symplectic Euler, No, No}, {2, 1, Symplectic pseudo Leapfrog, Yes, Yes}, {3, 3, McLachlan and Atela [MA92], No, No}, {4, 5, Suzuki [S90], Yes, Yes}, {6, 11, Sofroniou and Spaletta [SS05], Yes, Yes}, {8, 19, Sofroniou and Spaletta [SS05], Yes, Yes}, {10, 35, Sofroniou and Spaletta [SS05], Yes, Yes}})

Unlike the situation for explicit Runge–Kutta methods, the coefficients for high-order SPRK methods are only given numerically in the literature. Yoshida [Y90] only gives coefficients accurate to 14 decimal digits of accuracy for example.

Since (RefLink[NDSolve, paclet:ref/NDSolve]) also works for arbitrary precision, you need a process for obtaining the coefficients to the same precision as that to be used in the solver.

When the closed form of the coefficients is not available, the order equations for the symmetric composition coefficients can be refined in arbitrary precision using (RefLink[FindRoot, paclet:ref/FindRoot]), starting from the known machine-precision solution.

Alternative Methods

Due to the modular design of the new (RefLink[NDSolve, paclet:ref/NDSolve]) framework it is straightforward to add an alternative method and use that instead of one of the default methods.

Several checks are made before any integration is carried out:

Example

Select the perturbed Kepler problem:

system = GetNDSolveProblem["PerturbedKepler"];
time = {T, 0, 290};
step = 1/25;

Define a function for computing a numerical approximation to the coefficients for a fourth-order method of Forest and Ruth [FR90], Candy and Rozmus [CR91], and Yoshida [Y90]:

YoshidaCoefficients[4,prec_]:=
N[
{{Root[-1+12*#1-48*#1^2+48*#1^3&,1,0],Root[1-24*#1^2+48*#1^3&,1,0],Root[1-24*#1^2+48*#1^3&,1,0],Root[-1+12*#1-48*#1^2+48*#1^3&,1,0]},{Root[-1+6*#1-12*#1^2+6*#1^3&,1,0],Root[1-3*#1+3*#1^2+3*#1^3&,1,0],Root[-1+6*#1-12*#1^2+6*#1^3&,1,0],0}},
prec];

Here are machine-precision approximations for the coefficients:

YoshidaCoefficients[4,MachinePrecision]

This invokes the symplectic partitioned Runge–Kutta solver using Yoshida's coefficients:

Yoshida4 = {"SymplecticPartitionedRungeKutta","Coefficients"->YoshidaCoefficients,"DifferenceOrder"->4,"PositionVariables"->{(Subscript[Y, 1])[T],(Subscript[Y, 2])[T]}};

Yoshida4sol = NDSolve[system, time,Method->Yoshida4, StartingStepSize->step,MaxSteps->Infinity];

This plots the solution of the position variables, or coordinates, in the Hamiltonian formulation:

ParametricPlot[Evaluate[{(Subscript[Y, 1])[T],(Subscript[Y, 2])[T]} /. Yoshida4sol],Evaluate[time]]

Automatic Order Selection

Given that a variety of methods of different orders are available, it is useful to have a means of automatically selecting an appropriate method. In order to accomplish this we need a measure of work for each method.

A reasonable measure of work for an SPRK method is the number of stages s (or s-1 if the method is FSAL).

Definition (Work per unit step)

Given a step size (Subscript[h, k]) and a work estimate (Subscript[𝒜, k]) for one integration step with a method of order k, the work per unit step is given by (Subscript[𝒲, k])==(Subscript[𝒜, k])/(Subscript[h, k]).

Let Π be a nonempty set of method orders, (Subscript[Π, k]) denote the k(^th) element of Π, and |Π| denote the cardinality (number of elements).

A comparison of work for the default SPRK methods gives Π=={2,3,4,6,8,10}.

A prerequisite is a procedure for estimating the starting step (Subscript[h, k]) of a numerical method of order k (see for example [GSB87] or [HNW93]).

The first case to be considered is when the starting step estimate h can be freely chosen. By bootstrapping from low order, the following algorithm finds the order that locally minimizes the work per unit step.

Algorithm 4 (h free)

The second case to be considered is when the starting step estimate h is given. The following algorithm then gives the order of the method that minimizes the computational cost while satisfying given absolute and relative local error tolerances.

Algorithm 5 (h specified)

Algorithms 4 and 5 are heuristic since the optimal step size and order may change through the integration, although symplectic integration often involves fixed choices. Despite this, both algorithms incorporate salient integration information, such as local error tolerances, system dimension, and initial conditions, to avoid poor choices.

Examples

Consider Kepler's problem that describes the motion in the configuration plane of a material point that is attracted toward the origin with a force inversely proportional to the square of the distance:

H(p,q)==(1/2)(((Subscript[p, 1])^2)+((Subscript[p, 2])^2))-(1/(Sqrt[((Subscript[q, 1])^2)+((Subscript[q, 2])^2)])).

For initial conditions take

with eccentricity e==3/5.

Algorithm 4

The following figure shows the methods chosen automatically at various tolerances for the Kepler problem () according to Algorithm 4 on a log-log scale of maximum absolute phase error versus work.

It can be observed that the algorithm does a reasonable job of staying near the optimal method, although it switches over to the 8(^th)-order method slightly earlier than necessary.

This can be explained by the fact that the starting step size routine is based on low-order derivative estimation and this may not be ideal for selecting high-order methods.

Algorithm 5

The following figure shows the methods chosen automatically with absolute local error tolerance of (10^(-9)) and step sizes 1/16, 1/32, 1/64, 1/128 for the Kepler problem () according to Algorithm 5 on a log-log scale of maximum absolute phase error versus work.

With the local tolerance and step size fixed the code can only choose the order of the method.

For large step sizes a high-order method is selected, whereas for small step sizes a low-order method is selected. In each case the method chosen minimizes the work to achieve the given tolerance.

Option Summary

Options of the method "SymplecticPartitionedRungeKutta".