\(\int \frac {\coth ^2(x)}{a+b \coth (x)} \, dx\) [146]

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

Optimal result

Integrand size = 13, antiderivative size = 63 \[ \int \frac {\coth ^2(x)}{a+b \coth (x)} \, dx=-\frac {a x}{b^2}+\frac {a^3 x}{b^2 \left (a^2-b^2\right )}+\frac {\log (\sinh (x))}{b}-\frac {a^2 \log (b \cosh (x)+a \sinh (x))}{b \left (a^2-b^2\right )} \]

[Out]

-a*x/b^2+a^3*x/b^2/(a^2-b^2)+ln(sinh(x))/b-a^2*ln(b*cosh(x)+a*sinh(x))/b/(a^2-b^2)

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 63, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.308, Rules used = {3622, 3556, 3565, 3611} \[ \int \frac {\coth ^2(x)}{a+b \coth (x)} \, dx=-\frac {a^2 \log (a \sinh (x)+b \cosh (x))}{b \left (a^2-b^2\right )}+\frac {a^3 x}{b^2 \left (a^2-b^2\right )}-\frac {a x}{b^2}+\frac {\log (\sinh (x))}{b} \]

[In]

Int[Coth[x]^2/(a + b*Coth[x]),x]

[Out]

-((a*x)/b^2) + (a^3*x)/(b^2*(a^2 - b^2)) + Log[Sinh[x]]/b - (a^2*Log[b*Cosh[x] + a*Sinh[x]])/(b*(a^2 - b^2))

Rule 3556

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

Rule 3565

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

