Numerical integration of divergent function

Solution 1:

I suppose your function is $f(x) = g(x)/\sqrt{x-\epsilon}$ where $g$ is bounded, and you want to integrate this on $(\epsilon, b)$. The change of variables $x = \epsilon + t^2$ gives you $$ \int_\epsilon^b \dfrac{g(x)}{\sqrt{x-\epsilon}}\; dx = 2 \int_0^{\sqrt{b-\epsilon}} g(\epsilon + t^2)\; dt$$ which gets rid of the singularity. Similarly to integrate $g(x)/\sqrt{\epsilon - x}$ on $(a,\epsilon)$, use $x = \epsilon - t^2$.