rmath.calculus
Industrial-grade tools for automatic differentiation and numerical integration.
Proven: Forward-Mode AD
The Dual number implementation allows exact gradient computation alongside regular math operations, without the overhead of building a reverse-mode tape.
from rmath.calculus import Dual
x = Dual(3.0, 1.0)
y = x**2 + x * 5.0 + 10.0
print(f"f(3) : {y.value}")
print(f"f'(3) : {y.derivative}")
f(3) : 34.0
f'(3) : 11.0
Numerical Integration
RMath provides high-speed parallel implementations of common integration rules,
suitable for large-scale datasets.
import rmath.vector as rv
import rmath.calculus as rc
x = rv.linspace(0.0, 3.1415926535, 1000)
y = x.sin()
area = rc.integrate_trapezoidal(x, y)
print(f"Trapezoidal Area: {area:.6f}")
area_simpson = rc.integrate_simpson(lambda x: x**2, 0.0, 1.0, 100)
print(f"Simpson's Area : {area_simpson:.6f}")
Trapezoidal Area: 2.000000
Simpson's Area : 0.333333