github ↗
docs menu

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

Linear.dense

banded

Linear.banded

large, symmetric positive-definite

Linear.cg

large

Linear.gmres

Zero of a function

derivative given

Root.newton

a bracket

Root.bracket

Zero of a system

derivative given

System.newton

no usable derivative

System.broyden

fixed point x = g x

System.anderson

many small systems

System.lanes

Minimum

smooth, small

Minimize.bfgs

smooth, large

Minimize.lbfgs

smooth, ill-conditioned

Minimize.newton

sum of squares

Minimize.levenberg_marquardt

no useful gradient

Minimize.nelder_mead

bounds

~lo and ~hi on any of them

one variable, a bracket

Minimize.bracket

Integral, one dimension

smooth

Quad.adaptive; Quad.fixed, Quad.cumulative

of samples

Piecewise.integral of an interpolant

endpoint singularity, infinite range

Quad.tanh_sinh

Integral, several dimensions

up to ten

Quad.cubature

high

Quad.qmc

Approximation

samples

Piecewise.linear, Piecewise.cubic, Piecewise.hermite

monotone samples

Piecewise.steffen

a function, to a tolerance

Piecewise.adapt

a function, fixed resolution

Piecewise.chebyshev, Grid.chebyshev

samples on a grid

Grid.linear, Grid.cubic

Differential equation

non-stiff

Ode.solve, Ode.sample with Ode.tsit5 and kin; Ode.march with an explicit method, Ode.euler to Ode.dopri5

stiff; index-1 algebraic constraints

Ode.kvaerno5, with a mass

randomness

Sde.march

separable Hamiltonian, long times

Split

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.cubature and Quad.qmc solve 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.vmap gives 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: `Formula runs in a formula, `Embedded estimates 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_argument naming the function, at once. A missed tolerance is a status. A broken precondition on a formula's tensor data raises Invalid_argument through Nx.check, as a check does: at once on the host, at the next wait on another set, eagerly or under Rune.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. A Quad.Rule's nodes are host values, and Quad.Rule.nodes_at places them.
#module Tol : sig ... end

Tolerances.

#module Solution : sig ... end

Answers of solves.

#module Linear : sig ... end

Linear systems.

#module Root : sig ... end

Zeros of functions of one variable.

#module System : sig ... end

Zeros of systems.

#module Minimize : sig ... end

Minima.

#module Quad : sig ... end

Integrals.

#module Piecewise : sig ... end

Piecewise Chebyshev series.

#module Grid : sig ... end

Tensor-product series over grids.

#module Ode : sig ... end

Ordinary differential equations.

#module Sde : sig ... end

Stochastic differential equations.

#module Split : sig ... end

Splitting methods for separable Hamiltonians.