SymEngine: Leveraging The Power Of A Computer Algebra System (CAS) To Another
Shikhar Jaiswal (~ShikharJ) |
SymPy is a pure Python library for symbolic mathematics. It aims to become a full-featured Computer Algebra System (CAS) which is comprehensible and easily extensible.
SymPy is written entirely in
Python and does not require any external libraries.
The primary goal of
SymEngine as a CAS is to utilize the performance improvement of
Python, in speeding up the computations performed by the
SymPy core. Using
SymEngine.py, we aim to completely replace the
SymPy core with that of
SymEngine, keeping the changes minimal and the ensuring code integrity, while greatly speeding up the computations and expression handling.
We will present a short talk on the current status of development, how things are implemented internally, how we chose the language of development, benchmarks with other well known Computer Algebra Systems (such as
Maple), and a heavier explanation on examples of usage of the
C++ library in
Sage CAS and
PyDy multi-body dynamics toolkit. Wrappers to other languages (
Haskell) are also available.
SymPy is a widely used symbolic manipulation library in
Python. While it turns out to be very useful for many applications, one of the long-term problems with
SymPy has been that the speed might be insufficient while handling very large expressions. Another problem is that due to being written in
Python, it can be cumbersome to use from other languages like
C++, because it requires, say, a
Julia bridge, which might not always be robust and which inflicts additional overheads.
For these reasons, we implemented
SymEngine, an open-source
C++ symbolic manipulation library, with the goal of being the fastest library for symbolic manipulation, and allowing the use to other languages like
Python (the most mature wrapper),
We will show benchmarks comparing other popular Computer Algebra Systems (both open-source and commercial).
We will talk about why we chose
C++ and what rules to follow so that the code cannot have an undefined behavior in Debug mode (thus providing similar ease of development as one is used to from
Python), while being blazingly fast in Release mode.
The talk will focus heavily on
SymEngine's use in
PyDy software (all three being
Python based software). Detailed examples will be presented on various mathematical functionalities implemented, through
SymEngine created objects, as well as the details of our use of
Cython language (not to be confused with
CPython) in wrapping
C++ data structures and creating
Cython classes as per the requirements. Some amount of time will also be devoted to the issues faced, and the solutions implemented while wrapping off the library in
Python. We will also present a road-map portraying the present as well as previous strategies on porting
SymPy on top of
The library already has 46 contributors, 151 forks and 254 stars on
GitHub, as of July 12, 2017.
SymEngine should fix the slowness of
SymPy, while providing a familiar interface, and at the same allowing many languages to use it, thus creating a common platform/tool that many projects (like
PyDy ...) can use as their main symbolic engine and all contribute back to it.
- Basic knowledge of
- Basic mathematics, just enough to appreciate the manipulations done preferred.
Contents of presentation prepared by the
SymEngine team, along with the respective
Jupyter notebooks can be found in this
The presentation slides can be directly viewed here.
Few Extra Links:
Shikhar is currently a second year undergraduate at
IIT Patna, majoring in Computer Science and Engineering.
He is a contributor to
SymEngine as well as
He is currently pursuing his
Google Summer of Code 2017 project for
Improving SymEngine's Python Wrappers and SymPy-SymEngine Integration under
SymPy, with Sumith as one of the mentors.
Sumith is currently a fourth year Computer Science undergraduate student at
He is a contributor to
SymPy as well as
SymEngine, currently a mentor of
GSoC 2017 for two projects under the
SymPy organisation. Having previously mentored two successful projects for
GSoC 2016, he has also successfully completed
GSoC 2015 project for
Python Software Foundation.
Sumith has also collaborated research at
EPFL, Switzerland, birth place of the
Scala functional programming language and
University of Washington, USA.