# Incorrect result for Integrate[] over Region

I was doing a calculation that involved integrating rational functions over a triangular region, and eventually noticed some of my results didn't make any sense. After some investigating, I was able to track it down to

Integrate[1/x, {x, y} \[Element] Triangle[{{0, 0}, {1, 0}, {0, 1}}]]

> -1


which is a strange answer. It emits no warnings about nonconvergence, either. Is there some way to work around this issue and help Mathematica alert me when I'm asking to Integrate[] over a region, but the integral doesn't converge?

• Mathematica v12.2 evaluates \[Infinity] Commented Mar 7 at 16:51
• Please don't use the bugs tag: The tag wiki says: "This tag is reserved for questions where the problem has been vetted by this community and the observed behavior is confirmed to be a bug. Please do not use this tag for new questions." That said, if this really does spit out -1, then that is likely a bug. Commented Mar 7 at 17:39
• intg = With[{ϵ = t}, Integrate[ 1/x, {x, y} ∈ Triangle[{{ϵ, ϵ}, {ϵ, 1}, {1, ϵ}}]] ]; intg = FullSimplify[intg, t >= 0] Then you can do Limit[intg, t -> 0]. Your code outputs -1 on MMA 14.0 on windows, so looks like a bug. Commented Mar 7 at 17:41
• I reported this as a bug. Commented Mar 7 at 19:08
• f[ϵ_] := Integrate[ 1/x, {x, y} ∈ Polygon[{{ϵ, 0}, {1, 0}, {ϵ, 1}}], Assumptions -> ϵ > 0]; Limit[f[ϵ], ϵ -> 0] (* ∞ *) I think maybe Mathematica use Legesgue Integral  instead of Riemannian Integral Commented Mar 7 at 23:43

The answer $$-1$$ is strange indeed. I would expect Mathematica to blindly apply consecutive integration to get '' $$\int_0^1 \int_0^x \frac 1x dy \,dx = \int_0^1[y/x]_{y=0}^{y=x}dx = \int_0^1 1 dx = 1$$ '' which is still a wrong result... In fact, the existence of the iterated integrals does not guarantee the existence of the double integral. The other order of integration gives you ''$$\int_0^1\int_0^y \frac 1x dx\,dy=\int_0^1[\log x]_{x=0}^{x=y} \,dy$$''
Depending on your application, a possible remedy could be to use NIntegrate[] instead of Integrate[]. It still gives a bogus final result, but alerts you for possible non-convergence.