Skip to main content

Symbolica is a blazing fast symbolic manipulation toolkit

Project description


logo

Symbolica website Zulip Chat Symbolica website

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

symbolica-0.0.2.tar.gz (115.7 kB view hashes)

Uploaded Source

Built Distribution

symbolica-0.0.2-cp311-cp311-manylinux_2_34_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.34+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page