# Integrating twice gives a different result than a double integral

I would like to compute the following double integral: $$\int_{-1/2}^{0}\int_{-v}^{1+v} \frac{2}{1-(u^2-v^2)} dudv = \frac{\pi^2}{12}$$ When I do this using using

Integrate[2/(1 - (u^2 - v^2)), {v, -1/2, 0}, {u, -v, 1 + v}]

π^2/12


the result is $$\pi^2/12$$ as expected (It took me a while to figure out the strange convention that the first argument to Integrate is the outer variable).

However when I try to do the calculation in two steps like

Integrate[2/(1 - (u^2 - v^2)), {u, -v, 1 + v}, GenerateConditions -> False]

-((2 (ArcTan[v/Sqrt[-1 - v^2]] + ArcTan[(1 + v)/Sqrt[-1 - v^2]]))/Sqrt[-1 - v^2])

Integrate[ %, {v, -1/2, 0}]

1/12 (π^2 + 3 ArcCosh[7/2] ArcCsch - 12 ArcTanh[1/Sqrt]^2)


the result is different (I added GenerateConditions -> False just for speed, it doesn't seem to change the result).

Why is that? What do I have to do to get the same result for the integration also in two steps?

• Sometimes you can't - the double integral is sometimes not the same as the iterated integral ( or you cannot change the order ) en.wikipedia.org/wiki/… Jul 14 '20 at 12:04
• All that is not so simple. You deal with an improper double integral as Plot3D[2/(1 - (u^2 - v^2)), {v, -1/2, 0}, {u, -v, 1 + v}, PlotRange -> {0, 200}] shows (The integrand is unbounded at $u=1, v=0$.). Jul 14 '20 at 15:10
• The result of NIntegrate[2/(1 - (u^2 - v^2)), {v, -1/2, 0}, {u, -v, 1 + v}, Exclusions -> {u == 1, v == 0}] suggests that the improper integral converges though this is not a proof. Jul 14 '20 at 15:34
• @user64494 Have you doubts anymore? Jul 15 '20 at 10:11

You should add assumptions on v or simplify the result of the first integral with appropriate assumptions.

Integrate[ Integrate[2/(1 - (u^2 - v^2)), {u, -v, 1 + v},
Assumptions -> -1/2 <= v <= 0], {v, -1/2, 0}]

 Pi^2/12


Originally the first integral yields the result in terms of ArcTan, however with assumptions we get slightly different expression which after another integration avoids possible issues with terms hard to simplify.

Refine[ Integrate[2/(1 - (u^2 - v^2)), {u, -v, 1 + v}, Assumptions -> -1/2 <= v <= 0],
-1/2 < v < 0]

  (2 (ArcSinh[v] + ArcTanh[(1 + v)/Sqrt[1 + v^2]]))/Sqrt[1 + v^2]


alternatively we can get it with

FullSimplify[ -((2(ArcTan[v/Sqrt[-1 - v^2]]
+ ArcTan[(1 + v)/Sqrt[-1 - v^2]]))/Sqrt[-1 - v^2]), -1/2 <= v < 0]


Edit

In the comments there have appeared some doubts whether the integral converges since the integrand diverges as $$v \to 0$$. To demonstrate the convergence we can follow along standard mathematical techniques or exploit appropriate Mathematica functionality. We are going to make use of the newest functions. The first integral yields $$\int_{-1/2}^{0}\int_{-v}^{1+v} \frac{2}{1-(u^2-v^2)} dudv = \int_{-\frac{1}{2}}^0\frac{2\left(\operatorname{arcsh}(v)+\operatorname{arcth}(\frac{1+v}{\sqrt{1+v^2}}) \right)}{\sqrt{1+v^2}} dv$$ The first term in the integral is not harmful and so we take a closer look at the second one. Now we can show

Asymptotic[2 ArcTanh[(1 + v)/Sqrt[1 + v^2]]/Sqrt[1 + v^2], v -> 0]

-Log[v]


and integrating it with respect to $$v$$ we can see that the integral converges as the upper integration limit approaches to $$0$$ from below. Moreover

AsymptoticLessEqual[(2 (ArcTanh[(1 + v)/Sqrt[1 + v^2]]))/Sqrt[1 + v^2],-Log[-v],
v -> 0, Direction -> +1]

True


This means that we can find a constant $$c$$ such that $$\frac{2\operatorname{arcth}(\frac{1+v}{\sqrt{1+v^2}}) }{\sqrt{1+v^2}} \leq c \log(-v)$$ for any $$v<0$$, taking e.g. $$c=2$$ we can see

Plot[{(2 (ArcTanh[(1 + v)/Sqrt[1 + v^2]]))/Sqrt[1 + v^2], -2 Log[-v]},
{v, -1/2, 0}, PlotStyle -> Thick] These arguments clarify that the integral actually exists. One can also calculate this integral

res = Integrate[(2 (ArcTanh[(1 + v)/Sqrt[1 + v^2]]))/Sqrt[1 + v^2], {v, -1/2, z},
Assumptions -> -1/2 < z < 0]


and then calculate the limit

Limit[ res, z -> 0, Direction -> "FromBelow"]


We have proved, that Mathematica correctly deals with this type of the integrand.

• All that is not so simple. You deal with an improper double integral as Plot3D[2/(1 - (u^2 - v^2)), {v, -1/2, 0}, {u, -v, 1 + v}, PlotRange -> {0, 200}] shows (The integrand is unbounded at $u=1, v=0$.). Jul 14 '20 at 15:12
• @user64494 It doesn't matter. Jul 14 '20 at 15:16
• Artes, could you kindly ground you statement? TIA. Jul 14 '20 at 15:20
• Artes,the result of NIntegrate[2/(1 - (u^2 - v^2)), {v, -1/2, 0}, {u, -v, 1 + v}, Exclusions -> {u == 1, v == 0}] suggests that the improper integral converges though this is not a proof. Jul 14 '20 at 15:29
• My goal was more mundane, which was to suggest that the means of answering the question of convergence was easily within the reach of @user64494. I might add further that Integrate carried out an internal “proof” of convergence, and before demanding proof from others, one ought to provide grounds for doubting the result. I apologize for the noise on your comment thread. Jul 14 '20 at 21:26

PossibleZeroQ will numerically check for zero if standard transformations do not work. It, being numerical, is not foolproof, and so it is not a complete rigorous method. For that reason, @Artes' method is superior in this case.

Simplify[
1/12 (π^2 + 3 ArcCosh[7/2] ArcCsch -
12 ArcTanh[1/Sqrt]^2),
TransformationFunctions -> {Automatic, # /. _?PossibleZeroQ :> 0 &}]

Simplify::ztest1: Unable to decide whether numeric quantity -3 (-Log[1+Times[<<2>>]]+Log[1+1/Sqrt])^2+3 Log[1/2+Sqrt/2] Log[7/2+(3 Sqrt)/2] is equal to zero. Assuming it is.

(*  π^2/12  *)


Simplify caches results, so the message only appears on first execution.

• All that is not so simple. You deal with an improper double integral as Plot3D[2/(1 - (u^2 - v^2)), {v, -1/2, 0}, {u, -v, 1 + v}, PlotRange -> {0, 200}] shows (The integrand is unbounded at $u=1, v=0$.). Jul 14 '20 at 15:12
• @user64494 Your remark makes no sense. I do not deal with an integral at all. Unless you mean my approval of Artes' answer. Jul 14 '20 at 15:14
• Disagreed. 1/12 (π^2 + 3 ArcCosh[7/2] ArcCsch - 12 ArcTanh[1/Sqrt]^2) is a supposed value for the double integral. It is not obvious whether the integral exists and that result is right. Of course, your transformation leads to Pi^2/12. Jul 14 '20 at 15:19
• @user64494 Then prove whether the integral does or does not exist. Jul 14 '20 at 15:22
• Michael E2, the result of NIntegrate[2/(1 - (u^2 - v^2)), {v, -1/2, 0}, {u, -v, 1 + v}, Exclusions -> {u == 1, v == 0}] suggests that the improper integral converges though this is not a proof. Jul 14 '20 at 15:28

The results are the same, as

3 ArcCosh[7/2] ArcCsch-12 ArcTanh[1/Sqrt]^2


is actually zero. Mathematica does not seem to realize that, even with FullSimplify, but you can check it numerically up to a high number of digits

N[1+3 ArcCosh[7/2] ArcCsch-12 ArcTanh[1/Sqrt]^2,200]

1.00000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000000000000000000

• All that is not so simple. You deal with an improper double integral as Plot3D[2/(1 - (u^2 - v^2)), {v, -1/2, 0}, {u, -v, 1 + v}, PlotRange -> {0, 200}] shows (The integrand is unbounded at $u=1, v=0$.). Jul 14 '20 at 15:12
• The result of NIntegrate[2/(1 - (u^2 - v^2)), {v, -1/2, 0}, {u, -v, 1 + v}, Exclusions -> {u == 1, v == 0}] suggests that the improper integral converges though this is not a proof. Jul 14 '20 at 15:29
• @Hausdorff Would you say it is a bug in Mathematica that it cannot simplify this expression? Jul 15 '20 at 19:33
• No, it is generally very hard to determine whether something is truly zero. Mathematica just does not seem to know any transformations that would make everything cancel cleanly. Jul 15 '20 at 20:21