Expand description
Numerical algorithms for physics simulation.
Provides root finding, quadrature, finite differences, and special functions used throughout the OxiPhysics engine.
Structs§
- Online
Stats - Online (streaming) mean and variance using Welford’s algorithm.
- Root
Result - Result of a root-finding operation.
Functions§
- adaptive_
integrate - Adaptive Gaussian quadrature (recursive).
- bernoulli_
numbers - Compute the first
nBernoulli numbers B₀, B₁, …, B_{n-1}. - bessel_
j0 - Bessel function J0(x) (zeroth order, first kind).
- bessel_
j1 - Bessel function J1(x) (first order, first kind).
- beta
- Complete beta function B(a, b) = Γ(a)Γ(b)/Γ(a+b).
- bilinear_
arr - Bilinear interpolation on a 2×2 grid (array form).
- bisect
- Bisection root finding on interval [a, b].
- brent
- Brent’s method — robust root finding combining bisection, secant, and inverse quadratic interpolation.
- cfl_
number - Compute the CFL (Courant–Friedrichs–Lewy) number.
- chebyshev_
t - Chebyshev polynomial T_n(x) of the first kind.
- continued_
fraction - Evaluate a generalised continued fraction using the Lentz algorithm.
- digamma
- Digamma function ψ(x) = d/dx ln(Γ(x)).
- dt_
from_ cfl - Compute the maximum safe time step for a given CFL target.
- ei
- Exponential integral Ei(x) for x > 0.
- erf
- Error function erf(x) using a rational approximation.
- erfc
- Complementary error function erfc(x) = 1 - erf(x).
- erfinv
- Inverse error function erfinv(y) for y ∈ (-1, 1).
- factorial
- Factorial n! as f64 (using gamma).
- find_
x_ for_ value - Solve f(x) = target by translating to a zero-finding problem via Brent.
- finite_
diff_ central - First derivative of f at x using centered differences with step h.
- finite_
diff_ second - Second derivative of f at x using centered differences.
- gamma
- Gamma function approximation (Lanczos, g=7).
- gauss_
legendre5 - Gauss-Legendre 5-point quadrature on [-1, 1], mapped to [a, b].
- gauss_
legendre_ n - Gauss-Legendre quadrature of order n on [a, b].
- gauss_
legendre_ nw - Gauss-Legendre nodes and weights for n-point quadrature on [-1, 1].
- gradient_
3d - Gradient of f: R^3 → R using central differences.
- hessian
- Hessian of f: R^n → R as a flat n×n matrix using central differences.
- horner
- Evaluate a polynomial using Horner’s method.
- inc_
beta - Regularized incomplete beta function I(x; a, b).
- legendre
- Evaluate a Legendre polynomial P_n(x) via recurrence.
- lerp_
scalar - Linear interpolation scalar:
a + t*(b-a). - lgamma
- Log gamma function.
- ln_
via_ cf - Evaluate the natural logarithm via its continued fraction representation.
- newton
- Newton-Raphson root finding.
- normal_
cdf - Normal CDF Φ(x).
- regula_
falsi - Regula falsi (Illinois variant) root finding.
- richardson_
derivative - Compute the first derivative of f at x using Richardson extrapolation.
- richardson_
second_ derivative - Compute the second derivative of f at x using Richardson extrapolation.
- romberg
- Romberg integration of f over [a, b].
- secant
- Secant method root finding.
- simpson
- Simpson’s rule integration of f over [a, b] with n subintervals (n must be even).
- smootherstep
- Smoother step (Ken Perlin’s 6th degree).
- smoothstep
- Smooth Hermite interpolation (smoothstep).
- sqrt2_
cf - Compute √2 via its continued fraction [1; 2, 2, 2, …].
- stirling_
factorial - Stirling’s approximation for n! as f64.
- stirling_
ln_ factorial - Stirling’s approximation for ln(n!).
- stirling_
relative_ error - Relative error of Stirling’s approximation vs exact ln(Γ(n+1)).
- trapezoid_
tabulated - Trapezoidal rule for tabulated data.
- trilinear_
arr - Trilinear interpolation on a 2×2×2 grid (array form).