\(\int (1+\coth (x))^2 \, dx\) [64]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 6, antiderivative size = 13 \[ \int (1+\coth (x))^2 \, dx=2 x-\coth (x)+2 \log (\sinh (x)) \]

[Out]

2*x-coth(x)+2*ln(sinh(x))

Rubi [A] (verified)

Time = 0.01 (sec) , antiderivative size = 13, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {3558, 3556} \[ \int (1+\coth (x))^2 \, dx=2 x-\coth (x)+2 \log (\sinh (x)) \]

[In]

Int[(1 + Coth[x])^2,x]

[Out]

2*x - Coth[x] + 2*Log[Sinh[x]]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3558

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2)*x, x] + (Dist[2*a*b, Int[Tan[c + d
*x], x], x] + Simp[b^2*(Tan[c + d*x]/d), x]) /; FreeQ[{a, b, c, d}, x]

Rubi steps \begin{align*} \text {integral}& = 2 x-\coth (x)+2 \int \coth (x) \, dx \\ & = 2 x-\coth (x)+2 \log (\sinh (x)) \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.01 (sec) , antiderivative size = 28, normalized size of antiderivative = 2.15 \[ \int (1+\coth (x))^2 \, dx=x-\coth (x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},\tanh ^2(x)\right )+2 \log (\cosh (x))+2 \log (\tanh (x)) \]

[In]

Integrate[(1 + Coth[x])^2,x]

[Out]

x - Coth[x]*Hypergeometric2F1[-1/2, 1, 1/2, Tanh[x]^2] + 2*Log[Cosh[x]] + 2*Log[Tanh[x]]

Maple [A] (verified)

Time = 0.05 (sec) , antiderivative size = 13, normalized size of antiderivative = 1.00

method result size
derivativedivides \(-\coth \left (x \right )-2 \ln \left (\coth \left (x \right )-1\right )\) \(13\)
default \(-\coth \left (x \right )-2 \ln \left (\coth \left (x \right )-1\right )\) \(13\)
risch \(-\frac {2}{{\mathrm e}^{2 x}-1}+2 \ln \left ({\mathrm e}^{2 x}-1\right )\) \(21\)
parallelrisch \(\frac {-1+2 \ln \left (\tanh \left (x \right )\right ) \tanh \left (x \right )-2 \ln \left (1-\tanh \left (x \right )\right ) \tanh \left (x \right )}{\tanh \left (x \right )}\) \(26\)
parts \(x -\coth \left (x \right )-\frac {\ln \left (\coth \left (x \right )-1\right )}{2}+\frac {\ln \left (1+\coth \left (x \right )\right )}{2}+2 \ln \left (\sinh \left (x \right )\right )\) \(26\)

[In]

int((1+coth(x))^2,x,method=_RETURNVERBOSE)

[Out]

-coth(x)-2*ln(coth(x)-1)

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 53 vs. \(2 (13) = 26\).

Time = 0.24 (sec) , antiderivative size = 53, normalized size of antiderivative = 4.08 \[ \int (1+\coth (x))^2 \, dx=\frac {2 \, {\left ({\left (\cosh \left (x\right )^{2} + 2 \, \cosh \left (x\right ) \sinh \left (x\right ) + \sinh \left (x\right )^{2} - 1\right )} \log \left (\frac {2 \, \sinh \left (x\right )}{\cosh \left (x\right ) - \sinh \left (x\right )}\right ) - 1\right )}}{\cosh \left (x\right )^{2} + 2 \, \cosh \left (x\right ) \sinh \left (x\right ) + \sinh \left (x\right )^{2} - 1} \]

[In]

integrate((1+coth(x))^2,x, algorithm="fricas")

[Out]

2*((cosh(x)^2 + 2*cosh(x)*sinh(x) + sinh(x)^2 - 1)*log(2*sinh(x)/(cosh(x) - sinh(x))) - 1)/(cosh(x)^2 + 2*cosh
(x)*sinh(x) + sinh(x)^2 - 1)

Sympy [A] (verification not implemented)

Time = 0.19 (sec) , antiderivative size = 22, normalized size of antiderivative = 1.69 \[ \int (1+\coth (x))^2 \, dx=4 x - 2 \log {\left (\tanh {\left (x \right )} + 1 \right )} + 2 \log {\left (\tanh {\left (x \right )} \right )} - \frac {1}{\tanh {\left (x \right )}} \]

[In]

integrate((1+coth(x))**2,x)

[Out]

4*x - 2*log(tanh(x) + 1) + 2*log(tanh(x)) - 1/tanh(x)

Maxima [A] (verification not implemented)

none

Time = 0.18 (sec) , antiderivative size = 19, normalized size of antiderivative = 1.46 \[ \int (1+\coth (x))^2 \, dx=2 \, x + \frac {2}{e^{\left (-2 \, x\right )} - 1} + 2 \, \log \left (\sinh \left (x\right )\right ) \]

[In]

integrate((1+coth(x))^2,x, algorithm="maxima")

[Out]

2*x + 2/(e^(-2*x) - 1) + 2*log(sinh(x))

Giac [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 21, normalized size of antiderivative = 1.62 \[ \int (1+\coth (x))^2 \, dx=-\frac {2}{e^{\left (2 \, x\right )} - 1} + 2 \, \log \left ({\left | e^{\left (2 \, x\right )} - 1 \right |}\right ) \]

[In]

integrate((1+coth(x))^2,x, algorithm="giac")

[Out]

-2/(e^(2*x) - 1) + 2*log(abs(e^(2*x) - 1))

Mupad [B] (verification not implemented)

Time = 0.05 (sec) , antiderivative size = 20, normalized size of antiderivative = 1.54 \[ \int (1+\coth (x))^2 \, dx=2\,\ln \left ({\mathrm {e}}^{2\,x}-1\right )-\frac {2}{{\mathrm {e}}^{2\,x}-1} \]

[In]

int((coth(x) + 1)^2,x)

[Out]

2*log(exp(2*x) - 1) - 2/(exp(2*x) - 1)