Introduction

A brief introduction to SymPy.

We'll cover the following

In symbolic computation, we process generic variables instead of numerical calculations. Symbolic computation might be slow when compared to numeric computation, but it is a powerful tool for symbolic work that forms the basis for simulations of numeric code.

Introduction #

SymPy is a Python library for symbolic mathematical calculations.

SymPy is an open-source computer algebra system written in pure Python. It is built with a focus on extensibility and ease of use, through both interactive and programmatic applications. These characteristics have led SymPy to become a popular symbolic library for the scientific Python ecosystem.

SymPy enables simple symbolic arithmetic calculations and representations as well as differential and integral calculus, algebra, discrete mathematics, and quantum physics. The results are output upon request in the text system language TeX.

Importing SymPy #

The following statement imports all SymPy functions into the global Python namespace:

from sympy import *

or we can import it using the statement we have been using previously:

import sympy as sym

Usually when scientists and engineers are working with symbolic algebra, they tend to use the first import statement because they work exclusively with the sympy library.

Get hands-on with 1400+ tech skills courses.