A comprehensive, educational library of fundamental numerical analysis algorithms implemented from scratch in pure Python and NumPy. This project is designed to bridge the gap between theoretical numerical analysis and practical implementation, offering full transparency into algorithmic behavior, stability, and convergence.
The library is organized into specialized modules:
ode/: Ordinary Differential Equation solvers including Euler, RK2, and classic RK4 methods[cite: 15].integration/: Numerical quadrature methods, contrasting classic Newton-Cotes rules (Rectangle, Trapezoidal, Simpson) with high-precision Gauss-Legendre quadratures[cite: 17].linear_algebra/: Direct solvers (Gaussian Elimination with pivoting) and iterative solvers (Jacobi method) for linear systems[cite: 18].root_finding/: Iterative algorithms for nonlinear equations, implementing Tangent (Newton-Raphson) and Secant methods[cite: 19].interpolation/: Polynomial interpolation techniques including Lagrange and Newton methods.approximation/: Polynomial approximation using normal equations, Gram-Schmidt orthogonalization, and three-term recurrence.
- Transparency: No "black-box" solver calls. Every weight, step, and coefficient is explicitly calculated in the source code[cite: 15, 17].
- Stability focus: Implements partial and column pivoting in linear systems to prevent singular matrix errors[cite: 18].
- Educational Approach: Includes convergence analysis, error checking, and Fourier conditions for root-finding algorithms[cite: 19].
- Clean Design: Separation of concerns between the mathematical core (logic) and the demonstration/testing suites.
To use a specific module, simply import the desired algorithm. For example, to solve an ODE using the RK4 method:
from ode.runge_kutta import rk4
# Define ODE: dy/dx = x + y, Interval: [0, 1], Steps: 10
result = rk4(lambda x, y: x + y, a=0.0, b=1.0, ya=0.1, N=10)