SymEngine: Leveraging The Power Of A Computer Algebra System (CAS) To Another

Shikhar Jaiswal (~ShikharJ)


13

Votes

Description:

Abstract

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 C++ over Python, in speeding up the computations performed by the SymPy core. Using SymEngine's Python wrapper, 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 Mathematica, SymPy, GiNaC and Maple), and a heavier explanation on examples of usage of the C++ library in Python with SymPy CAS, Sage CAS and PyDy multi-body dynamics toolkit. Wrappers to other languages (C, Ruby, Julia and Haskell) are also available.

The Details

Motivation

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 Julia, Ruby, JavaScript or C++, because it requires, say, a Python to Julia bridge, which might not always be robust and which inflicts additional overheads.

Methods

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), Ruby, Julia, Haskell and C.

Results

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 SymPy, Sage and PyDy software (all three being Python based software). Detailed examples will be presented on various mathematical functionalities implemented, through SymPy and 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 Python and 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 SymEngine.

The library already has 46 contributors, 151 forks and 254 stars on GitHub, as of July 12, 2017.

Conclusion

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 SymPy, Sage, PyDy ...) can use as their main symbolic engine and all contribute back to it.

Prerequisites:

  • Basic knowledge of Python and C++ languages.
  • Basic mathematics, just enough to appreciate the manipulations done preferred.

Content URLs:

Resources

Contents of presentation prepared by the SymEngine team, along with the respective IPython/Jupyter notebooks can be found in this Github repository.

The presentation slides can be directly viewed here.

Few Extra Links:

Speaker Info:

Shikhar is currently a second year undergraduate at IIT Patna, majoring in Computer Science and Engineering. He is a contributor to SymPy, SymEngine as well as SymEngine.py. He is currently pursuing his Google Summer of Code 2017 project for SymEngine titled 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 IIT Bombay. 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 SymEngine for GSoC 2016, he has also successfully completed GSoC 2015 project for SymEngine under Python Software Foundation. Sumith has also collaborated research at EPFL, Switzerland, birth place of the Scala functional programming language and University of Washington, USA.

Speaker Links:

Shikhar Jaiswal

You can also reach out to me on Facebook.

Sumith Kulal

You can even reach me on Facebook. My blog lives here.

Section: Scientific Computing
Type: Talks
Target Audience: Beginner
Last Updated: