Symbolica is a blazing fast computer algebra system
Project description
Symbolica
Symbolica is a blazing fast and modern computer algebra system which aims to handle huge expressions. It can easily be incorporated into existing projects using its Python, Rust or C++ bindings. Check out the live Jupyter Notebook demo!
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.
Python
Symbolica can be installed for Python >3.5 using pip
:
pip install symbolica
The installation may take some time on Mac OS and Windows, as it may have to compile Symbolica.
Rust
If you want to use Symbolica as a library in Rust, simply include it in the Cargo.toml
:
[dependencies]
symbolica = "0.3"
Examples
Below we list some examples of the features of Symbolica. Check the guide for a complete overview.
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
.
Solving a linear system
Solve a linear system in x
and y
with a parameter c
:
from symbolica import Expression
x, y, c = Expression.vars('x', 'y', 'c')
f = Expression.fun('f')
x_r, y_r = Expression.solve_linear_system(
[f(c)*x + y + c, y + c**2], [x, y])
print('x =', x_r, ', y =', y_r)
which yields x = (-c+c^2)*f(c)^-1
and y = -c^2
.
Series expansion
Perform the Taylor series in x
of an expression that contains a user-defined function f
:
from symbolica import Expression
x, y = Expression.vars('x', 'y')
f = Expression.fun('f')
e = 2* x**2 * y + f(x)
e = e.taylor_series(x, 0, 2)
print(e)
which yields f(0)+x*der(1,f(0))+1/2*x^2*(4*y+der(2,f(0)))
.
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 Distribution
Hashes for symbolica-0.3.0-cp37-abi3-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d4f037b2ba9a1892b6f93f21b8ba05e7858a6d0d611ea20ba6aa6a124ba6100 |
|
MD5 | 8c55f63bdfb6e5c70e1834b1f634f7f8 |
|
BLAKE2b-256 | 8b579979a9c445786c518919745f07b8ea8c58a65a2d2caa8acc9cc52bef74c7 |