Symbolica is a blazing fast symbolic manipulation toolkit
Project description
Symbolica
Symbolica is a symbolic manipulation toolkit which aims to handle expressions with billions of terms, taking up terabytes of diskspace. It can easily be incorporated into existing projects using its Python, Rust or C++ bindings.
Installation
Symbolica is in early development, but can already be used as a library in Rust and Pyton.
Rust
If you are using Symbolica as a library in Rust, simply include it in the Cargo.toml
:
[dependencies]
symbolica = { git = "https://github.com/benruijl/symbolica.git" }
Python
Compile Symbolica with a recent Rust compiler:
git clone https://github.com/benruijl/symbolica.git
cd symbolica
cargo build --release
and copy the shared library to your destination location, stripping the leading lib
from the filename:
cp target/release/libsymbolica.so symbolica.so
Now test that it works with the following Python script, which showcases pattern matching and rational polynomial arithmetic:
from symbolica import Expression
# create a Symbolica expression
x, y, w1_, w2_ = Expression.vars('x','y','w1_','w2_')
f = Expression.fun('f')
e = f(3,x)*y**2+5
# replace f(w1_,w2_) with f(w-1,w2^2) in e where w1_>=0 and w2_ is a variable
r = e.replace_all(f(w1_,w2_), f(w1_ - 1, w2_**2), (w1_ >= 1) & w2_.is_var())
print('Replaced:', r)
# parse rational polynomials
p = Expression.parse('(x*y^2*5+5)^2/(2*x+5)+(x+4)/(6*x^2+1)').to_rational_polynomial()
print('Rational polynomial:', p)
# compute polynomial GCDs
a = Expression.parse('(1 + 3*x1 + 5*x2 + 7*x3 + 9*x4 + 11*x5 + 13*x6 + 15*x7)^2 - 1').to_rational_polynomial()
b = Expression.parse('(1 - 3*x1 - 5*x2 - 7*x3 + 9*x4 - 11*x5 - 13*x6 + 15*x7)^2 + 1').to_rational_polynomial()
g = Expression.parse('(1 + 3*x1 + 5*x2 + 7*x3 + 9*x4 + 11*x5 + 13*x6 - 15*x7)^2 + 3').to_rational_polynomial()
ag = a * g
bg = b * g
print('Complicated GCD:', ag.gcd(bg))
Development
Symbolica is in early development. Follow the development on Zulip!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for symbolica-0.0.2-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d665a52fa29864c6728207779eb582d445e5f367eb9e75db2940dcc4f5e0b96a |
|
MD5 | f09f03704a5ddb50a97f7deb6d3c8141 |
|
BLAKE2b-256 | 41a9979f371e8c185af905530384bb25d8c82084a91b1152ba7ce2dbfc7546f8 |