# Calling Integrate with many limits of integration

I accidentally discovered that you can put many numbers into the limits of integration of Integrate and Mathematica will still evaluate it without returning an error message:

Integrate[x^2, {x, 0, 46, 53, -1, 2}]


returns 8/3. Mathematica seems to ignore all the numbers except for the first and last ones. Do the middle numbers ever affect the result in some way that I haven't noticed, or are they completely irrelevant? I don't see anything in the documentation about this.

Update: The same thing happens with NIntegrate. Trace doesn't help, but it appears that Mathematica is evaluating each integral connecting consecutive bounds of integration in the list. The integral takes longer to calculate when you add in extra numbers into the limits list, and

Integrate[1/x, {x, 1, -1, 2}]


returns

Integrate::idiv: "Integral of 1/x does not converge on {1,-1}"


even though the integral converges if you ignore the intermediate numbers.

Update 2: The behavior appears to have something to do with specifying integration contours.

Integrate[1/x, {x, -1, I, 1}]


returns -I Pi while

Integrate[1/x, {x, -1, -I, 1}]


returns I Pi.

## 1 Answer

As you have now apparently surmised, this is actually a way to specify piecewise linear contours in the complex plane. It's in the docs, but in a not very prominent spot.

A less trivial example might be to use Cauchy's integral formula to evaluate the Fibonacci numbers, using a square contour centered at the origin:

Table[Integrate[z^-n/(1 - z - z^2), {z, 1/2, I/2, -1/2, -I/2, 1/2}]/(2 π I),
{n, 5}] // FullSimplify
{1, 1, 2, 3, 5}

• Good eye - that's an extremely not-very-prominent spot ... – tparker Mar 29 '16 at 7:03
• Also, your example doesn't really need a specified contour at all - you can just do Table[Residue[z^-n/(1 - z - z^2), {z, 0}], {n, 5}] :) – tparker Mar 29 '16 at 7:09
• Yes, Residue[] would be the more readable procedure (and SeriesCoefficient[] the most convenient); since you were asking about Integrate[], I brought out one of my usual examples. This is another one. – J. M.'s technical difficulties Mar 29 '16 at 7:15