To begin with, let's elaborate on the previous example in SymPy and explain the steps.
First, we have to import the module:
from sympy import *
init_printing()
The second command makes sure that formulas are presented in a graphical way, if possible. Then, we generate a symbol and define the integrand:
x = symbols('x')
f = Lambda(x, 1/(x**2 + x + 1))
x is now a Python object of type Symbol and f is a SymPy Lambda function (note the command starting with a capital letter).
Now we start with the symbolic computation of the integral:
integrate(f(x),x)
Depending on your working environment, the result is presented in different ways; see the following screenshot (Figure 16.2), which represents two different results of a SymPy formula in different environments:
Figure 16.2: Two screenshots of a SymPy presentation of formula in two different environments
We can check by differentiation...