Second-order systems
A second-order system
nystrom_stepper (selah_nystrom) runs it with the stepper's stage contract: you evaluate the force at stage_state() into rhs_register() for each stage; finish_step(bx, h, q, p) updates both. The catalogue, NYSTROM_SCHEMES (each nystrom(name) a nystrom_tableau):
| Scheme | Stages | Order | Embedded | Source |
|---|---|---|---|---|
rkn-4 | 3 | 4 | — | Nyström (1925), as Hairer, Nørsett & Wanner I, II.14 |
rkn-64 | 6 | 6 | 4 | Dormand, El-Mikkawy & Prince, RKN6(4)6FM (1987) |
rkn-1210 | 17 | 12 | 10 | Dormand, El-Mikkawy & Prince, RKN12(10)17M (1987) |
notes/nystrom-check.py checks every order condition of each, tree by tree in 60 digits: rkn-4 11 conditions and rkn-64 36 + 11 exactly, rkn-1210 1667 + 439 to notes/methods/rkn/: the coefficients and their sources). step_error estimates the embedded pair's error of
Kepler's orbit
One period of an orbit of eccentricity 1/2, each scheme at 50 and 100 steps, and butcher-6 on the first-order system
real(R_P), parameter :: E = 0.5_R_P, T = 2._R_P * acos(-1._R_P)
type(nystrom_stepper) :: ns
type(nystrom_tableau) :: nt
type(box) :: bx
real(R_P), allocatable, target :: q(:,:,:,:,:), p(:,:,:,:,:)
real(R_P), pointer :: y(:,:,:,:,:), f(:,:,:,:,:)
real(R_P) :: h, err
integer(I4P) :: s, n, istep, k
bx = box_interior(LAYOUT_V_FIRST, 2_I4P, 1_I4P, 1_I4P, 1_I4P, 0_I4P, 1_I4P) ! (x, y) on one cell
allocate(q(2,1,1,1,1), p(2,1,1,1,1))
print '(A)', ' scheme stages order steps error after a period evaluations'
do s=1, size(NYSTROM_SCHEMES)
nt = nystrom(trim(NYSTROM_SCHEMES(s)))
call ns%initialize(trim(NYSTROM_SCHEMES(s)), lb=bx%lb, ub=bx%hi)
do n=50, 100, 50
q(:,1,1,1,1) = [1._R_P - E, 0._R_P] ; p(:,1,1,1,1) = [0._R_P, sqrt((1._R_P + E) / (1._R_P - E))]
h = T / n
do istep=1, n
call ns%begin_step
do k=1, ns%stages()
call ns%begin_stage(k, bx, h, q, p) ! Y_k = q + c_k h p + h^2 sum abar_kj F_j
y => ns%stage_state() ; f => ns%rhs_register()
f(:,1,1,1,1) = -y(:,1,1,1,1) / norm2(y(:,1,1,1,1))**3
call ns%end_stage(k)
enddo
call ns%finish_step(bx, h, q, p) ! q and p together
enddo
err = max(maxval(abs(q(:,1,1,1,1) - [1._R_P - E, 0._R_P])), &
maxval(abs(p(:,1,1,1,1) - [0._R_P, sqrt((1._R_P + E) / (1._R_P - E))])))
call print_row(trim(NYSTROM_SCHEMES(s)), nt%s, nt%order, n, err)
enddo
call ns%destroy
enddo
do n=50, 100, 50
call print_row('butcher-6', 7_I4P, 6_I4P, n, first_order_kepler(n))
enddo$ cookbook_second_order kepler
scheme stages order steps error after a period evaluations
rkn-4 3 4 50 2.62E-02 150
rkn-4 3 4 100 1.34E-03 300
rkn-64 6 6 50 1.11E-05 300
rkn-64 6 6 100 2.31E-07 600
rkn-1210 17 12 50 below 1e-12 850
rkn-1210 17 12 100 below 1e-12 1700
butcher-6 7 6 50 1.30E-03 350
butcher-6 7 6 100 1.92E-05 700rkn-64 is 80 to 120 times more accurate than butcher-6 at the same order with one stage less: its stages integrate the force twice. selah_test_nystrom: at an error of rkn-4 takes 1703 force evaluations against rk4's 2147, rkn-64 462 against butcher-6's 1138.
The wave equation
real(R_P) :: w
integer(I4P) :: n
w = 2._R_P / DX * sin(PI2 / 2._R_P * DX)
print '(A)', ' form steps evaluations error to t = 1'
do n=32, 96, 16
call wave_row(' Nystrom rkn-64 ', n, 6 * n, wave_nystrom(n, w))
enddo
do n=32, 96, 16
call wave_row(' first order b6 ', n, 7 * n, wave_first_order(n, w))
enddo$ cookbook_second_order wave
form steps evaluations error to t = 1
Nystrom rkn-64 32 192 4.25E-10
Nystrom rkn-64 48 288 3.73E-11
Nystrom rkn-64 64 384 6.64E-12
Nystrom rkn-64 80 480 1.74E-12
Nystrom rkn-64 96 576 below 1e-12
first order b6 32 224 unstable
first order b6 48 336 1.64E-08
first order b6 64 448 2.90E-09
first order b6 80 560 7.56E-10
first order b6 96 672 2.53E-10The Nyström form is stable at 32 steps (butcher-6 on the first-order form is not; both converge at order 6, and the Nyström form reaches

The two recipes above as curves: at the same error, the Nyström form makes fewer force evaluations, on the orbit and on the wave equation (rkn-1210 is below
Störmer and Cowell
A multistep scheme for the same systems spends one force evaluation a step: stormer_stepper runs stormer-<k> (explicit) and cowell-<k> (implicit), STORMER_MAX_STEPS (16), at a constant step, from a history you write (Schemes: the Nyström form); stormer_weights gives a scheme's weights and order. The same wave, from the exact history, Cowell's with 3 stages (the force at
character(9), parameter :: NAMES(6) = [character(9) :: 'stormer-2', 'stormer-4', 'stormer-8', &
'cowell-2', 'cowell-4', 'cowell-8']
real(R_P), allocatable :: wt(:)
real(R_P) :: w
integer(I4P) :: s, n, order
w = 2._R_P / DX * sin(PI2 / 2._R_P * DX)
print '(A,I3)', ' k-step schemes available: k = 1 ..', STORMER_MAX_STEPS
print '(A)', ' scheme order steps evaluations error to t = 1'
do s=1, size(NAMES)
call stormer_weights(trim(NAMES(s)), wt, order) ! the weights and the order
do n=64, 256, 64
call stormer_row(NAMES(s), order, n, wave_stormer(trim(NAMES(s)), n, w))
enddo
enddo$ cookbook_second_order stormer
k-step schemes available: k = 1 .. 16
scheme order steps evaluations error to t = 1
stormer-2 2 64 64 1.97E-03
stormer-2 2 128 128 4.87E-04
stormer-2 2 192 192 2.16E-04
stormer-2 2 256 256 1.21E-04
stormer-4 4 64 64 unstable
stormer-4 4 128 128 1.14E-06
stormer-4 4 192 192 2.22E-07
stormer-4 4 256 256 7.00E-08
stormer-8 8 64 64 unstable
stormer-8 8 128 128 unstable
stormer-8 8 192 192 unstable
stormer-8 8 256 256 4.84E-11
cowell-2 4 64 192 9.54E-07
cowell-2 4 128 384 5.88E-08
cowell-2 4 192 576 1.16E-08
cowell-2 4 256 768 3.65E-09
cowell-4 5 64 192 1.05E-07
cowell-4 5 128 384 3.27E-09
cowell-4 5 192 576 4.31E-10
cowell-4 5 256 768 1.02E-10
cowell-8 9 64 192 unstable
cowell-8 9 128 384 2.51E-10
cowell-8 9 192 576 3.30E-11
cowell-8 9 256 768 7.84E-12Per evaluation, the explicit schemes are the cheapest at a step their stability allows, and that interval shrinks as stormer-8 needs 256 steps on this grid (rkn-64's cowell-8 from 128) and pay for it in the fixed-point stages. selah_test_nystrom checks each scheme against polynomials of degree order + 1 (exact) and the next (not), and its observed order on the oscillator.