Rule 3611

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c/(b*f))
*Log[RemoveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rule 3622

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

Rubi steps \begin{align*} \text {integral}& = -\frac {a x}{b^2}+\frac {a^2 \int \frac {1}{a+b \coth (x)} \, dx}{b^2}+\frac {\int \coth (x) \, dx}{b} \\ & = -\frac {a x}{b^2}+\frac {a^3 x}{b^2 \left (a^2-b^2\right )}+\frac {\log (\sinh (x))}{b}-\frac {\left (i a^2\right ) \int \frac {-i b-i a \coth (x)}{a+b \coth (x)} \, dx}{b \left (a^2-b^2\right )} \\ & = -\frac {a x}{b^2}+\frac {a^3 x}{b^2 \left (a^2-b^2\right )}+\frac {\log (\sinh (x))}{b}-\frac {a^2 \log (b \cosh (x)+a \sinh (x))}{b \left (a^2-b^2\right )} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.14 (sec) , antiderivative size = 59, normalized size of antiderivative = 0.94 \[ \int \frac {\coth ^2(x)}{a+b \coth (x)} \, dx=-\frac {\log (1-\coth (x))}{2 (a+b)}+\frac {\log (1+\coth (x))}{2 (a-b)}-\frac {a^2 \log (a+b \coth (x))}{b \left (a^2-b^2\right )} \]

[In]

Integrate[Coth[x]^2/(a + b*Coth[x]),x]

[Out]

-1/2*Log[1 - Coth[x]]/(a + b) + Log[1 + Coth[x]]/(2*(a - b)) - (a^2*Log[a + b*Coth[x]])/(b*(a^2 - b^2))

Maple [A] (verified)

Time = 0.11 (sec) , antiderivative size = 56, normalized size of antiderivative = 0.89

method result size
parallelrisch \(\frac {-a^{2} \ln \left (b +a \tanh \left (x \right )\right )+\ln \left (1-\tanh \left (x \right )\right ) b^{2}+\left (\left (a -b \right ) \ln \left (\tanh \left (x \right )\right )+b x \right ) \left (a +b \right )}{a^{2} b -b^{3}}\) \(56\)
derivativedivides \(\frac {\ln \left (1+\coth \left (x \right )\right )}{2 a -2 b}-\frac {\ln \left (\coth \left (x \right )-1\right )}{2 a +2 b}-\frac {a^{2} \ln \left (a +b \coth \left (x \right )\right )}{\left (a +b \right ) \left (a -b \right ) b}\) \(60\)
default \(\frac {\ln \left (1+\coth \left (x \right )\right )}{2 a -2 b}-\frac {\ln \left (\coth \left (x \right )-1\right )}{2 a +2 b}-\frac {a^{2} \ln \left (a +b \coth \left (x \right )\right )}{\left (a +b \right ) \left (a -b \right ) b}\) \(60\)
risch \(\frac {x}{a +b}+\frac {2 x \,a^{2}}{b \left (a^{2}-b^{2}\right )}-\frac {2 x}{b}-\frac {a^{2} \ln \left ({\mathrm e}^{2 x}-\frac {a -b}{a +b}\right )}{b \left (a^{2}-b^{2}\right )}+\frac {\ln \left ({\mathrm e}^{2 x}-1\right )}{b}\) \(83\)

[In]

int(coth(x)^2/(a+b*coth(x)),x,method=_RETURNVERBOSE)

[Out]

(-a^2*ln(b+a*tanh(x))+ln(1-tanh(x))*b^2+((a-b)*ln(tanh(x))+b*x)*(a+b))/(a^2*b-b^3)

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.21 \[ \int \frac {\coth ^2(x)}{a+b \coth (x)} \, dx=-\frac {a^{2} \log \left (\frac {2 \, {\left (b \cosh \left (x\right ) + a \sinh \left (x\right )\right )}}{\cosh \left (x\right ) - \sinh \left (x\right )}\right ) - {\left (a b + b^{2}\right )} x - {\left (a^{2} - b^{2}\right )} \log \left (\frac {2 \, \sinh \left (x\right )}{\cosh \left (x\right ) - \sinh \left (x\right )}\right )}{a^{2} b - b^{3}} \]

[In]

integrate(coth(x)^2/(a+b*coth(x)),x, algorithm="fricas")

[Out]

-(a^2*log(2*(b*cosh(x) + a*sinh(x))/(cosh(x) - sinh(x))) - (a*b + b^2)*x - (a^2 - b^2)*log(2*sinh(x)/(cosh(x)
- sinh(x))))/(a^2*b - b^3)

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 372 vs. \(2 (51) = 102\).

Time = 0.71 (sec) , antiderivative size = 372, normalized size of antiderivative = 5.90 \[ \int \frac {\coth ^2(x)}{a+b \coth (x)} \, dx=\begin {cases} \tilde {\infty } \left (x - \log {\left (\tanh {\left (x \right )} + 1 \right )} + \log {\left (\tanh {\left (x \right )} \right )}\right ) & \text {for}\: a = 0 \wedge b = 0 \\\frac {x - \log {\left (\tanh {\left (x \right )} + 1 \right )} + \log {\left (\tanh {\left (x \right )} \right )}}{b} & \text {for}\: a = 0 \\\frac {3 x \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} - \frac {3 x}{2 b \tanh {\left (x \right )} - 2 b} - \frac {2 \log {\left (\tanh {\left (x \right )} + 1 \right )} \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} + \frac {2 \log {\left (\tanh {\left (x \right )} + 1 \right )}}{2 b \tanh {\left (x \right )} - 2 b} + \frac {2 \log {\left (\tanh {\left (x \right )} \right )} \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} - \frac {2 \log {\left (\tanh {\left (x \right )} \right )}}{2 b \tanh {\left (x \right )} - 2 b} - \frac {1}{2 b \tanh {\left (x \right )} - 2 b} & \text {for}\: a = - b \\\frac {x \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} + 2 b} + \frac {x}{2 b \tanh {\left (x \right )} + 2 b} - \frac {2 \log {\left (\tanh {\left (x \right )} + 1 \right )} \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} + 2 b} - \frac {2 \log {\left (\tanh {\left (x \right )} + 1 \right )}}{2 b \tanh {\left (x \right )} + 2 b} + \frac {2 \log {\left (\tanh {\left (x \right )} \right )} \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} + 2 b} + \frac {2 \log {\left (\tanh {\left (x \right )} \right )}}{2 b \tanh {\left (x \right )} + 2 b} + \frac {1}{2 b \tanh {\left (x \right )} + 2 b} & \text {for}\: a = b \\\frac {x - \frac {1}{\tanh {\left (x \right )}}}{a} & \text {for}\: b = 0 \\- \frac {a^{2} \log {\left (\tanh {\left (x \right )} + \frac {b}{a} \right )}}{a^{2} b - b^{3}} + \frac {a^{2} \log {\left (\tanh {\left (x \right )} \right )}}{a^{2} b - b^{3}} + \frac {a b x}{a^{2} b - b^{3}} - \frac {b^{2} x}{a^{2} b - b^{3}} + \frac {b^{2} \log {\left (\tanh {\left (x \right )} + 1 \right )}}{a^{2} b - b^{3}} - \frac {b^{2} \log {\left (\tanh {\left (x \right )} \right )}}{a^{2} b - b^{3}} & \text {otherwise} \end {cases} \]

