Integration

In this lesson, we will learn about definite and indefinite integrals of single and multiple integrations.

Integration is one of the two main operations of calculus, with its inverse operation, differentiation, being the other. Given a function ff of a real variable xx and an interval [a,b][a, b] of the real line, the definite integral is denoted as:

abf(x) dx\int_{a}^{b} f(x) \space dx

Integrals are calculated with the integrate() function. SymPy implements a combination of the Risch algorithm and an algorithm for computing integrals based on Meijer G-functions. These allow SymPy to compute a wide variety of indefinite and definite integrals.

Indefinite integrals #

Integration uses syntax similar to differentiation. For the indefinite integral, we specify the function and the variable with respect to which the integration is performed.

integrate(y, x)

The integrate() function does not add the constant of integration in the indefinite integral.

Let’s see an example of integrating a polynomial below:

Press + to interact
from sympy import *
def f(x):
return (x**2 + x)
x = Symbol('x')
print(integrate(f(x), x))

SymPy allows for a range of integrals. Let’s see them one by ...