Numerical Integration of a singular function

I have a following function: $$f(r)=\int_{r}^{\infty}\frac{g(y)\mathrm{d}y}{\sqrt{y^2-r^2}}~,$$ where $g(y)$ is a continuous function and $g(r)\neq 0$ and $g(r\rightarrow\infty)=0$. Now, in reality I do not have a full functional form for $g(y)$: all I have is data points $g(y_i)$ for $y_i\epsilon (r, \infty)$. And I need to estimate $f(r)$ based on the data points $g(y_i)$. Assuming an equal separation of $y_i$, so that $\Delta y=y_{i+1}-y_i$ for all $i$, the approach is carrying out summation: $$f(r)\approx \Delta y\sum_{i}\frac{g(y_i)}{\sqrt{y_i^2-r^2}}~.$$ However, there is a problem in the summation, as the term $g(y_i=r)/\sqrt{(y_i=r)^2-r^2}$ is divergent. Is there any way to fix this issue, given that I do not have closed functional form of $g(y)$ but just the data points?

• Do you know anything about $g(y)$ near $y=r$? E.g. if it is (more or less) constant when $r \le y \le 2r$, then you can calculate the integral explicitly between those points and start your sum at $2r$. Oct 28, 2017 at 3:40

We can get rid of the problem at $y=r$ and change the integral over an infinite domain to a finite one using the substitution $y=r\sec(u)$: \begin{align} \int_r^\infty\frac{g(y)\,\mathrm{d}y}{\sqrt{y^2-r^2}} &=\int_0^{\pi/2}g(r\sec(u))\sec(u)\,\mathrm{d}u\\ \end{align}