2 releases
| 0.1.0-beta.2 | Sep 30, 2025 |
|---|---|
| 0.1.0-beta.1 | Sep 21, 2025 |
| 0.1.0-alpha.5 |
|
#985 in Math
73 downloads per month
Used in 3 crates
66KB
1.5K
SLoC
SymEngine for Rust
Symbolic computation in Rust, powered by SymEngine.
This crate provides safe, idiomatic Rust bindings to SymEngine, a fast symbolic manipulation library written in C++. It allows you to perform symbolic mathematics operations such as algebraic manipulation, calculus, equation solving, and more.
Quick Start
use quantrs2_symengine::Expression;
// Create symbolic expressions
let x = Expression::symbol("x");
let y = Expression::symbol("y");
// Perform operations
let expr = x.clone() * x.clone() + x.clone() * 2 * y.clone() + y.clone() * y.clone();
let expanded = expr.expand();
println!("Expression: {}", expr);
println!("Expanded: {}", expanded);
Features
- Fast: Built on SymEngine's optimized C++ core
- Safe: Memory-safe Rust interface with proper error handling
- Feature-rich: Supports algebraic operations, calculus, equation solving
- Serializable: Optional serde support for persistence
- Cross-platform: Works on Linux, macOS, and Windows
Optional Features
serde-serialize: Enable serialization/deserialization supportstatic: Link SymEngine staticallysystem-deps: Use system-installed SymEngine via pkg-config
symengine-rs
Rust bindings to SymEngine.
This is a fork of the original symengine-rs with fixes for macOS and updated symengine-sys bindings.
Requirements
You need to have SymEngine installed on your system.
macOS
brew install symengine gmp mpfr
When building, set the following environment variables:
export SYMENGINE_DIR=$(brew --prefix symengine)
export GMP_DIR=$(brew --prefix gmp)
export MPFR_DIR=$(brew --prefix mpfr)
export BINDGEN_EXTRA_CLANG_ARGS="-I$(brew --prefix symengine)/include -I$(brew --prefix gmp)/include -I$(brew --prefix mpfr)/include"
Usage
Add this to your Cargo.toml:
[dependencies]
symengine = { git = "https://github.com/cool-japan/symengine-rs.git", branch = "fixed-macos" }
License
MIT
Dependencies
~91MB
~1.5M SLoC