SymPy – Introduction & Installation

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible.

Audience

This tutorial is designed for python programmers who would like to get introduced to the symbolic mathematics including basics of symbolic computing, basic symbolic operations, calculus, matrices and some select advanced topics.

Prerequisites

Before proceeding with this tutorial, you should have a good understanding of python programming language. This tutorial assumes a decent mathematical background. Most examples require knowledge lower than a calculus level, and some require knowledge at a calculus level.

Introduction

SymPy is a Python library for performing symbolic computation. It is a computer algebra system (CAS) that can be used either as a standalone application, as a library to other applications. Its live session is also available at https://live.sympy.org/. Since it is a pure Python library, it can be used as interactive mode and as a programmatic application. SymPy has now become a popular symbolic library for the scientific Python ecosystem.

SymPy has a wide range of features applicable in the field of basic symbolic arithmetic, calculus, algebra, discrete mathematics, quantum physics, etc. SymPy is capable of formatting the results in variety of formats including LaTeX, MathML, etc. SymPy is distributed under New BSD License. A team of developers led by Ondřej Čertík and Aaron Meurer published first version of SymPy in 2007. Its current version is 1.5.1.

Some of the areas of applications of SymPy are −

  • Polynomials
  • Calculus
  • Discrete maths
  • Matrices
  • Geometry
  • Plotting
  • Physics
  • Statistics
  • Combinatorics

Installation

SymPy has one important prerequisite library named mpmath. It is a Python library for real and complex floating-point arithmetic with arbitrary precision. However, Python’s package installer PIP installs it automatically when SymPy is installed as follows −

pip install sympy

Other Python distributions such as Anaconda, Enthought Canopy, etc., may have SymPy already bundled in it. To verify, you can type the following in the Python prompt −

>>> import sympy
>>> sympy.__version__

And you get the below output as the current version of sympy −

‘1.5.1’

Source code of SymPy package is available at https://github.com/sympy/sympy.

Leave a Reply