We just released SymEngine 0.1.0:
) is a standalone fast
C++ symbolic manipulation library. Optional thin wrappers allow usage
of the library from other languages, we currently have C, Python, Ruby
and Julia wrappers. The Python wrappers allow integration with SymPy
SymEngine was previously called CSymPy, but we renamed it, since it
can be used from any language, not just Python. Even though the Python
wrappers are the most developed, and I am personally heavily invested
in Python and my long term goal is to figure out how to port SymPy on
top of SymEngine, as well as Sage on top of SymEngine. So that we can
have just one symbolic library, that is fast, but also has a lot of
features, either in terms of SymPy in Python, or eventually in C++
(that way other languages can benefit as well).
Here are build instructions for Sage:
we tested it on Sage Math Cloud. You can then use Sage with SymEngine
in it to run your favorite benchmark.
We also have some automatic benchmarks, some timings are posted here:
We benchmark both the Python wrappers (against Sage or SymPy), as well
as just the raw C++ library (against e.g. GiNaC).
Most of these benchmarks are synthetic, and so the problem with them
is that you can for example use a fast polynomial library to do them
faster. SymEngine seems to be faster than Sage on all of them, but if
you find some where Sage is faster, definitely let me know.
However, much better is to benchmark on some real applications. Here
is an example: https://github.com/certik/symengine/pull/10#issuecomment-129199481
that uses symbolics (as it has square roots, fractions, sin, cos and
other things) and it is benchmarking how long it takes to do a
derivative (once the expression is fully converted to Sage, SymEngine
or SymPy). The expression comes up when calculating equations of
motion for a bicycle using PyDy (http://www.pydy.org/
), you actually
need a Jacobian, but this is just one element of it.
And Sage seems 6x slower. The benchmark is here:
, it's the kane3.py. It
should be pointed out that Sage might arrange the final expression a
bit differently, so a meaningful benchmark is to do the whole bicycle
application, not just one derivative.
But so far my experience has been that SymEngine is faster than Sage
(sometimes significantly, I think 6x is a good speedup) and if you
find some application or a case when Sage is faster, please let me
What is the best way to maintain a package like this for Sage --- we
currently create an spkg, but I read somewhere that spkgs will be
deprecated? Right now we want to maintain it ourselves and make it
easy for people to try out and if enough people like it, we can start
discussing more how to make Sage use it by default.
As I said, that is my long term goal, but it is a lot of work. If
successful though, users and developers of Sage can then contribute to
it and then anybody else who uses SymEngine outside of Sage will
immediately benefit, and vice versa. And by being in C++, not just
Python users will benefit, since the main development is done in C++.
There are lots of people in Ruby, Julia, even Haskell who ask for a
symbolic package. And this can be it.
The C++ code is truly cross platform, we test every commit with
gcc/clang on linux, gcc/apple clang on OS X and MSVC/mingw on Windows.
I also test manually with Intel and PGI compilers. See here for more
There will be bugs that you might discover during building it, but
they can be fixed if you report them. Inherently it should build using
any recent C++11 compiler on any platform.
If you try it out, we would be interested in any feedback, both
positive and negative. Isuru has spent most of the summer making it
working well with Sage and improving the code overall. And several
other GSoC students have been working on it as well.