# Indefinite ArcTan integral does not return the (known) real expression but returns complex expression

I have a problem with an indefinite integral which I solved using MMA in back in 2010 (must have been version 7 or 8) successfullly and it gave an elegant result. However, if I run it with MMA 11.3 (probably holds for 10 too, maybe 9), the same integral yields an expression in complex logarithmic terms. Numerically, the latter is probably the same, symbolically not what I'm looking for as I need to work further with the results.

The problem concerns following integral

FullSimplify[ Integrate[2 y z ArcTan[(x y)/(z Sqrt[x^2 + y^2 + z^2])], z]]


In the old MMA version (I guess 8 but I'm not sure) the result was:

y (z^2 ArcTan[(x y)/(z Sqrt[x^2 + y^2 + z^2])] -
y^2 ArcTan[(x z)/(y Sqrt[x^2 + y^2 + z^2])] +
x (-x ArcTan[(y z)/(x Sqrt[x^2 + y^2 + z^2])] +
2 y Log[z + Sqrt[x^2 + y^2 + z^2]]))


(Quick check with Simplify@D[result,z] indeed gives the original expression. )

However, if I run the same integral with MMA11.3 the result becomes far less elegant

y z^2 ArcTan[(x y)/(z Sqrt[x^2 + y^2 + z^2])] + 1/2 I y (-4 I x y Log[z + Sqrt[x^2 + y^2 + z^2]] + y^2 (Log[(y + (x (x + Sqrt[x^2 + y^2 + z^2]))/(y - I z))/(x^2 y^2)] - Log[(y + (x (x + Sqrt[x^2 + y^2 + z^2]))/(y + I z))/(x^2 y^2)]) + x^2 (Log[(x^2 - I x z + y (y + Sqrt[x^2 + y^2 + z^2]))/(x^2 y^2 (x - I z))] - Log[(x^2 + I x z + y (y + Sqrt[x^2 + y^2 + z^2]))/(x^2 y^2 (x + I z))]))


The quick check again gives the original expression.

Any ideas about what's going on, or what changed between these MMA versions?

• FindInstance finds (complex) values of x,y,z for which the expressions are unequal. Different versions seem to choose different branches. Commented Aug 16, 2018 at 20:57
• In the eighth version, the same result is obtained, as in 11.3 Commented Aug 17, 2018 at 7:20

Rubi returns the following antiderivative:

rubiSol = Int[2 y z ArcTan[(x y)/(z Sqrt[x^2 + y^2 + z^2])], z]


and it can be derived back to the original expression

D[rubiSol, z] // FullSimplify

(* 2 y z ArcTan[(x y)/(z Sqrt[x^2 + y^2 + z^2])] *)

• Thanks, I was not aware of this package!
– JJBK
Commented Aug 27, 2018 at 10:36

A new day, a new insight. Partial integration may be saving this day...

, or

expression = 2 y  z ArcTan[(x y)/(z Sqrt[x^2 + y^2 + z^2])]
udv        = MapThread[Rule, {{dv, u}, expression /. {a_ ArcTan[b_] -> {a, ArcTan[b]}}}]
u          = u /. udv
du         = Simplify@D[u, z]
dv         =  dv /. udv
v          = Integrate[dv, z]
Simplify[u v - Integrate[du v, z]]


The result:

y (z^2 ArcTan[(x y)/(z Sqrt[x^2 + y^2 + z^2])] -
y^2 ArcTan[(x z)/(y Sqrt[x^2 + y^2 + z^2])] +
x (-x ArcTan[(y z)/(x Sqrt[x^2 + y^2 + z^2])] +
2 y Log[z + Sqrt[x^2 + y^2 + z^2]]))