from sympy import * # fine for scripts/notebooks import sympy as sp # safer in a package x, y, z = symbols('x y z') # Symbols must be DECLARED n, k = symbols('n k', integer=True) f, g = symbols('f g', cls=Function) t = Symbol('t', positive=True) init_printing() # pretty output in a notebook
symbols('x y z')Space- or comma-separated. Returns a tuple.symbols('a0:5')Ranges:a0, a1, a2, a3, a4.from sympy.abc import x, yShortcut for the obvious single letters.Function('f')An undefined function —f(x).diff(x)stays symbolic.
Gotchafrom sympy import * shadows built-ins — notably abs, pow, sum, and lambda-adjacent names. Fine in a notebook; use import sympy as sp in library code.