Symbolica is a blazing fast symbolic manipulation toolkit
Project description
Symbolica
Symbolica is a computer algebra system 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.
For documentation and more, see symbolica.io.
Quick Example
Symbolica allows you to build and manipulate mathematical expressions through matching and replacing patterns, similar to regex
for text:
You are able to perform these operations from the comfort of a programming language that you (probably) already know, by using Symbolica's bindings to Python, Rust and C++:
Installation
Visit the Get Started page for detailed installation instructions.
Rust
If you are using Symbolica as a library in Rust, simply include it in the Cargo.toml
:
[dependencies]
symbolica = "0.1"
Python
Symbolica can be installed for Python >3.5 using pip
:
pip install symbolica
The installation may take some time, as it may have to compile Symbolica.
Examples
In the following example we create a Symbolica expression (1+x)^2
, expand it, and replace x^2
by 6
:
from symbolica import Expression
x = Expression.var('x')
e = (1+x)**2
r = e.expand().replace_all(x**2, 6)
print(r)
which yields 2*x+7
.
Pattern matching
Variables ending with a _
are wildcards that match to any subexpression.
In the following example we try to match the pattern f(w1_,w2_)
:
from symbolica import Expression
x, y, w1_, w2_ = Expression.vars('x','y','w1_','w2_')
f = Expression.fun('f')
e = f(3,x)*y**2+5
r = e.replace_all(f(w1_,w2_), f(w1_ - 1, w2_**2))
print(r)
which yields y^2*f(2,x^2)+5
.
Rational arithmetic
Symbolica is world-class in rational arithmetic, outperforming Mathematica, Maple, Form, Fermat, and other computer algebra packages. Simply convert an expression to a rational polynomial:
from symbolica import Expression
x, y = Expression.vars('x','y')
p = Expression.parse('(x*y^2*5+5)^2/(2*x+5)+(x+4)/(6*x^2+1)').to_rational_polynomial()
print(p)
which yields (45+13*x+50*x*y^2+152*x^2+25*x^2*y^4+300*x^3*y^2+150*x^4*y^4)/(5+2*x+30*x^2+12*x^3)
.
Development
Follow the development and discussions 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 Distributions
Hashes for symbolica-0.1.0.post1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25ed416e7c9f6e3e6df11631906ca7f840628be0760d3e13f6fc0037354f78dc |
|
MD5 | b67d60abacb952ee1c37dc22aff81a26 |
|
BLAKE2b-256 | 006635fca72d562642521e9588ff55166b8836b6bec8f758c2e61dfb73a67fdb |
Hashes for symbolica-0.1.0.post1-cp37-abi3-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef6aaeb4159f8d84b30f257461965f3617ed464a6149db1cd19c9cb6c61b8028 |
|
MD5 | 636fdc8f62d24c4ebf7cf9c28e5ae605 |
|
BLAKE2b-256 | d4a70431de63327cb820ff9abf1899cb2555b144cd8cddf9de3618efa775f7ed |