Integrate

SciPy

SciPy is a fundamental library for scientific computing (see scipy.org). The documentation of scipy.integrate submodule and the quad function can be found here.

Example: Calculate $\int_0^1 x^2\,\mathrm{d}x$.

Recall: A lambda function is a small anonymous function, which can only have one expression as a return value.

SymPy

SymPy is a Python library for symbolic mathematics. A tutorial for this module and for the integrals can be found here and here.

Example: Calculate $\int x^2\,\mathrm{d}x$ and $\int_0^1 x^2\,\mathrm{d}x$.