Is there a way to deal with this singularity in numerical integration?
I would like to compute numerically, e.g., using the standard method of trapezes the following definite integral over the interface $[0,1]$:
$$
I = \int_0^1 \frac{f(x)}{\sqrt{1-x^2}} \, \mathrm{d} x \, ,
$$
where $f(x)$ is continuous in the interval [0,1].
It can readily be shown analytically that the integral is well convergent.
However, when proceeding numerically, difficulties arise since the integrand diverges at the upper limit of integration for $x=1$.
I was wondering whether there exists a procedure that can help to remove the singularity in this integral. Any help is highly appreciated
Thank you,
hartmut
It's easy to convert your integral into one without any singularities via the substitution $x=\sin\theta$: $$I=\int^{\pi/2}_0f(\sin\theta)\,d\theta.$$ If you're lucky to have a function $f$ that is even (so that $I$ is just a quarter of the integral over the full period, from $-\pi$ to $\pi$), you might be pleasantly surprised by the speed of convergence of the trapezoidal rule in this special situation.
A general technique is to remove the singularity by moving it to an analytically integrable function:
$$\int_0^1\frac{f(x)}{\sqrt{1-x^2}}dx=\int_0^1\frac{f(x)-f(1)+f(1)}{\sqrt{1-x^2}}dx=-\int_0^1\frac{f(x)-f(1)}{\sqrt{1-x^2}}dx+f(1)\left.\arcsin(x)\right|_0^1.$$
The limit of the integrand at $x=1$ should be finite.
For instance with $f(x):=x$,
$$\frac{x-1}{\sqrt{1-x^2}}=-\sqrt{\frac{1-x}{1+x}},$$ which is well-behaved.