Q8.2.3Evaluating \(\pi\) by direct integration
Use scipy.integrate.dblquad to evaluate \(\pi\) by integration of the constant function \(f(x,y)=4\) over the quarter circle with unit radius in the quadrant \(x>0\), \(y>0\).
Show solution
This is a simple application of dblquad:
In [x]: from scipy.integrate import dblquad
In [x]: dblquad(lambda y, x: 4, 0, 1, lambda x: 0, lambda x: np.sqrt(1-x**2))
Out[x]: (3.1415926535897922, 3.533564552071766e-10)