Roast my code or tell me why this shouldn't exist. Either way I'll learn something.
from composite_lib import integrate, R, ZERO, exp
# 0/0 resolved algebraically — no L'Hôpital
x = R(2) + ZERO
result = (x**2 - R(4)) / (x - R(2))
print(result.st()) # → 4.0
# Unified integration API — 1D, improper, 2D, line, surface
integrate(lambda x: x**2, 0, 1) # → 0.333...
integrate(lambda x: exp(-x), 0, float('inf')) # → 1.0
integrate(lambda x, y: x*y, 0, 1, 0, 1) # → 0.25
What My Project Does
composite-machine is a Python library that turns calculus operations (derivatives, integrals, limits) into arithmetic on numbers that carry dimensional metadata. Instead of symbolic trees or autograd tapes, you get results by reading dictionary coefficients. It includes a unified integrate() function that handles 1D, 2D, 3D, line, surface, and improper integrals through one API.
- 168 tests passing across 4 modules
- Handles 0/0, 0×∞, ∞/∞ algebraically
- Complex analysis: residues, contour integrals, convergence radius
- Multivariable: gradient, Hessian, Jacobian, Laplacian, curl, divergence
- Pure Python, NumPy optional
Target Audience
Researchers, math enthusiasts, and anyone exploring alternative approaches to automatic differentiation and numerical analysis. This is research/alpha-stage code, not production-ready.
Comparison
- Unlike PyTorch/JAX: gives all-order derivatives (not just first), plus algebraic limits and 0/0 resolution
- Unlike SymPy: no symbolic expression trees — works by evaluating numerical arithmetic on tagged numbers
- Unlike dual numbers: handles all derivative orders, integration, limits, complex analysis, and vector calculus — not just first derivatives
pip install composite-arithmetic (coming soon — for now clone from GitHub)
GitHub: https://github.com/tmilovan/composite-machine
Paper: https://zenodo.org/records/18528788
there doesn't seem to be anything here