11
$\begingroup$

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:

  1. Naive method:

    NIntegrate[1/((x (x - 2)))^(1/3), {x, -5, 5}]

6.28841 - 2.23957 I

Warning occurs.

  1. 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.

  1. 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$?)

$\endgroup$

2 Answers 2

14
$\begingroup$

Note that

{x, x1, x2, x3,..., xn}

describes a path in the real or complex domain, and the order matters. So

{x, -5, 2, 0, 5}]

integrates from x == -5 to x == 2 (passing a singularity), from x == 2 back to x == 0, and then from x == 0 to x == 5 (passing another singularity).

For

{x, -10, 0, 10}, {y, -10, 0, x, 10}

I use

{x, -10, 0, 10}, {y, -10, Min[0, x], Max[0, x], 10}

NIntegrate does fine when x == 0 and Min[0, x] == Max[0, x] == 0. You can also use Exclusions -> {x == 0, y == 0, y == x}.

$\endgroup$
1
  • $\begingroup$ Thanks for your answer! I think your suggestion is how I should proceed my problem. $\endgroup$
    – eigenvalue
    Jan 19 at 6:57
11
$\begingroup$

we observe that the order of singularity points matters.

To avoid this, use the Exclusions option instead of listing them in order. Now the order does not matter any more since it is a list and not a sequence. From help on Exclusions

Specify the location of the singularity to handle it with appropriate transformations:

NIntegrate[1/((x (x - 2)))^(1/3), {x, -5, 5}, Exclusions -> {2, 0}]

Mathematica graphics

NIntegrate[1/((x (x - 2)))^(1/3), {x, -5, 5}, Exclusions -> {0, 2}]

Mathematica graphics

Both give same result and no warning.

$\endgroup$
2
  • $\begingroup$ Thanks for your answer. I have a further question: does this method also work for LocalAdaptive method? As far as I know, if one gives Exclusions option in LocalAdaptive method, the Mathematica automatically changes to GlobalAdaptive method. (By the way, it seems that my integrand can be computed efficiently for LocalAdaptive method.) $\endgroup$
    – eigenvalue
    Jan 19 at 3:33
  • 2
    $\begingroup$ @eigenvalue I really do not know as I have not used these methods. But may be this could be made a separate question. It is up to you. $\endgroup$
    – Nasser
    Jan 19 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.