Data and Math
vnumerical
Root finding, numerical integration and simple ODE simulation.
Released v1.0.0 · 2026-09-28use "stdlib/numerical.ven"
print bisection_root(make(x) give x * x - 2.0, 0.0, 2.0, 0.000001, 100)
Reference (7 functions)
API reference
bisection_root(f, low, high, tolerance, max_iterations)
Finds a root of f inside [low, high] by repeated interval halving.
bisection_root(make(x) give x * x - 2.0, 0.0, 2.0, 0.000001, 100)newton_raphson_root(f, fprime, x0, tolerance, max_iterations)
Finds a root of f near x0 using Newton's method.
newton_raphson_root(make(x) give x * x - 2.0, make(x) give 2.0 * x, 1.0, 0.000000001, 50)numerical_derivative(f, x, h)
Estimates the derivative of f at x by central difference.
numerical_derivative(make(x) give x * x * x, 2.0, 0.000001)trapezoidal_integral(f, low, high, steps)
Approximates the definite integral of f over [low, high].
trapezoidal_integral(make(x) give x * x * x, 0.0, 1.0, 100)simpsons_integral(f, low, high, steps)
Approximates the definite integral of f over [low, high].
simpsons_integral(make(x) give x * x * x, 0.0, 1.0, 10)euler_method(f, x0, y0, x_end, steps)
euler_method(make(x, y) give y, 0.0, 1.0, 1.0, 4)runge_kutta_4(f, x0, y0, x_end, steps)
Solves the same initial value problem as euler_method, more accurately.
runge_kutta_4(make(x, y) give y, 0.0, 1.0, 1.0, 4)