Consider the following integral:
$$I = \int_{-5}^5 \frac{1}{(x(x-2))^{1/3}} dx.$$
The exact value is 6.30249 - 2.2405 I
. I will perform NIntegrate
in 3 different ways:
Naive method:
NIntegrate[1/((x (x - 2)))^(1/3), {x, -5, 5}]
6.28841 - 2.23957 I
Warning occurs.
Singularity handling with correct order
NIntegrate[1/((x (x - 2)))^(1/3), {x, -5, 0, 2, 5}]
6.30249 - 2.2405 I
No warning occurs, and the result is the most accurate.
Singularity handling with wrong order
NIntegrate[1/((x (x - 2)))^(1/3), {x, -5, 2, 0, 5}]
6.29582 - 2.2454 I
Warning occurs.
From this observation, we observe that the order of singularity points matters. Is this phenomenon general, so that the intermediate singular points $\{x_1,\ldots, x_n\}$ should be given with $x_1<\cdots <x_n$?
Another question is about a double integral. Suppose that an integrand has a singularity at $x=0$, $y=0$, and $x=y$. In this case, we cannot give the singular point information in the right order! For example, assuming the integration range to be $[-10,10]\times [10,10]$,
{x, -10,0,10}, {y,-10, 0, x, 10}
does not work since it is not necessarily true that $0<x$. In this case, what should I do? (Divide the region? Then how about integration on $\mathbb R^n$, where the integrand is singular on $x_i=0$ and $x_i=x_j$?)