Numerical integration with divergent bounds I have an ugly numerical function $f(x)$ that diverges at the boundaries $x_a$ and $x_b$, but I want to calculate the integral,
$$\int_{x_a}^{x_b} f(x) dx$$
For physical reasons I know that the integral needs to be convergent, but I don't know how to calculate it.

I have a series of values $g_1, g_2, ..., g_n$ corresponding to points $x_1, x_2, ..., x_n$.  This is a smooth function which I can spline interpolate to be $g(x)$. This function is zero at the points $g(x_a) = g(x_b) = 0$ --- in particular it changes sign at these points, with $g(x_a < x < x_b) > 0$.  
The function I need to integrate is $f(x) = 1/\sqrt{g(x)}$, which then diverges at $x_a$ and $x_b$.

edit:
My initial approach was to divide the region $[x_a,x_b]$ into three regions, $R_1:[x_a,x_a + \delta]$, $R_2:[x_a + \delta, x_b - \delta]$, $R_3:[x_b - \delta, x_b]$ and break each of these regions into $n$ intervals.  Region $R_2$ is very well behaved, and I can easily calculate the integral using a Riemann sum with something like $n = 100$ segments.
To evaluate the accuracy of my integrals over the boundary regions, I compared left and right Riemann sums.  As I decreased $\delta$, however, the difference between my Riemann sums diverged.
 A: 
I have an ugly numerical function $f(x)$  that diverges at the boundaries $x_1$   and $x_ 2$ 

For integrating this functions use a well-known numerical integration method (e.g. Simpson approximation), but for the Region in which the integral diverges, you can choose more coarse discretization intervals. That means you have a large number of interval subdivisions in the interior of the integral, but near boundary you can use very few subdivisions to "average out" your divergences.
A: A specific formula for $f(x)$ is needed before the question can be answered. Take for example $$\int_1^2\dfrac{x}{\sqrt{x^3-1}}\mathrm d x.$$ This doesn't have a closed-form formula for its value. If you try to integrate it numerically, you have a problem, because the function is unbounded at the lower limit. However, a substitution $x=\sec^{2/3}\theta$ converts this "improper" integral into a proper one: $$\dfrac23\int_0^{\arccos(1/\sqrt8)}\dfrac{1}{\cos^{4/3}\theta}\mathrm d\theta,$$ which has a bounded argument and is easily amenable to numerical integration. Perhaps your function $f$ will allow a similar trick with a suitable substitution.
