# Symbolic solution for integral that Mathematica can't directly integrate

As explored in this math.SE post, the integral

$I = \int_{-1}^1\frac1x\sqrt{\frac{1+x}{1-x}}\ln\left(\frac{2\,x^2+2\,x+1}{2\,x^2-2\,x+1}\right) \ \mathrm dx$

or in code:

Integrate[1/x*Sqrt[(1 + x)/(1 - x)]* Log[(2 x^2 + 2 x + 1)/(2 x^2 - 2 x + 1)], {x, -1, 1}]


a) cannot be evaluated directly with Mathematica; and
b) has the following closed form (symbolic) solution $I=4\,\pi\operatorname{arccot}{\sqrt\phi}$, where $\phi$ is the golden ratio.

In code, this is:

4 π ArcCot[Sqrt[GoldenRatio]]


Can we find a way to perform this symbolic integration with Mathematica?

• have you tried any of the various approaches in the answers to the linked question? Commented Oct 23, 2017 at 23:54

Here is a partial answer: making the substitution $x=\cos t$ yields the integral

AbsoluteTiming[res = Integrate[Cot[t/2] Tan[t]
Log[1 + (4 Cos[t])/(2 - 2 Cos[t] + Cos[2 t])], {t, 0, π}];]
{1033.99, Null}


which is very complicated:

LeafCount[res]
2460


but does evaluate to a number that is the same as $4\pi\operatorname{arccot}\sqrt\phi$:

{N[res, 20], N[4 π ArcCot[Sqrt[GoldenRatio]], 20]}
{8.3722116266012756616 + 0.*10^-20 I, 8.3722116266012756616}


I've had FullSimplify[] work on res for eight hours; no progress thus far.

## Update

I aborted the evaluation of FullSimplify[] after 20 hours. It turns out that a slightly more convoluted route gives a more manageable expression:

