Repository navigation
Description
Hi, thanks for maintaining qmat. While checking Butcher tables against the classical order conditions
(rooted trees up to order 6), three order / orderEmbedded values in qmat/qcoeff/butcher.py came out
one higher than the tables satisfy:
| Class | Label | Highest order whose conditions all hold | Largest residual at the next order |
|---|---|---|---|
RK32 |
order = 3 |
2 | 0.17 (order 3) |
ARK343ERK |
order = 4 |
3 | 0.073 (order 4) |
ARK548L2SAESDIRK, embedded weights |
orderEmbedded = 5 |
4 | 1.3e-4 (order 5) |
Order studies on y' = y cos(t) and y' = t - y^2 agree: RK32 converges at 1.99, ARK343ERK at 3.00.
RK32: the docstring says order 2, and the TODO about the Dahlquist order 3 is consistent with that, since on y' = λy some conditions coincide. For nonlinear or non-autonomous problems the order is 2.ARK343ERK: this is the explicit part of the ARS(4,4,3) scheme from Ascher, Ruuth & Spiteri (1997), which is third order. The docstring says "4rd-order". (Its coefficients are written with 10 digits, so the order-3 conditions hold to about 2e-10, which is harmless.)ARK548L2SAESDIRK: the comment says both schemes seem to be order 5, but the embedded weights satisfy the order-5 conditions only to 1.3e-4. With such a small residual, an order study looks fifth order until the errors are around 1e-11, which may be where the observation came from. So the original 5(4) claim seems right, andorderEmbedded = 4would match it. Since adaptive step control uses the embedded order, this value also affects the chosen step sizes slightly.
Snippet:
import numpy as np
from qmat.qcoeff import Q_GENERATORS
from physverify.butcher import check_tableau # pip install git+https://github.com/rcgiri-physics/physverify (butcher is newer than the 0.1.0 release on PyPI)
for name, emb in [("RK32", False), ("ARK343ERK", False), ("ARK548L2SAESDIRK", True)]:
g = Q_GENERATORS[name]()
b = g.weightsEmbedded if emb else g.weights
p = g.orderEmbedded if emb else g.order
print(name, check_tableau(np.asarray(g.Q), np.asarray(b), np.asarray(g.nodes), claimed=p).message)All the other tables I checked (38 generators, plus Gauss, Radau and Lobatto collocation with 2 to 4 nodes) have the order they state.
I found this while testing physverify, a small verification tool I'm working on, against public codes. The tests and this write-up were done with help from an AI assistant; the numbers come from actually running the code. Apologies if I have misread how order is meant to be used.
Activity
tlunet commentedon Oct 20, 2026
Hi @rcgiri-physics, thanks for looking into it. Seems like a discrepancy for those schemes between the order on general ODEs (non-autonomous, maybe non-linear) and linear autonomous ODEs (like Dahlquist). Do you know if this was already documented in the literature ? I didn't took the time to look into that yet ...
In
qmat, the order convergence tests are done to systematically check every scheme's implementation against an ODE solved numerically, and the Dahlquist tests are a convenient and efficient way for that, although it uses the (wrong) hypothesis that the order of accuracy is the same for autonomous and non-autonomous problems.Suggested solution : distinguish both orders, and add additional convergence tests with a non-autonomous problem, and maybe a non-linear one. There is actually still the question : does this order discrepancy also happens with non-linear autonomous problems, like y' = cos(y) or something equivalent ...
What do you think @brownbaerchen ?
rcgiri-physics commentedon Oct 20, 2026
Thanks a lot for the quick reply. I ran your question about y' = cos(y) on the tableaus from the same commit (T = 1, n = 8 to 64 steps, observed order between successive n):
RK32ARK343ERKSo the lower order also shows up for a nonlinear autonomous problem. As far as I understand, this is expected: when the nodes satisfy c = A·1 (they do for all three schemes), an autonomous nonlinear problem already needs the full set of order conditions (one per rooted tree), and the non-autonomous case adds nothing new. On y' = λy, the method reduces to its stability function R(z), so only the condition that R(z) matches exp(z) up to z^p is tested. That condition is much weaker, which is why the Dahlquist order can be higher.
On the literature: I haven't read these myself, but the AI assistant I work with pointed me to Hairer, Nørsett and Wanner, Solving Ordinary Differential Equations I and II (classical order conditions and the stability function), and to the SSP literature, where the order on linear problems is called the "linear order" (e.g. Gottlieb, Ketcheson and Shu, 2011). You'll know far better than me whether those are the right references.
Your suggested solution sounds good to me. Keeping both orders and adding a nonlinear test (y' = cos(y) is enough to catch it) would make the convergence tests detect this. Checking the order conditions directly from the Butcher table is another cheap option; that is how I found it, using the
butchermodule of physverify. If you or @brownbaerchen ever have time to try it on qmat, I'd be very grateful for any suggestions or criticism.I didn't redo the ARK548L2SAESDIRK embedded case here because it is implicit, but the 1.3e-4 residual at order 5 from my first post still applies.
brownbaerchen commentedon Oct 20, 2026
That's a good catch, thanks a lot!
Since the intention behind qmat is to be small enough for anyone to add it to the list of dependencies without worries, I am very hesitant to add dependencies to qmat that are not strictly needed. That's why I would suggest to simply add additional convergence tests with the$y' = \cos(y)$ problem.
That being said, I think your tool looks really nice and we could think about adding a CI action that double-checks the Butcher tableaux with it.
tlunet commentedon Oct 21, 2026
Hi @rcgiri-physics, thanks for the quick testing. The references you found are already good, although you can probably focus on Hairer & Wanner, Solving ODEs II to find a result where they specify a different linear (autonomous) order for a RK method. I can send you the PDF if you don't have access to it, let me know. Also, there is this publication that focused a bit more on linear order, and designed RK methods with higher linear orders, could be interesting to you (and again, let me know if you don't have access to the PDF 😉)
I've started a code adaptation in the
orderbranch. Still need to decide on :test_convergence.py:qmatneeds to stay light, and testing a non-linear problem for every scheme requires to add some solver code ...Beside those two aspects, I believe we could add
physverifyin the CI testing to automatically test the Butcher coefficients. We already have many optional dependencies for thetestenvironment (likematplotlib,flake8, etc ...), so this won't change the lightweight aspect ofqmat(onlynumpyandscipydependencies on install). But to make this cleanly, @rcgiri-physics could you eventually make a new release ofphysverifythat contains the Butcher functionalities, so we can use that as test dependency ? That would be great ... and more stable than a github pip install 😅rcgiri-physics commentedon Oct 21, 2026
Thank you, @tlunet, for the references and for the kind offer. I don't have access to Hairer & Wanner II or to that paper, so I would be very grateful for the PDFs. You can send them to rcgiri.physics@gmail.com. I'll try to read the relevant parts and understand linear order better before saying more about it.
About a release: physverify 0.4.1 is now on PyPI (
pip install "physverify>=0.4.1"), so it can go in the test dependencies without a GitHub install. Following this discussion,check_tableaucan now check more than the classical order:claimed_linear=: the order on y' = λy (where R(z) matches e^z), which is what yourorderLinearrecords and what the Dahlquist tests measure. Without it, the check notes when the linear order is higher than the order.claimed_stage=: the stage order.a_stable=,l_stable=,stiffly_accurate=: for schemes whose names claim these properties.cis passed, it fails when the row sums of A differ from it.For each registered scheme
s, a test could do something like this (only a sketch; I haven't run it inside qmat's test suite):I ran these checks on the tables in the
orderbranch. The order, the linear order, and (where the name or docstring says so) L-stability and stiff accuracy all matched your labels, with one exception: inRK53,c[2] = 3/16, but the row sum of A is3/13. The order conditions only use A and b, so the order still comes out as 3, but ifcis used for the stage times, that stage would be evaluated at the wrong time on non-autonomous problems. I couldn't check the original Wang & Spiteri table to see which of the two values is right.Any suggestions or criticism of physverify are very welcome too.
tlunet commentedon Oct 21, 2026
Thanks for the release ... and for spotting this typo on my side 😅. The proper coefficient in A was indeed 3/16, not 3/13. Guess it was to small of a difference to be spotted by the numerical tests on the Riccati problem (will still check that in detail when I'll have the time ...)
I've put the papers we talked about in a Google drive I shared with you (added also the paper from Wang & Spiteri). I'll add the
physverifyCI as soon as I can, and will ofc share my user experience with it 😉