Skip to contents

residual_order_condition(tab, order) evaluates the residuals \((\Phi(t) - 1/\gamma(t)) / \sigma(t)\) of the order conditions of a Runge-Kutta tableau for every rooted tree t with order vertices (in the order of RootedTrees.jl's tree iterator), with the elementary weight \(\Phi\), the density \(\gamma\) and the symmetry \(\sigma\) of the tree. With a reducer (a function of two arguments such as `+`) the residuals are first transformed by mapper and then combined from left to right. embedded = TRUE uses the weights of the embedded method.

Usage

residual_order_condition(
  tab,
  order,
  reducer = NULL,
  mapper = function(x) x^2,
  embedded = FALSE
)

check_tableau(tab, tol = 10 * .Machine$double.eps)

Arguments

tab

A Runge-Kutta tableau, such as ExplicitRKTableau().

order

Number of vertices of the rooted trees.

reducer

NULL for the vector of residuals, or a function combining two values.

mapper

Function applied to each residual before reducing.

embedded

Use the embedded method.

tol

Tolerance on the sum of absolute residuals.

Value

A numeric vector or value; check_tableau() returns TRUE.

Details

check_tableau(tab) checks the conditions of every order up to the declared order of the method (and of the embedded method, when it has one): the sum of the absolute residuals of each order must be below tol. It returns TRUE or signals an error.

Examples

tab <- constructTsit5ExplicitRK()
residual_order_condition(tab, 3)
#> [1] -1.193490e-15 -2.164935e-15
residual_order_condition(tab, 5, `+`, abs)
#> [1] 0.002301776
# the order 5 conditions of Tsit5 hold only approximately, as in Julia
tryCatch(check_tableau(tab), error = conditionMessage)
#> [1] "Tableau's order is not correct."