[In]

integrate(coth(x)**2/(a+b*coth(x)),x)

[Out]

Piecewise((zoo*(x - log(tanh(x) + 1) + log(tanh(x))), Eq(a, 0) & Eq(b, 0)), ((x - log(tanh(x) + 1) + log(tanh(
x)))/b, Eq(a, 0)), (3*x*tanh(x)/(2*b*tanh(x) - 2*b) - 3*x/(2*b*tanh(x) - 2*b) - 2*log(tanh(x) + 1)*tanh(x)/(2*
b*tanh(x) - 2*b) + 2*log(tanh(x) + 1)/(2*b*tanh(x) - 2*b) + 2*log(tanh(x))*tanh(x)/(2*b*tanh(x) - 2*b) - 2*log
(tanh(x))/(2*b*tanh(x) - 2*b) - 1/(2*b*tanh(x) - 2*b), Eq(a, -b)), (x*tanh(x)/(2*b*tanh(x) + 2*b) + x/(2*b*tan
h(x) + 2*b) - 2*log(tanh(x) + 1)*tanh(x)/(2*b*tanh(x) + 2*b) - 2*log(tanh(x) + 1)/(2*b*tanh(x) + 2*b) + 2*log(
tanh(x))*tanh(x)/(2*b*tanh(x) + 2*b) + 2*log(tanh(x))/(2*b*tanh(x) + 2*b) + 1/(2*b*tanh(x) + 2*b), Eq(a, b)),
((x - 1/tanh(x))/a, Eq(b, 0)), (-a**2*log(tanh(x) + b/a)/(a**2*b - b**3) + a**2*log(tanh(x))/(a**2*b - b**3) +
 a*b*x/(a**2*b - b**3) - b**2*x/(a**2*b - b**3) + b**2*log(tanh(x) + 1)/(a**2*b - b**3) - b**2*log(tanh(x))/(a
**2*b - b**3), True))

Maxima [A] (verification not implemented)

none

Time = 0.19 (sec) , antiderivative size = 63, normalized size of antiderivative = 1.00 \[ \int \frac {\coth ^2(x)}{a+b \coth (x)} \, dx=-\frac {a^{2} \log \left (-{\left (a - b\right )} e^{\left (-2 \, x\right )} + a + b\right )}{a^{2} b - b^{3}} + \frac {x}{a + b} + \frac {\log \left (e^{\left (-x\right )} + 1\right )}{b} + \frac {\log \left (e^{\left (-x\right )} - 1\right )}{b} \]

[In]

integrate(coth(x)^2/(a+b*coth(x)),x, algorithm="maxima")

[Out]

-a^2*log(-(a - b)*e^(-2*x) + a + b)/(a^2*b - b^3) + x/(a + b) + log(e^(-x) + 1)/b + log(e^(-x) - 1)/b

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 59, normalized size of antiderivative = 0.94 \[ \int \frac {\coth ^2(x)}{a+b \coth (x)} \, dx=-\frac {a^{2} \log \left ({\left | a e^{\left (2 \, x\right )} + b e^{\left (2 \, x\right )} - a + b \right |}\right )}{a^{2} b - b^{3}} + \frac {x}{a - b} + \frac {\log \left ({\left | e^{\left (2 \, x\right )} - 1 \right |}\right )}{b} \]

[In]

integrate(coth(x)^2/(a+b*coth(x)),x, algorithm="giac")

[Out]

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

Mupad [B] (verification not implemented)

Time = 2.20 (sec) , antiderivative size = 57, normalized size of antiderivative = 0.90 \[ \int \frac {\coth ^2(x)}{a+b \coth (x)} \, dx=\frac {\ln \left ({\mathrm {e}}^{2\,x}-1\right )}{b}+\frac {x}{a-b}-\frac {a^2\,\ln \left (b-a+a\,{\mathrm {e}}^{2\,x}+b\,{\mathrm {e}}^{2\,x}\right )}{a^2\,b-b^3} \]

[In]

int(coth(x)^2/(a + b*coth(x)),x)

[Out]

log(exp(2*x) - 1)/b + x/(a - b) - (a^2*log(b - a + a*exp(2*x) + b*exp(2*x)))/(a^2*b - b^3)