resf = MapAll[FullSimplify, MapAll[Simplify, MapAll[ComplexExpand, res]]]
π^2 - 1/2 I π Log[Root[1 - 4868 #1 + 5638 #1^2 - 4868 #1^3 + #1^4 &, 3]]

π^2 - 1/2 π ArcTan[(8 Sqrt[15242 + 20689 Sqrt[5]])/1409]


Make a manual transformation:

atanRule = ArcTan[u_] :> 2 ArcTan[ToRadicals[RootReduce[(Sqrt[1 + u^2] - 1)/u]]];

resf = FullSimplify[resf /. atanRule]
π (π - ArcTan[4/31 Sqrt[-22 + 17 Sqrt[5]]])


Manually transform again:

resf = resf /. atanRule
π (π - 2 ArcTan[1/2 Sqrt[-2 + Sqrt[5]]])


And again:

resf = FullSimplify[resf /. ArcTan[u_] :> π/2 - ArcCot[u]]
2 π ArcTan[2 Sqrt[2 + Sqrt[5]]]


And finally:

resf = resf /. atanRule /. ArcTan[u_] :> ArcCot[FullSimplify[1/u]]
4 π ArcCot[Sqrt[1/2 (1 + Sqrt[5])]]


THIS IS AN EXTENDED COMMENT RATHER THAN AN ANSWER.

expr = 1/x Sqrt[(1 + x)/(1 - x)] *
Log[(2 x^2 + 2 x + 1)/(2 x^2 - 2 x + 1)];

expr2 = NIntegrate[expr, {x, -1, 1}];


Although not practical, you can use RootApproximant to reverse engineer from the numerical integration

(expr3 = 4 Pi ArcCot[(RootApproximant[Cot[expr2/(4 Pi)]] // ToRadicals) /.
5^(1/2) -> 2 GoldenRatio - 1]) // TraditionalForm


Rubi can integrate this, but Rubi only does indefinite integration. Using second part of Fundamental Theorem of Calculus in order to obtain the definite integration then proved hard, but may be because this is improper integral and one can't really use FTOC on it!

Mathematica can't find limit as x->1 but can find limit x->0.

The Rubi indefinite result contain many PolyLog terms. Tried "DeveloperPolyLogSimplify" on it, but that did not help. I post Rubi output, may be someone has smart way to finish this part.

ClearAll[x]
expr=1/x Sqrt[(1+x)/(1-x)] Log[(2x^2+2x+1)/(2 x^2-2x+1)]
anti = Int[expr, x];
anti2 = DeveloperPolyLogSimplify[anti]


Here it the long result

2*ArcTan[Sqrt[(1 + x)/(1 - x)]]*
Log[(1 - (2*(1 + x))/(1 - x) + (5*(1 + x)^2)/(1 - x)^2)/
(5 - (2*(1 + x))/(1 - x) + (1 + x)^2/(1 - x)^2)] -
2*ArcTanh[Sqrt[(1 + x)/(1 - x)]]*
Log[(1 - (2*(1 + x))/(1 - x) + (5*(1 + x)^2)/(1 - x)^2)/
(5 - (2*(1 + x))/(1 - x) + (1 + x)^2/(1 - x)^2)] +
Log[1 - Sqrt[(1 + x)/(1 - x)]]*Log[-((Sqrt[1 - 2*I] - Sqrt[(1 + x)/(1 - x)])/
(1 - Sqrt[1 - 2*I]))] + Log[1 - Sqrt[(1 + x)/(1 - x)]]*
Log[-((Sqrt[1 + 2*I] - Sqrt[(1 + x)/(1 - x)])/(1 - Sqrt[1 + 2*I]))] +
I*Log[(Sqrt[1 - 2*I] - Sqrt[(1 + x)/(1 - x)])/(I + Sqrt[1 - 2*I])]*
Log[1 - I*Sqrt[(1 + x)/(1 - x)]] +
I*Log[(Sqrt[1 + 2*I] - Sqrt[(1 + x)/(1 - x)])/(I + Sqrt[1 + 2*I])]*
Log[1 - I*Sqrt[(1 + x)/(1 - x)]] -
I*Log[-((Sqrt[1 - 2*I] - Sqrt[(1 + x)/(1 - x)])/(I - Sqrt[1 - 2*I]))]*
Log[1 + I*Sqrt[(1 + x)/(1 - x)]] -
I*Log[-((Sqrt[1 + 2*I] - Sqrt[(1 + x)/(1 - x)])/(I - Sqrt[1 + 2*I]))]*
Log[1 + I*Sqrt[(1 + x)/(1 - x)]] -
Log[(Sqrt[1 - 2*I] - Sqrt[(1 + x)/(1 - x)])/(1 + Sqrt[1 - 2*I])]*
Log[1 + Sqrt[(1 + x)/(1 - x)]] -
Log[(Sqrt[1 + 2*I] - Sqrt[(1 + x)/(1 - x)])/(1 + Sqrt[1 + 2*I])]*
Log[1 + Sqrt[(1 + x)/(1 - x)]] + I*Log[1 - I*Sqrt[(1 + x)/(1 - x)]]*
Log[-((Sqrt[1 - 2*I] + Sqrt[(1 + x)/(1 - x)])/(I - Sqrt[1 - 2*I]))] -
Log[1 + Sqrt[(1 + x)/(1 - x)]]*Log[-((Sqrt[1 - 2*I] + Sqrt[(1 + x)/(1 - x)])/
(1 - Sqrt[1 - 2*I]))] - I*Log[1 + I*Sqrt[(1 + x)/(1 - x)]]*
Log[(Sqrt[1 - 2*I] + Sqrt[(1 + x)/(1 - x)])/(I + Sqrt[1 - 2*I])] +
Log[1 - Sqrt[(1 + x)/(1 - x)]]*Log[(Sqrt[1 - 2*I] + Sqrt[(1 + x)/(1 - x)])/
(1 + Sqrt[1 - 2*I])] + I*Log[1 - I*Sqrt[(1 + x)/(1 - x)]]*
Log[-((Sqrt[1 + 2*I] + Sqrt[(1 + x)/(1 - x)])/(I - Sqrt[1 + 2*I]))] -
Log[1 + Sqrt[(1 + x)/(1 - x)]]*Log[-((Sqrt[1 + 2*I] + Sqrt[(1 + x)/(1 - x)])/
(1 - Sqrt[1 + 2*I]))] - I*Log[1 + I*Sqrt[(1 + x)/(1 - x)]]*
Log[(Sqrt[1 + 2*I] + Sqrt[(1 + x)/(1 - x)])/(I + Sqrt[1 + 2*I])] +
Log[1 - Sqrt[(1 + x)/(1 - x)]]*Log[(Sqrt[1 + 2*I] + Sqrt[(1 + x)/(1 - x)])/
(1 + Sqrt[1 + 2*I])] - Log[1 - Sqrt[(1 + x)/(1 - x)]]*
Log[(1 - Sqrt[1 - 2*I]*Sqrt[(1 + x)/(1 - x)])/(1 - Sqrt[1 - 2*I])] +
I*Log[1 + I*Sqrt[(1 + x)/(1 - x)]]*Log[(1 - Sqrt[1 - 2*I]*Sqrt[(1 + x)/(1 - x)])/
(1 - I*Sqrt[1 - 2*I])] - I*Log[1 - I*Sqrt[(1 + x)/(1 - x)]]*
Log[(1 - Sqrt[1 - 2*I]*Sqrt[(1 + x)/(1 - x)])/(1 + I*Sqrt[1 - 2*I])] +
Log[1 + Sqrt[(1 + x)/(1 - x)]]*Log[(1 - Sqrt[1 - 2*I]*Sqrt[(1 + x)/(1 - x)])/
(1 + Sqrt[1 - 2*I])] + Log[1 + Sqrt[(1 + x)/(1 - x)]]*
Log[(1 + Sqrt[1 - 2*I]*Sqrt[(1 + x)/(1 - x)])/(1 - Sqrt[1 - 2*I])] -
I*Log[1 - I*Sqrt[(1 + x)/(1 - x)]]*Log[(1 + Sqrt[1 - 2*I]*Sqrt[(1 + x)/(1 - x)])/
(1 - I*Sqrt[1 - 2*I])] + I*Log[1 + I*Sqrt[(1 + x)/(1 - x)]]*
Log[(1 + Sqrt[1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1 - 2*I]))] + PolyLog[2, (1 - Sqrt[(1 + x)/(1 - x)])/
(1 + Sqrt[1 - 2*I])] - PolyLog[2, (Sqrt[1 - 2*I]*(1 - Sqrt[(1 + x)/(1 - x)]))/
(1 + Sqrt[1 - 2*I])] + PolyLog[2, (1 - Sqrt[(1 + x)/(1 - x)])/
(1 - Sqrt[1 + 2*I])] - PolyLog[2, -((Sqrt[1 + 2*I]*(1 - Sqrt[(1 + x)/(1 - x)]))/
(1 - Sqrt[1 + 2*I]))] + PolyLog[2, (1 - Sqrt[(1 + x)/(1 - x)])/
(1 + Sqrt[1 + 2*I])] - PolyLog[2, (Sqrt[1 + 2*I]*(1 - Sqrt[(1 + x)/(1 - x)]))/
(1 + Sqrt[1 + 2*I])] -
I*PolyLog[2, -((Sqrt[1 - 2*I]*(1 - I*Sqrt[(1 + x)/(1 - x)]))/(I - Sqrt[1 - 2*I]))] +
I*PolyLog[2, (1 - I*Sqrt[(1 + x)/(1 - x)])/(1 - I*Sqrt[1 - 2*I])] +
I*PolyLog[2, (1 - I*Sqrt[(1 + x)/(1 - x)])/(1 + I*Sqrt[1 - 2*I])] -
I*PolyLog[2, (Sqrt[1 - 2*I]*(1 - I*Sqrt[(1 + x)/(1 - x)]))/(I + Sqrt[1 - 2*I])] -
I*PolyLog[2, -((Sqrt[1 + 2*I]*(1 - I*Sqrt[(1 + x)/(1 - x)]))/(I - Sqrt[1 + 2*I]))] +
I*PolyLog[2, (1 - I*Sqrt[(1 + x)/(1 - x)])/(1 - I*Sqrt[1 + 2*I])] +
I*PolyLog[2, (1 - I*Sqrt[(1 + x)/(1 - x)])/(1 + I*Sqrt[1 + 2*I])] -
I*PolyLog[2, (Sqrt[1 + 2*I]*(1 - I*Sqrt[(1 + x)/(1 - x)]))/(I + Sqrt[1 + 2*I])] +
I*PolyLog[2, -((Sqrt[1 - 2*I]*(1 + I*Sqrt[(1 + x)/(1 - x)]))/(I - Sqrt[1 - 2*I]))] -
I*PolyLog[2, (1 + I*Sqrt[(1 + x)/(1 - x)])/(1 - I*Sqrt[1 - 2*I])] -
I*PolyLog[2, (1 + I*Sqrt[(1 + x)/(1 - x)])/(1 + I*Sqrt[1 - 2*I])] +
I*PolyLog[2, (Sqrt[1 - 2*I]*(1 + I*Sqrt[(1 + x)/(1 - x)]))/(I + Sqrt[1 - 2*I])] +
I*PolyLog[2, -((Sqrt[1 + 2*I]*(1 + I*Sqrt[(1 + x)/(1 - x)]))/(I - Sqrt[1 + 2*I]))] -
I*PolyLog[2, (1 + I*Sqrt[(1 + x)/(1 - x)])/(1 - I*Sqrt[1 + 2*I])] -
I*PolyLog[2, (1 + I*Sqrt[(1 + x)/(1 - x)])/(1 + I*Sqrt[1 + 2*I])] +
I*PolyLog[2, (Sqrt[1 + 2*I]*(1 + I*Sqrt[(1 + x)/(1 - x)]))/(I + Sqrt[1 + 2*I])] -
PolyLog[2, (1 + Sqrt[(1 + x)/(1 - x)])/(1 - Sqrt[1 - 2*I])] +
PolyLog[2, -((Sqrt[1 - 2*I]*(1 + Sqrt[(1 + x)/(1 - x)]))/(1 - Sqrt[1 - 2*I]))] -
PolyLog[2, (1 + Sqrt[(1 + x)/(1 - x)])/(1 + Sqrt[1 - 2*I])] +
PolyLog[2, (Sqrt[1 - 2*I]*(1 + Sqrt[(1 + x)/(1 - x)]))/(1 + Sqrt[1 - 2*I])] -
PolyLog[2, (1 + Sqrt[(1 + x)/(1 - x)])/(1 - Sqrt[1 + 2*I])] +
PolyLog[2, -((Sqrt[1 + 2*I]*(1 + Sqrt[(1 + x)/(1 - x)]))/(1 - Sqrt[1 + 2*I]))] -
PolyLog[2, (1 + Sqrt[(1 + x)/(1 - x)])/(1 + Sqrt[1 + 2*I])] +
PolyLog[2, (Sqrt[1 + 2*I]*(1 + Sqrt[(1 + x)/(1 - x)]))/(1 + Sqrt[1 + 2*I])]


Now

Limit[anti2,x->-1]
(*0*)

Limit[anti2,x->1]  (*this is the problem, it gets stuck here*)


Rubi and Mathematica are close, but no cigar.

Now to verify Rubi result, Differentiated back the anti-derivative to see it gives back the integrand (or constant shifted version of it). This is what I get

expr0=Assuming[Element[x,Reals],FullSimplify[D[anti2,x]]]
(*     (2*Sqrt[(1 + x)/(1 - x)]*ArcTanh[(2*x)/(1 + 2*x^2)])/x *)


Plotting the above against the original integrand to check, shows they are the same! So Rubi result is valid, but may be not optimal

{Plot[expr0,{x,-1,1},PlotLabel->"Rubi"],Plot[expr,{x,-1,1},PlotLabel->"original"]}