# 1/x integration giving 0 instead of infinity [duplicate]

I stumbled across the fact this integral:

Integrate[1/y, {y, 0, 1}, GenerateConditions -> False]


returns

0


Anybody understand why this is zero and not divergent? Is "GenerateConditions" doing something weird?

• We do not put the bugs tag into questions until your observed behavior has been confirmed by others as a bug. – J. M.'s ennui Aug 12 '15 at 11:35
• Anyway: what does Integrate[1/y, {y, 0, x}, GenerateConditions -> False] return? – J. M.'s ennui Aug 12 '15 at 11:37
• Well, that at least explains the $0$ result… – J. M.'s ennui Aug 12 '15 at 11:49
• I don't understand completely, but GenerateConditions turns off some checking. In particular, it turns off the step that checks convergence. What I don't understand is why it throws out the limit at 0 -- it calculates it, gets -Infinity and then seems to remove the singular part. Reminds me of something my roommate in grad school, who was in physics, said about one of his classes: whether the integral came out 0 or Infinity, in both cases the result was negligible. I don't really have a complete answer, but may it will be easier to discuss it in an answer... – Michael E2 Aug 12 '15 at 12:30
• If your goal with GenerateConditions -> False is to get rid of ConditionalExpression, consider using Normal instead. – Szabolcs Aug 12 '15 at 17:15

Summary: Setting GenerateConditions -> False turns off safety checks. In my opinion, when the user does that and the result is erroneous, I would not call that a bug. Now WRI could decide to improve Mathematica in this case, but it might not be such a simple matter. On the other hand, it is entirely up to the user to decide whether or not he or she is satisfied with such limitations. The analysis below shows that Mathematica does "plug in" y == 0 and gets -Infinity: I think it would be an easy matter to be able to emit a message about possible divergence and suggest using the option GenerateConditions -> True. See also When to use GenerateConditions -> True and What exactly does GenerateConditions do?.

From How much time should one give Mathematica for an integral evaluation?, one can monitor the progress of Integrate by setting

InternalIntegratedebugSwitch = 10


The output is mainly inscrutable and for internal use at WRI, but if you've ever been able to read a mathematical paper in a language you don't understand, you can pick out important points now and then.

In a single integral, GenerateConditions -> Automatic is equivalent to GenerateConditions -> True. One of the differences between

GenerateConditions -> False
GenerateConditions -> True


is that the False setting turns off convergence testing. If we set debugSwitch = 10, we get Print statements in the output at various steps as Integrate figures out the integral. After 11 initialization steps, we see that there is a branch (after the last "start main' statement). The computation with GenerateConditions -> True enters the "exception locus" routine, which ultimately determines the integral diverges. The OP's integral enters "SimpPredicates", which sounds like a simplified check of the integrand; it is followed by a "dispatcher" which calls "Simpdispatcher", which again sounds like a simplified integrator.

Block[{InternalIntegratedebugSwitch = 10},
Integrate[1/y, {y, 0, 1}]
]


Block[{InternalIntegratedebugSwitch = 10},
Integrate[1/y, {y, 0, 1}, GenerateConditions -> False]
]


As one scrolls through the output of the GenerateConditions -> False computation, one sees that Log[y] is found to be the antiderivative. Its limit is taken as y -> 1 from below; and then the limit is taken as y -> 0 from above:

After this point, I do not have a clear idea of what happens. Apparently dissatisfied with -Infinity, Integrate essentially computes Series[Log[y], {y, 0, 2}]:

It is not clear from the output what is done with this result. A very few steps after, the Log[y] disappears and the result 0 appears; after several simplification steps, 0 is the answer.

The same thing happens when 1/y^2 is integrated. Different things happen when the integrand is 1/(1 + y^2), which should be expected. Integrate is quite complicated.

If you know that for multivariable integrals, GenerateConditions -> Automatic means that the inner integral(s) will be computed with the setting GenerateConditions -> False and the outer integral is integrated with the setting GenerateConditions -> True, you should be able to predict the difference in these two integrals:

Integrate[1/y, {y, 0, 1}, {x, 0, 1}]
Integrate[1/y, {x, 0, 1}, {y, 0, 1}]


The second result might be considered a bug, I suppose. (I'm not sure who would have predicted the unnecessary second message, although you might infer why.)

If one adds the option GenerateConditions -> True to the last integral, one gets the expected divergence message (and only once):

Integrate[1/y, {x, 0, 1}, {y, 0, 1}, GenerateConditions -> True]


• "when the user does that and the result is erroneous, I would not call that a bug" - pretty much why I removed the initial bugs tag; I think of it like the safety mechanism on a rifle. Disable it if and only if you know what you're doing. – J. M.'s ennui Aug 12 '15 at 13:38
• @J. M. Then should Mathematica not generate a warning that its answer might be wrong? – Calchas Aug 12 '15 at 17:08
• @Calchas, it's on by default, which is where the usual warnings come from. Since you've explicitly told Mathematica not to warn you… ;) – J. M.'s ennui Aug 12 '15 at 17:11
• @Szabolcs, I'd concur that the double integral example looks to be a bug, but ever since GenerateConditions became built-in, I was always of the philosophy that it's not something you shut off unless you're absolutely sure of what you're doing. So, if the calculus functions suddenly take wrong limits in that case, I'd say it's a classical case of GIGO. – J. M.'s ennui Aug 12 '15 at 17:29
• GenerateConditions is a seriously overloaded option. Meanings include "check hard for convergence", "check for parameter provisos needed to make the result correct", "check for singular points along the integration path", "explicitly allow (or even assume) cancellation of singular parts of the integral". I'd say it is this last one at work in the example shown here. – Daniel Lichtblau Aug 16 '15 at 17:26