Numerical Integration

In this lesson, we will learn about single and multiple integrals using numerical integration.

Numerically integrating a function is a common engineering task. The SciPy module provides a number of functions for integration. A general-purpose tool used to solve integrals like this"


is the quad() function. SciPy provides a series of functions for different kinds of integrations, for example, dblquad for double integration and tplquad for triple integration.

We use the following command to import the relevant functions from the integrate package:

from scipy.integrate import quad, dblquad, tplquad

The quad function takes a large number of optional arguments that can be seen using the help(quad) command.

The input arguments of the quad() function include the integrand f(x) and the limits of integration a and b. quad() returns a tuple with the first value being the numerical result and the second being the estimation of the numerical error in the result.

res, err = quad(f, a, b)

Get hands-on with 1200+ tech skills courses.