# Numerical Integration

For $r=1$, how to calculate the following integral numerically.

$$\frac{8}{\sqrt{3}r^2}\int_{x=0}^{\frac{r}{2}}\int_{y=0}^{\sqrt{3}(\frac{r}{2}-x)}\prod_{i=0}^2\left(1-\frac{2}{\pi} \cos^{-1} (\frac{d_i}{2r}) + \frac{d_i}{2\pi^2 r}\sqrt{4r^2-d_i^2}\right)I_{(0,2r)}(d_i),$$ where $d_i$ are the distance between the point $B$ and $A_i$ for $i=0,1,2$ and the coordinates of $B$ and $A_i$'s are $(x,y),~(0,\frac{\sqrt{3}r}{2}),~ (0,-\frac{\sqrt{3}r}{2}),~(0,\frac{3\sqrt{3}r}{2})$ respectively.

$I_{(0,2r)}(d_i)$ is 1 if $d_i \leq 2r$ else $0$.

-
Ouch, that's disgusting. Have you looked into things like the midpoint method, or Simpson's method? – Robert Mastragostino May 22 '12 at 4:41
Just a cursory look; can you subdivide the domain analytically so that the integrand is continuous within each partition? Removing discontinuities in this manner will significantly speed up whichever method you use. – dls May 22 '12 at 4:52
Yes, I have tried Trapezoidal method. I know for single integration. What should be the approach for double integration? – user12290 May 22 '12 at 5:34
Apply integration two times? For double integrals it still will be fast. If you are interested in an exact code, specify the language. Is this integral from molecular physics? – Yrogirg May 22 '12 at 6:19
I can solve the problem. No, it is not from molecular physics. – user12290 May 24 '12 at 4:35