
- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
Scipy Multiple Integration (nquad)
Multiple Integration in SciPy
Multiple integration in SciPy is used to calculating the integral of a function over more than one variable i.e., double, triple or higher-dimensional integrals. The scipy.integrate module which provides functions such as dblquad for double integration, tplquad for triple integration, quad for single integration and nquad for integration over multiple variables.
In multiple integration we can define the function to be integrated along with the integration limits for each variable and also any additional parameters. SciPy handles both finite and infinite limits and can integrate complex functions over specified ranges by providing an efficient solution for high-dimensional problems such as physics simulations and probability distributions.
Mathematical Formula for the n-dimensional Integration over a region of D −

The limits of the multiple integration depends on the specific region D in n-dimensional space.
Syntax
Following is the syntax of the function scipy.integrate.nquad() which is used to calculate the multiple integration −
scipy.integrate.nquad(func, ranges, args=None, opts=None, full_output=False)
Parameters
Here are the parameters for the nquad() function of scipy.integrate module −
- func: The function to be integrate. It should take the variables being integrated as individual arguments.
- ranges: A list of limits for each variable's integration given as tuples (a, b) where a and b are the bounds. Use -inf or inf for infinite limits in improper integrals.
- args(optional): Additional arguments to pass to func.
- opts(optional): Integration options for each dimension such as tolerance settings or other parameters for the integrator.
- full_output(optional): If this parameter is True then the extra information about the integration process is returned in a dictionary.
Example of Multiple Integration
This example shows how to use nquad() to perform double integration of a two-variable function over a specified rectangular region. We can modify the integrand and limits as needed for different applications −
import numpy as np from scipy.integrate import nquad # Define the function to integrate def integrand(x, y): return np.sin(x) + np.cos(y) # Define the limits for x and y # x goes from 0 to pi # y goes from 0 to pi/2 ranges = [[0, np.pi], [0, np.pi / 2]] # Perform the double integration result, error = nquad(integrand, ranges) # Output the results print(f"Double Integral Result: {result}") print(f"Error Estimate: {error}")
Following is the output of the calculating the dobule integration with the help of nquad() function −
Double Integral Result: 6.283185307179586 Error Estimate: 6.975736996017264e-14
Example to Perform Double Integration
This example shows how to use nquad() to perform double integration of a two-variable function over a specified rectangular region. We can modify the integrand and limits as needed for different applications −
import numpy as np from scipy.integrate import nquad # Define the function to integrate def integrand(x, y): return np.sin(x) + np.cos(y) # Define the limits for x and y # x goes from 0 to pi # y goes from 0 to pi/2 ranges = [[0, np.pi], [0, np.pi / 2]] # Perform the double integration result, error = nquad(integrand, ranges) # Output the results print(f"Double Integral Result: {result}") print(f"Error Estimate: {error}")
Following is the output of the calculating the double integration with the help of nquad() function −
Double Integral Result: 6.283185307179586 Error Estimate: 6.975736996017264e-14
Example to Perform Triple Integration
Here's an example of triple integration using the nquad() function from the scipy.integrate module in Python. This example will calculate the integral of the function f(x,y,z) = x2+y2+z2 over a specified range for each variable −
from scipy.integrate import nquad # Define the function to integrate def func(x, y, z): return x**2 + y**2 + z**2 # Specify the ranges for x, y, and z ranges = [[0, 1], [0, 1], [0, 1]] # Perform the triple integration result, error = nquad(func, ranges) # Output the result print("Result of the triple integration:", result) print("Estimated error:", error)
Here is the output of the calculating the multiple integration with the help of nquad() function −
Result of the triple integration: 1.0 Estimated error: 2.5808878251226036e-14
Key Features of the nquad() Function
Following are the key features of nquad() of scipy.integrate module −
- The nquad() function handles multiple Integrations of any dimension.
- This function supports variable limits for integration.
- It can pass additional arguments to the integrand function.
- This function perform customizable integration settings via the opts parameter.