# Numerical integration - Techniques to remove singularities

1. Mar 30, 2013

### franciobr

Hello everyone!

I am trying to understand why the following function does not provide problems to being computed numerically:

∫dx1/(sin(abs(x)^(1/2))) from x=-1 to x=2.

Clearly there is a singularity for x=0 but why does taking the absolute value of x and then taking its square root solve the problem?

I searched for quite a while on the internet and on numerical integration books and was surprised that I couldn't find the answer for that. Apparentlly there is a lack of documentation on singularity removal techniques on the web or I am not searching with the right keywords. Any introductory documentation on the subject is welcome!

For the record I am using matlab built-in functions such as quadtx() or integral() to solve it but I that's not the point since it turns out even the most simple simpson rule algorithm can deal with that integral.

2. Mar 30, 2013

### SteamKing

Staff Emeritus
Just because you get a certain number out of a numerical routine does not mean it is accurate. Convergence for a particular definite integral containing a singularity within the limits of integration must be shown using other analysis methods before judging whether the resulting evaluation has any meaning.

3. Mar 30, 2013

### franciobr

Yes. The result is accurate since if you exclude the singularity by simply integrating from -1 to 0 and then from 0 to 2 and sum them up the answer is exactly the same. I do not know how to analytically solve this integral and, well, that's the whole point of numerical integration.

I dind't mention that if you try to take the integral without taking the absolute value or the square root you get no answer and there is no convergence of the method. I am interested on why quadrature methods of integration converges on these cases. I am not interested on that particular integral, if you do the same with 1/x kinds of functions and integrate it going through its singularity on 0 you get convergence for the same methods of integration and they agree with analytical results. There is a reason why taking taking a square root and the absolute value of the denominator the numerical methods converges.

The absolute value application seems logical since you dont want a imaginary number coming out of the square root. But the convergence of the method is what astonishes me. I would like to know why there is the convergence and also if anyone has a good source for these techniques of excluding singularities for numerical integration.

4. Mar 30, 2013

### AlephZero

It's fairly easy to see that the integral is convergent. Expand the function as a power series and you get $$\frac{1}{|x|^{1/2}} \frac {1}{1 - |x|/3! + |x|^2/5! - \cdots}$$

So close to $x = 0$ the function is similar to $|x|^{-1/2}$ which can be integrated everywhere.

If you want to remove the singularity before you do the numerical integration, one way is to write the function as $f(x) = s(x) + g(x)$ where the $s(x)$ contains the singular part and can be integrated explicitly.

Then integrate $s(x)$ analytically and $g(x)$ numerically.

For this example you could take $s(x) = |x|^{-1/2}$ and $g(x) = f(x) - s(x)$ (where $f(x)$ is the function the OP wants to integrate).

You know that $g(0) = 0$ and $g(x)$ is well behaved near $x = 0$, so any numerical integration method should converge quickly.

Last edited: Mar 30, 2013
5. Apr 3, 2013

### franciobr

Good job Aleph, it makes sense now. Thanks!