SymPy: Doing your homework for you

SymPy is the foremost symbolic computation library for Python. It is a powerful and fast computer algebra system. See the Sympy Tutorial for a more detailed introduction.

Creating symbols

Symbols are created with the sympy.Symbol() constructor or the sympy.symbols() method.

Operations on symbols

Symbols can generally be treated as numbers with the basic operations +-/*, but math functions have to be from SymPy.

As you can see, SymPy is pretty smart about its simplifications! It will apply various common identities to decrease the number of terms.

Substituting symbols

As all symbolic computation libraries do, SymPy allows you to substitute in numerical values for symbols

Matrices

SymPy supports a variety of matrix operations, though for numerical purposes it is much slower than NumPy.

SymPy can calculate matrix exponentials without diagonalizing:

SymPy can also perform many linear algebra matrix decompositions, including the LU, QR, and Cholesky decompositions. Some things you can do are found in the documentation.

Differential Equations

SymPy can solve ODEs in the form g(f, f', ...) = 0.

Laplace Transforms

SymPy can perform Laplace transforms and invert them too.