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
.