- Find the following integral.

```
\int_0^1\dfrac{1}{1+x^2}~dx
```

- The actual solution is $ \ pi / 4 = 0.78539816339 ... $

- SciPy scipy.integrate.quad Is used.

- Script

`sample.py`

```
from scipy.integrate import quad
answer, abserr = quad(lambda x: 1/(1+x**2), 0, 1)
print answer
```

- Execution result

```
> python sample.py
0.785398163397
```

Recommended Posts