SymbAnaFis
High-performance symbolic mathematics library written in Rust with Python bindings.
SymbAnaFis provides a robust engine for symbolic differentiation, simplification, and evaluation, designed for performance-critical applications in physics, engineering, and machine learning.
Key Capabilities
- ⚡ High-Performance Architecture: Built on Rust for speed and memory safety, with interned strings and optimized memory layout.
- ∂ Symbolic Differentiation: Supports product, chain, and quotient rules for a vast array of mathematical functions.
- ✨ Algebraic Simplification: Intelligent simplification engine covering trigonometric identities, constant folding, and algebraic expansion.
- 📊 Uncertainty Propagation: Comprehensive support for calculating uncertainty propagation with full covariance matrix integration.
- ∇ Vector Calculus: Native symbolic computation of Gradients, Hessians, and Jacobian matrices.
- 🚀 Parallel Processing: Optional parallel evaluation engine using Rayon for massive batch operations.
- 📦 Python Bindings: Seamless Python integration via
maturin, offering the speed of Rust with the ease of Python.
Visual Benchmarks
SymbAnaFis performance is validated against SymPy and SymEngine using complex physical simulations. Each benchmark features a Quad-View Dashboard comparing real-time simulations side-by-side.
Aizawa Attractor
Watch Video Simulates 500,000 particles flowing through the Aizawa field, comparing Euler integration throughput.
Clifford Attractor
Watch Video Visualizes 1,000,000 particles evolving in the Clifford map, testing discrete map evaluation speed.
Double Pendulum Matrix
Watch Video Simulates 50,000 chaotic double pendulums, verifying symbolic differentiation correctness and RK4 integration stability.
Gradient Descent Avalanche
Watch Video Massive particle descent on a complex terrain function, showcasing symbolic differentiation of compiled functions.
Installation
# Python
# Rust
Quick Start
Python
# Differentiate complex expressions
=
# → "3*x^2 + cos(x)"
# Algebraic Simplification
=
# → "1"
# Handle constants automatically
=
# → "2*a*x"
Rust
use ;
Advanced Features
🔍 Fine-Grained Control
Use the Builder pattern to configure safety limits and behavior.
use ;
new
.domain_safe // Prevent unsafe simplifications (e.g., x/x != 1 if x=0)
.max_depth // Prevent stack overflows on massive expressions
.diff_str?; // Result: abs(x)/x
📉 Uncertainty Propagation
Calculate error propagation symbolically, supporting correlated variables.
use uncertainty_propagation;
// Calculate uncertainty formula for f = x + y with full covariance support
let sigma = uncertainty_propagation?;
// → sqrt(sigma_x^2 + 2*sigma_x*sigma_y*rho_xy + sigma_y^2)
⚡ Parallel Evaluation
Evaluate expressions over large datasets in parallel (requires parallel feature).
// Evaluate symbolic expressions across thousands of data points efficiently
let results = evaluate_parallel;
🛠️ Custom Functions
Register custom functions with their own derivative rules.
use ;
new
.user_fn
.diff_str?; // → 4*x^3
Supported Functions
SymbAnaFis supports over 50 built-in mathematical functions:
| Category | Functions |
|---|---|
| Trig | sin, cos, tan, cot, sec, csc |
| Inverse Trig | asin, acos, atan, atan2, acot, asec, acsc |
| Hyperbolic | sinh, cosh, tanh, coth, sech, csch |
| Inverse Hyperbolic | asinh, acosh, atanh, acoth, asech, acsch |
| Exp/Log | exp, ln, log(b, x), log10, log2, exp_polar(acts as exp for now) |
| Roots | sqrt, cbrt |
| Error Functions | erf, erfc |
| Gamma Family | gamma, digamma, trigamma, tetragamma, polygamma(n, x), beta(a, b) |
| Zeta | zeta, zeta_deriv(n, s) |
| Bessel | besselj(n, x), bessely(n, x), besseli(n, x), besselk(n, x) |
| Elliptic Integrals | elliptic_k, elliptic_e |
| Orthogonal Polynomials | hermite(n, x), assoc_legendre(l, m, x) |
| Spherical Harmonics | spherical_harmonic(l, m, θ, φ), ynm(l, m, θ, φ) |
| Other | abs, signum, sinc, lambertw, floor, ceil, round |
Documentation
- API Reference - Detailed guide to all functions and modules.
- docs.rs - Full Rust crate documentation.
License
Apache License 2.0 - see LICENSE
Citation
If you use SymbAnaFis in academic work, please cite:
Built with ❤️ in Rust 🚀