Skip to content
Specular Differentiation

Scalar ODE

This page reproduces the numerical experiments in the paper using specular.

The seven numerical figures are saved as EPS, PDF, and PNG under

examples/ode/figures/. The four manuscript tables and additional numerical

data are saved under examples/ode/tables/. The geometric diagram is

maintained separately.

SE2, SE3, and SE4 on this page

These labels refer to second-, third-, and fourth-order configurations of the specular ellipse method.

SE2 uses sigma_n=1. SE3 uses the left-endpoint cancelling scale when its

elliptic-malleability condition holds and scale 1 otherwise. Pure SE4

checks both endpoint conditions and A*C < 0 at each trial, using scale 1

otherwise. Prescribed vanishing scales are identified separately below.

This SE2 is ellipse_scheme(..., sigma_n=1), which equals euler_scheme_5; it is not euler_scheme_2.

The SE4 experiments explicitly use fourth_order=True. The separate

auto=True option prefers SE4 but allows the left-endpoint SE3 scale as its

fallback; it is not used in the paper's SE4 comparisons. See the

automatic scale-selection modes.

Each field callback receives the vector [t,u], and every solver uses the

prescribed constant h on t_n=t_0+n*h, with

N_h=floor((T-t_0)/h) and no shortened final step.

Install the development dependencies, then generate and check all outputs from the repository root:

pip install -e ".[dev]"

python examples/ode/generate_all.py

python examples/ode/check_reproduction.py

Each script can also be run separately, for example

python examples/ode/ellipse_exactness.py. The checker compares saved

references or analytical properties with newly calculated values; it does not

replace new results with historical values. Roundoff-level errors can differ

from older runs. See the

example README

for parameters, tolerances, reference provenance, and raw-data descriptions.

Each manuscript table has a readable <stem>.txt and a copyable

<stem>_latex.txt:

| Table | Output stem | Generator |

| --- | --- | --- |

| Choices of the two endpoint slopes | method_choices | method_choices.py |

| Ellipse maximum errors and ratios to machine epsilon | ellipse_exactness_errors | ellipse_exactness.py |

| Pendulum scales and cancellation residuals | pendulum_scale | pendulum_fourth_order.py |

| Tanh scales and errors at selected nodes | tanh_fallback_samples | tanh_fallback.py |

The order statements below are numerical observations for the stated problems.

The ODE guide summarizes the hypotheses required by the convergence results.

Exact tracing

For

[

u'=-\frac{b^2(t-p)}{a^2u},

\qquad

u(t)=b\sqrt{1-\left(\frac{t-p}{a}\right)^2},

]

the fitted scale is \(\sigma_n=b/a\).

The two panels use \(p=2.25\), \(h=0.3\), and \((a,b)=(2.26,2.26)\) or \((2.26,1.5)\).

The fitted SE trajectory reaches the exact ellipse at every mesh point, subject to the unique admissible implicit update assumed by the exactness result; CN does not.

Exact tracing on a circle and an ellipse

Python source

· PDF figure

Vanishing scales

For \(u'=u^{-1}\), \(u(0)=1\), on \([0,1]\), the script compares \(\sigma_n=1\) and \(\sigma_n=h^p\) with \(p\in\{1/2,1,2,3,4\}\), together with CN, RK3, RK4, and the fourth-order implicit two-point Hermite formula (IH4).

The higher orders visible for the vanishing scales follow a direct estimate for this particular equation; they are not general SE3 guarantees.

At the smallest errors, roundoff and nonlinear-solver tolerances become visible.

Maximum global errors for the inverse equation

Python source

· PDF figure

Optimal scales for a normalized pendulum branch

The normalized positive-velocity phase equation is

[

\frac{du}{d\xi}=-\frac{\sin(\theta\xi)}{\theta u},

\qquad 0\leq\xi\leq0.8.

]

The four panels compare SE2, the pointwise SE3 selector, the two-endpoint SE4 selector, RK4, and IH4 for \(\theta=1,0.25,0.1,0.01\).

This is a normalized phase equation, not the original time-domain pendulum.

The curves compare accuracy at the same step size, not at the same runtime or number of field evaluations.

SE3 and SE4 use scale 1 at the initial point. The scale table at h=.01

reports steps n=1,...,79, excluding that initial fallback. Residuals use the

accepted numerical endpoints and the scales recorded by the solver, without

recomputing a scale after acceptance.

Maximum global errors for normalized pendulum branches

Python source

· PDF figure

Defect cancellation for quadratic decay

For \(u'=-u^2\), \(u(0)=1\), the two panels plot the absolute pointwise defect used by SE3 and the absolute two-endpoint defect used by SE4.

The exact states at \(n=0,1,2\), with \(h=0.3\), are used so that the marked scales show the intended cancellation directly rather than accumulated global error.

Pointwise and two-endpoint defect cancellation

Python source

· PDF figure

Convergence for quadratic decay

For the same quadratic decay problem on \([0,1]\), the maximum global errors show the expected second-order behavior of CN and SE2, third-order behavior of SE3 and RK3, and fourth-order behavior of SE4, RK4, and IH4.

Unlike the pendulum illustration, this problem supplies a clean instance of the uniform branch assumptions used by the fourth-order convergence theorem.

Maximum global errors for quadratic decay

Python source

· PDF figure

SE3 fallback for the tanh solution

For \(u'=1-u^2\), \(u(0)=0\), the exact solution is \(u(t)=\tanh t\).

The two panels show the selected scales and absolute nodal errors on

\([0,2]\) for \(h=0.1,0.01,0.001\). SE3 uses scale 1 until its left-endpoint

condition permits the cancelling scale. The transition is near

\(t_\ast=\operatorname{arctanh}(1/\sqrt3)\); these runs exhibit second-order

global convergence because the number of fallback steps grows under refinement.

SE3 fallback scales and absolute errors for the tanh solution

Python source

· PDF figure

The sample table includes the nodes immediately before and after \(t_\ast\).

Dashes mark \(t_\ast\), which is not a mesh point. Its terminal scale at

\(t=2\) is evaluated only for that table; no extra integration step is taken.

The optional --compare flag adds a pure-SE4 comparison to the default SE3

outputs.

Diverging scales

For \(u'=1-u^2\), each \(h\) uses a separately selected exact endpoint pair from the large-scale boundary case.

The figure compares fixed scales \(\sigma_n=1,3,10\), the diverging scale \(\sigma_n=h^{-1}\), and CN.

It is a one-step experiment, not a global-convergence plot: the fixed scales exhibit third-order one-step error here, while \(h^{-1}\) and CN exhibit fifth-order one-step error.

One-step errors for fixed and diverging scales

Python source

· PDF figure