Make a note about SymPy¶
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. SymPy is written entirely in Python.
from sympy import Symbol, lambdify def Unit(x): if(x != 0): return 0 else: return 1 x = Symbol('x') x
fx = x**2 + Unit(x) fx
lam_f = lambdify(x, fx, modules=['sympy']) lam_f
print(lam_f(-1)) # prints 1