Table of Contents

Example


In [3]:
try:
    from sympy import init_session
except:
    !pip3 install sympy
    from sympy import init_session

init_session(use_latex='matplotlib')


IPython console for SymPy 1.5.1 (Python 3.7.7-64-bit) (ground types: python)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
>>> init_printing()

Documentation can be found at https://docs.sympy.org/1.5.1/


In [4]:
# https://github.com/AeroPython/Taller-Aeropython-PyConEs16
expr = cos(x)**2 + sin(x)**2
expr


Out[4]:

In [5]:
simplify(expr)


Out[5]:

In [6]:
expr.subs(x, y**2)


Out[6]:

In [7]:
expr = (x + y) ** 2
expr


Out[7]:

In [8]:
expr = expr.expand()
expr


Out[8]:

In [9]:
expr = expr.factor()
expr


Out[9]:

In [10]:
expr = expr.integrate(x)
expr


Out[10]:

In [11]:
expr = expr.diff(x)
expr


Out[11]: