SymbAnaFis: Symbolic Analysis for Physics
A fast, focused Rust library for symbolic differentiation and analysis, designed for physics and engineering applications.
Features
- Symbolic Differentiation: Compute derivatives of complex mathematical expressions.
- Context-Aware Parsing: Support for fixed variables (constants) and custom functions.
- Simplification: Comprehensive algebraic, trigonometric, hyperbolic, and logarithmic simplification rules.
- Extensible: Easily add new functions and simplification rules.
- Safe: Built with Rust's safety guarantees, with limits on recursion depth and node count.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use ;
Configuration
You can configure safety limits using environment variables:
SYMB_ANAFIS_MAX_DEPTH: Maximum AST depth (default: 100)SYMB_ANAFIS_MAX_NODES: Maximum AST node count (default: 10000)
Advanced Usage
Expression Simplification
You can simplify expressions without differentiation:
use simplify;
Multi-Character Symbols
For symbols with multiple characters (like "sigma", "alpha", etc.), pass them as fixed variables to ensure they're treated as single symbols:
use simplify;
Fixed Variables and Custom Functions
You can define constants (like a, b) and custom functions (like f(x)) that are treated correctly during differentiation.
use diff;
Supported Functions
- Trigonometric:
sin,cos,tan,cot,sec,csc,asin,acos,atan,acot,asec,acsc - Hyperbolic:
sinh,cosh,tanh,coth,sech,csch,asinh,acosh,atanh,acoth,asech,acsch - Exponential/Logarithmic:
exp,ln,log,log10,log2 - Roots:
sqrt,cbrt - Absolute Value/Sign:
abs,sign - Special:
sinc,erf,erfc,gamma,digamma,trigamma,tetragamma,polygamma,beta,LambertW,besselj,bessely,besseli,besselk
Note: The polygamma(n, x) function provides derivatives for all polygamma functions. Functions with non-elementary derivatives use custom notation.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.