\(\int (a+b \coth (c+d x))^2 \, dx\) [80]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (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 = 12, antiderivative size = 38 \[ \int (a+b \coth (c+d x))^2 \, dx=\left (a^2+b^2\right ) x-\frac {b^2 \coth (c+d x)}{d}+\frac {2 a b \log (\sinh (c+d x))}{d} \]

[Out]

(a^2+b^2)*x-b^2*coth(d*x+c)/d+2*a*b*ln(sinh(d*x+c))/d

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 38, 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.167, Rules used = {3558, 3556} \[ \int (a+b \coth (c+d x))^2 \, dx=x \left (a^2+b^2\right )+\frac {2 a b \log (\sinh (c+d x))}{d}-\frac {b^2 \coth (c+d x)}{d} \]

[In]

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

[Out]

(a^2 + b^2)*x - (b^2*Coth[c + d*x])/d + (2*a*b*Log[Sinh[c + d*x]])/d

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}& = \left (a^2+b^2\right ) x-\frac {b^2 \coth (c+d x)}{d}+(2 a b) \int \coth (c+d x) \, dx \\ & = \left (a^2+b^2\right ) x-\frac {b^2 \coth (c+d x)}{d}+\frac {2 a b \log (\sinh (c+d x))}{d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.13 (sec) , antiderivative size = 65, normalized size of antiderivative = 1.71 \[ \int (a+b \coth (c+d x))^2 \, dx=\frac {-2 b^2 \coth (c+d x)-(a+b)^2 \log (1-\tanh (c+d x))+4 a b \log (\tanh (c+d x))+(a-b)^2 \log (1+\tanh (c+d x))}{2 d} \]

[In]

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

[Out]

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

Maple [A] (verified)

Time = 0.08 (sec) , antiderivative size = 59, normalized size of antiderivative = 1.55

method result size
parts \(a^{2} x +\frac {b^{2} \left (-\coth \left (d x +c \right )-\frac {\ln \left (\coth \left (d x +c \right )-1\right )}{2}+\frac {\ln \left (\coth \left (d x +c \right )+1\right )}{2}\right )}{d}+\frac {2 a b \ln \left (\sinh \left (d x +c \right )\right )}{d}\) \(59\)
derivativedivides \(\frac {-\coth \left (d x +c \right ) b^{2}-\frac {\left (a^{2}+2 a b +b^{2}\right ) \ln \left (\coth \left (d x +c \right )-1\right )}{2}+\frac {\left (a^{2}-2 a b +b^{2}\right ) \ln \left (\coth \left (d x +c \right )+1\right )}{2}}{d}\) \(61\)
default \(\frac {-\coth \left (d x +c \right ) b^{2}-\frac {\left (a^{2}+2 a b +b^{2}\right ) \ln \left (\coth \left (d x +c \right )-1\right )}{2}+\frac {\left (a^{2}-2 a b +b^{2}\right ) \ln \left (\coth \left (d x +c \right )+1\right )}{2}}{d}\) \(61\)
risch \(a^{2} x -2 a b x +b^{2} x -\frac {4 a b c}{d}-\frac {2 b^{2}}{d \left ({\mathrm e}^{2 d x +2 c}-1\right )}+\frac {2 a b \ln \left ({\mathrm e}^{2 d x +2 c}-1\right )}{d}\) \(65\)
parallelrisch \(\frac {-2 \ln \left (1-\tanh \left (d x +c \right )\right ) \tanh \left (d x +c \right ) a b +2 a b \ln \left (\tanh \left (d x +c \right )\right ) \tanh \left (d x +c \right )+d x \left (a -b \right )^{2} \tanh \left (d x +c \right )-b^{2}}{d \tanh \left (d x +c \right )}\) \(73\)

[In]

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

[Out]

a^2*x+b^2/d*(-coth(d*x+c)-1/2*ln(coth(d*x+c)-1)+1/2*ln(coth(d*x+c)+1))+2*a*b*ln(sinh(d*x+c))/d

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 205 vs. \(2 (38) = 76\).

Time = 0.26 (sec) , antiderivative size = 205, normalized size of antiderivative = 5.39 \[ \int (a+b \coth (c+d x))^2 \, dx=\frac {{\left (a^{2} - 2 \, a b + b^{2}\right )} d x \cosh \left (d x + c\right )^{2} + 2 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} d x \cosh \left (d x + c\right ) \sinh \left (d x + c\right ) + {\left (a^{2} - 2 \, a b + b^{2}\right )} d x \sinh \left (d x + c\right )^{2} - {\left (a^{2} - 2 \, a b + b^{2}\right )} d x - 2 \, b^{2} + 2 \, {\left (a b \cosh \left (d x + c\right )^{2} + 2 \, a b \cosh \left (d x + c\right ) \sinh \left (d x + c\right ) + a b \sinh \left (d x + c\right )^{2} - a b\right )} \log \left (\frac {2 \, \sinh \left (d x + c\right )}{\cosh \left (d x + c\right ) - \sinh \left (d x + c\right )}\right )}{d \cosh \left (d x + c\right )^{2} + 2 \, d \cosh \left (d x + c\right ) \sinh \left (d x + c\right ) + d \sinh \left (d x + c\right )^{2} - d} \]

