Skip to main content

Integration

Let's say, we want to perform the following integration:

I=0πsin(x)dxI = \int_{0}^{\pi} sin(x) dx
from scipy.integrate import quad
import numpy as np

# Define the function
def integrand(x):
return np.sin(x)

I = quad(integrand, 0, np.pi)
print(I)

It returns the result and error bound.