You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generated by python docs/validate.py; rerun in CI on every push.
105 / 105 checks pass.
Every from-scratch algorithm is compared with SciPy/NumPy/statsmodels, with exact analytic results, with NIST certified values, or with its theoretical order of convergence (the slope of log(error) against log(step size)).
Root finding
Check
Reference
engmath
Expected
Tolerance
Status
bisection: root of x^3 - 2x - 5
scipy brentq
2.094551482
2.094551482
1e-11
pass
Newton: root of x^3 - 2x - 5
scipy brentq
2.094551482
2.094551482
1e-11
pass
secant: root of x^3 - 2x - 5
scipy brentq
2.094551482
2.094551482
1e-11
pass
Brent: root of x^3 - 2x - 5
scipy brentq
2.094551482
2.094551482
1e-11
pass
Newton convergence order (cos x = x)
theory: 2
1.99803193
2
0.2
pass
secant convergence order
theory: 1.618
1.680279093
1.618
0.3
pass
bisection: error halves each step (median ratio)
theory: 0.5
0.3942053058
0.5
0.3
pass
Colebrook f (eps/D 1e-3, Re 5e5) vs Haaland
Haaland (1983), ±2 %
1.001892231
1
0.02
pass
Colebrook residual at computed root
exact: 0
4.076206039e-11
0
1e-10
pass
Optimisation
Check
Reference
engmath
Expected
Tolerance
Status
Nelder-Mead: Rosenbrock minimum x
exact: 1
1
1
1e-05
pass
Nelder-Mead: Rosenbrock minimum y
exact: 1
1
1
1e-05
pass
golden section: min of (x-2)^2 + sin 3x
scipy minimize_scalar
1.649428381
1.649428371
1e-06
pass
Linear systems and eigenvalues
Check
Reference
engmath
Expected
Tolerance
Status
Gauss elimination vs numpy.linalg.solve (max diff)
numpy
2.081668171e-17
0
1e-12
pass
Gauss with a zero pivot (pivoting needed)
numpy
1.165734176e-15
0
1e-10
pass
Thomas algorithm, n = 200 (max diff)
numpy
1.665334537e-16
0
1e-12
pass
jacobi iteration (diagonally dominant)
numpy
3.016753514e-12
0
1e-09
pass
gauss-seidel iteration (diagonally dominant)
numpy
1.814159933e-12
0
1e-09
pass
power iteration: largest eigenvalue of spring chain
exact: 2 + 2cos(pi/11)
3.918985947
3.918985947
1e-08
pass
Interpolation
Check
Reference
engmath
Expected
Tolerance
Status
natural cubic spline vs scipy (max diff)
scipy CubicSpline natural
6.661338148e-16
0
1e-12
pass
spline derivative vs scipy (max diff)
scipy
3.330669074e-16
0
1e-11
pass
spline integral vs scipy
scipy
1.428391731
1.428391731
1e-12
pass
linear interpolation vs numpy.interp
numpy
0
0
1e-15
pass
spline convergence order (sin on [0, pi])
theory: 4
4.033358178
4
0.3
pass
Lagrange through 5 points of a quartic is exact
exact
-0.2919
-0.2919
1e-14
pass
Integration
Check
Reference
engmath
Expected
Tolerance
Status
trapezoid: observed order of accuracy
theory: 2
2.001061538
2
0.1
pass
midpoint: observed order of accuracy
theory: 2
2.001856693
2
0.1
pass
simpson: observed order of accuracy
theory: 4
4.002587339
4
0.1
pass
Romberg (6 levels)
exact
0.1848746759
0.1848746759
1e-10
pass
Gauss-Legendre 12 points
exact
0.1848746759
0.1848746759
1e-12
pass
Simpson, 42 unequal points vs scipy.simpson
scipy
0.1849559485
0.1849559485
1e-10
pass
Simpson, uneven spacing, quadratic (exact)
exact
4.5
4.5
1e-10
pass
Simpson, EQUAL spacing, cubic (exact by symmetry)
exact
20.25
20.25
1e-12
pass
trapezoid, uneven points vs scipy.trapezoid
scipy
0.1856604401
0.1856604401
1e-14
pass
cumulative trapezoid end value
trapezoid
0.1856604401
0.1856604401
1e-14
pass
Differentiation
Check
Reference
engmath
Expected
Tolerance
Status
uneven gradient vs numpy.gradient (2nd-order edges)
numpy
0
0
1e-10
pass
uneven-grid gradient: observed order
theory: 2
1.969503111
2
0.2
pass
Richardson extrapolation of d/dx e^x sin 3x at 1
exact
-7.689631888
-7.689631888
1e-09
pass
second derivative of a quadratic (exact)
exact
1.572075803e-13
0
1e-09
pass
Smoothing
Check
Reference
engmath
Expected
Tolerance
Status
Savitzky-Golay (15 pts, cubic, deriv 0) vs scipy
scipy savgol_filter
5.773159728e-15
0
1e-09
pass
Savitzky-Golay (15 pts, cubic, deriv 1) vs scipy
scipy savgol_filter
1.232347557e-14
0
1e-09
pass
Savitzky-Golay (15 pts, cubic, deriv 2) vs scipy
scipy savgol_filter
4.085620731e-14
0
1e-09
pass
LOWESS reduces error vs the true signal (RMS ratio)
should be < 0.6
0.4532236684
0.6
0.6
pass
LOWESS reproduces a straight line exactly
exact
1.421085472e-14
0
1e-10
pass
Least-squares fitting
Check
Reference
engmath
Expected
Tolerance
Status
linear least squares vs numpy.lstsq (max diff)
numpy
1.776356839e-15
0
1e-12
pass
standard errors vs s^2 (X'X)^-1
formula
2.255065327e-15
0
1e-10
pass
Huber IRLS slope with an edge outlier (true 2)
truth ±0.15
2.025264216
2
0.1
pass
... while ordinary least squares is pulled away
OLS error > 0.3
0.3
0.3
1e-09
pass
LM: NIST Misra1a b1 (start 1)
NIST certified
1
1
1e-06
pass
LM: NIST Misra1a b2 (start 1)
NIST certified
0.9999999997
1
1e-06
pass
LM: NIST Misra1a SE(b1)
NIST certified
0.9999998954
1
0.0001
pass
LM: NIST Misra1a residual SD
NIST certified
1
1
1e-08
pass
Ordinary differential equations
Check
Reference
engmath
Expected
Tolerance
Status
Euler: observed order
theory: 1
1.008600088
1
0.2
pass
RK4: observed order
theory: 4
4.072785345
4
0.2
pass
adaptive RK23 (rtol 1e-8) vs exact
exact exp(-t^2)
0.01831563566
0.01831563889
1e-07
pass
RK4 Lotka-Volterra system vs solve_ivp
scipy (rtol 1e-12)
0
0
1e-07
pass
backward Euler stable on stiff ODE (h = 0.02, lambda h = -20)
y - cos t
small
0.0008354542167
0
... explicit Euler with the same step blows up
y
> 1e6
1000000
1000000
Diffusion PDE (vs erf solution of a semi-infinite medium)
Check
Reference
engmath
Expected
Tolerance
Status
FTCS (r = 0.4) max error
erfc solution
3.41466789e-05
0
0.005
pass
Crank-Nicolson (r = 2.5, beyond the FTCS limit) max error
erfc solution
8.99232107e-06
0
0.01
pass
FTCS refuses an unstable step (r = 0.6)
raises
1
1
0
pass
Systems of nonlinear equations
Check
Reference
engmath
Expected
Tolerance
Status
three-reservoir junction head vs 1D reduction (Brent)
independent formulation
105.2119062
105.2119062
1e-08
pass
continuity satisfied (sum of flows)
exact: 0
1.387778781e-17
0
1e-12
pass
flows vs scipy.optimize.root (max diff)
scipy
2.775557562e-17
0
1e-09
pass
Newton for systems: observed order near the root
theory: 2
2.007479289
2
0.3
pass
Boundary-value problems (pin fin with convective tip)