[In]

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

[Out]

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

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 209 vs. \(2 (34) = 68\).

Time = 0.57 (sec) , antiderivative size = 209, normalized size of antiderivative = 5.50 \[ \int (a+b \coth (c+d x))^2 \, dx=\begin {cases} x \left (a + b \coth {\left (c \right )}\right )^{2} & \text {for}\: d = 0 \\- \frac {a^{2} \log {\left (- e^{- d x} \right )}}{d} - \frac {2 a b \log {\left (- e^{- d x} \right )} \coth {\left (d x + \log {\left (- e^{- d x} \right )} \right )}}{d} - \frac {b^{2} \log {\left (- e^{- d x} \right )} \coth ^{2}{\left (d x + \log {\left (- e^{- d x} \right )} \right )}}{d} & \text {for}\: c = \log {\left (- e^{- d x} \right )} \\a^{2} x + 2 a b x \coth {\left (d x + \log {\left (e^{- d x} \right )} \right )} + b^{2} x \coth ^{2}{\left (d x + \log {\left (e^{- d x} \right )} \right )} & \text {for}\: c = \log {\left (e^{- d x} \right )} \\a^{2} x + 2 a b x - \frac {2 a b \log {\left (\tanh {\left (c + d x \right )} + 1 \right )}}{d} + \frac {2 a b \log {\left (\tanh {\left (c + d x \right )} \right )}}{d} + b^{2} x - \frac {b^{2}}{d \tanh {\left (c + d x \right )}} & \text {otherwise} \end {cases} \]

[In]

integrate((a+b*coth(d*x+c))**2,x)

[Out]

Piecewise((x*(a + b*coth(c))**2, Eq(d, 0)), (-a**2*log(-exp(-d*x))/d - 2*a*b*log(-exp(-d*x))*coth(d*x + log(-e
xp(-d*x)))/d - b**2*log(-exp(-d*x))*coth(d*x + log(-exp(-d*x)))**2/d, Eq(c, log(-exp(-d*x)))), (a**2*x + 2*a*b
*x*coth(d*x + log(exp(-d*x))) + b**2*x*coth(d*x + log(exp(-d*x)))**2, Eq(c, log(exp(-d*x)))), (a**2*x + 2*a*b*
x - 2*a*b*log(tanh(c + d*x) + 1)/d + 2*a*b*log(tanh(c + d*x))/d + b**2*x - b**2/(d*tanh(c + d*x)), True))

Maxima [A] (verification not implemented)

none

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

[In]

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

[Out]

b^2*(x + c/d + 2/(d*(e^(-2*d*x - 2*c) - 1))) + a^2*x + 2*a*b*log(sinh(d*x + c))/d

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 57, normalized size of antiderivative = 1.50 \[ \int (a+b \coth (c+d x))^2 \, dx=\frac {2 \, a b \log \left ({\left | e^{\left (2 \, d x + 2 \, c\right )} - 1 \right |}\right ) + {\left (a^{2} - 2 \, a b + b^{2}\right )} {\left (d x + c\right )} - \frac {2 \, b^{2}}{e^{\left (2 \, d x + 2 \, c\right )} - 1}}{d} \]

[In]

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

[Out]

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

Mupad [B] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 51, normalized size of antiderivative = 1.34 \[ \int (a+b \coth (c+d x))^2 \, dx=x\,{\left (a-b\right )}^2-\frac {2\,b^2}{d\,\left ({\mathrm {e}}^{2\,c+2\,d\,x}-1\right )}+\frac {2\,a\,b\,\ln \left ({\mathrm {e}}^{2\,c}\,{\mathrm {e}}^{2\,d\,x}-1\right )}{d} \]

[In]

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

[Out]

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