#symbolic-math #computation #sym-engine

quantrs2-symengine

Symbolic Computation in Rust via SymEngine

2 releases

0.1.0-beta.2 Sep 30, 2025
0.1.0-beta.1 Sep 21, 2025
0.1.0-alpha.5 Jun 17, 2025

#985 in Math

Download history 4/week @ 2025-08-18 5/week @ 2025-08-25 70/week @ 2025-09-15 67/week @ 2025-09-22 145/week @ 2025-09-29 20/week @ 2025-10-06 20/week @ 2025-10-13 17/week @ 2025-10-20 4/week @ 2025-10-27

73 downloads per month
Used in 3 crates

MIT/Apache

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 support
  • static: Link SymEngine statically
  • system-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