How to use scipy. integrate. quad properly?

Viewed 42

I am confused about how to use scipy.integrate.quad properly because I found this :

import numpy as np
import scipy.integrate

def f(x):
 return 1/np.sqrt(np.pi)*np.exp(-x**2)

print(scipy.integrate.quad(f,-np.inf,np.inf))

Then I got 0.99999998 and a small error. That's right. But like this :

print(scipy.integrate.quad(f,-1e4,1e4))

The answer I got is like (1.11468e-203 , 2.2157e-203) which is absolutely wrong. It should be near 1 for this function like before. I want to know why did this happen? How can I use numerical integral properly so that I can avoid this kind of errors? Many thanks!

0 Answers
Related