Module Jera
Numerical methods.
Jera computes quantities defined as limits (integrals, solutions of differential equations, approximations of functions) over Nx tensors. Every program is eager unless it says otherwise and runs unchanged under Rune.jit, Rune.vmap and the derivatives of Rune; jera never compiles anything itself. A random source, a key or a Brownian path, is an argument of a compiled function: one it captures is a constant, whose draws it refuses.
Methods by problem
Problem | Regime | Method |
|---|---|---|
Linear system | small, dense | |
banded | ||
large, symmetric positive-definite | ||
large | ||
Zero of a function | derivative given | |
a bracket | ||
Zero of a system | derivative given | |
no usable derivative | ||
fixed point | ||
many small systems | ||
Minimum | smooth, small | |
smooth, large | ||
smooth, ill-conditioned | ||
sum of squares | ||
no useful gradient | ||
bounds |
| |
one variable, a bracket | ||
Integral, one dimension | smooth | |
of samples |
| |
endpoint singularity, infinite range | ||
Integral, several dimensions | up to ten | |
high | ||
Approximation | samples | |
monotone samples | ||
a function, to a tolerance | ||
a function, fixed resolution | ||
samples on a grid | ||
Differential equation | non-stiff |
|
stiff; index-1 algebraic constraints |
| |
randomness | ||
separable Hamiltonian, long times |
Conventions
- Problems are closures. A problem is an OCaml function and the data it is computed over. Every tracked value the function reads, argument or capture, reaches the derivative.
- Batching. Elementwise families (
Root,Minimize.bracket,Quad's one-dimensional integrals, evaluation) treat every element as its own problem; their function must not reduce or mix along any axis.Quad.cubatureandQuad.qmcsolve one problem per lane, their integrand reducing only the last, coordinate axis. Structured families solve one problem, and a state's tensors share its steps.Rune.vmapgives each lane its own. - Dtypes. The working dtype is the data's, with no default. Times have their own dtype. Float leaves of a state are its vector; other leaves are carried unchanged.
- Formula or solve. A function whose answer can miss on tensor data (a tolerance, a budget) is a solve and returns a
Solution.t, with a status per lane; one that cannot is a formula and returns its value, and its derivative is the composition's. - Searches and answers. A solve searches on detached values, then states its answer from the search's decisions: a zero or a minimum by its equation through
Rune.root, an integral by its rule over the final partition, a flow by its accepted steps taken again, a fit by its final pieces. The derivative is the answer's: no search is differentiated, and a lane that did not converge has a zero derivative. - Tags. A method's tag says which drivers take it:
`Formularuns in a formula,`Embeddedestimates its error and drives a solve. An impossible pairing is a type error. - Budgets are arguments only where no bound is derivable, with no default.
- Derivatives that steer. A method that needs a derivative only to steer its search takes it from the caller (
slope); it changes the speed only. - Errors. A broken precondition on static data raises
Invalid_argumentnaming the function, at once. A missed tolerance is a status. A broken precondition on a formula's tensor data raisesInvalid_argumentthroughNx.check, as a check does: at once on the host, at the next wait on another set, eagerly or underRune.jit. - Devices. Every result lies on its data's device set
'd, and the types carry it. Constants are computed on the host in float64, rounded once to the working dtype and placed whole on each device the data lies on. AQuad.Rule's nodes are host values, andQuad.Rule.nodes_atplaces them.