# How to obtain this expression in terms of real functions

I know that this expression

(2 (ArcCot[E^(-((I ϕ)/2)) r] + ArcCot[E^((I ϕ)/2) r]))/π


is real, because is the sum of a real series, in particular:

Assuming[{r > 1, -π < ϕ < π, ϕ ∈ Reals}, Sum[r^-n 4/π Sin[n π/2]/n Cos [n ϕ/2], {n, 1, ∞}]] // FullSimplify

(2 (ArcCot[E^(-((I ϕ)/2)) r] + ArcCot[E^((I ϕ)/2) r]))/π


and I have been told that Maple gets a real function when calling evalc. But with ComplexExpand I do not get anything satisfying:

(2 (ArcCot[E^(-((I ϕ)/2)) r] + ArcCot[E^((I ϕ)/2) r]))/π // ComplexExpand


-(Arg[1 - (I E^(-((I ϕ)/2)))/r]/π) + Arg[1 + (I E^(-((I ϕ)/2)))/r]/π - Arg[1 - (I E^((I ϕ)/2))/r]/π + Arg[1 + (I E^((I ϕ)/2))/r]/π

\$Version

(*  "10.4.1 for Mac OS X x86 (64-bit) (April 11, 2016)"  *)

expr = Assuming[{r > 1, -π < ϕ < π, ϕ ∈
Reals}, Sum[
r^-n 4/π Sin[n π/2]/n Cos[n ϕ/2], {n,
1, ∞}]] // FullSimplify expr2 = Assuming[{r > 1, -π < ϕ < π, ϕ ∈
Reals}, expr // ComplexExpand[#, TargetFunctions -> {Re, Im}] & //
FullSimplify] Plot3D[#, {r, 1, 5}, {ϕ, -π, π}] & /@ {expr, expr2} The answer is completely satisfactory. It returns the result in terms of Arg which is always a real number. If look for its imaginary part

Im@ComplexExpand[(2 (ArcCot[E^(-((I \[Phi])/2)) r] +
ArcCot[E^((I \[Phi])/2) r]))/\[Pi]]


0

So your answer is a Real quantity.

You can use the TargetFunctions option of ComplexExpand[]:

FullSimplify[ComplexExpand[(2 (ArcCot[E^(-((I ϕ)/2)) r] + ArcCot[E^((I ϕ)/2) r]))/π,
TargetFunctions -> {Re, Im}], r > 1 && -π < ϕ < π]
(2 (ArcCot[Sec[ϕ/2] (r + Sin[ϕ/2])] + ArcCot[r Sec[ϕ/2] - Tan[ϕ/2]]))/π


One could probably argue for the following further simplification, but you'll have to check if this remains valid for your assumptions:

2 ArcCot[TrigExpand[Cot[π %/2]] // Simplify]/π // Simplify
2 ArcCot[(-1 + r^2) Csc[ϕ] Sin[ϕ/2]/r]/π