3.142 \(\int \frac {\tanh ^2(x)}{a+b \coth (x)} \, dx\)

Optimal. Leaf size=60 \[ \frac {a x}{a^2-b^2}-\frac {b^3 \log (a \sinh (x)+b \cosh (x))}{a^2 \left (a^2-b^2\right )}-\frac {b \log (\cosh (x))}{a^2}-\frac {\tanh (x)}{a} \]

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.19, antiderivative size = 60, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.308, Rules used = {3569, 3651, 3530, 3475} \[ \frac {a x}{a^2-b^2}-\frac {b^3 \log (a \sinh (x)+b \cosh (x))}{a^2 \left (a^2-b^2\right )}-\frac {b \log (\cosh (x))}{a^2}-\frac {\tanh (x)}{a} \]

Antiderivative was successfully verified.

[In]

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

[Out]

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

Rule 3475

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

Rule 3530

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c*Log[Re
moveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]])/(b*f), 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 3569

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Si
mp[(b^2*(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^(n + 1))/(f*(m + 1)*(a^2 + b^2)*(b*c - a*d)), x] + D
ist[1/((m + 1)*(a^2 + b^2)*(b*c - a*d)), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^n*Simp[a*(b*c -
 a*d)*(m + 1) - b^2*d*(m + n + 2) - b*(b*c - a*d)*(m + 1)*Tan[e + f*x] - b^2*d*(m + n + 2)*Tan[e + f*x]^2, x],
 x], x] /; FreeQ[{a, b, c, d, e, f, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0] && I
ntegerQ[2*m] && LtQ[m, -1] && (LtQ[n, 0] || IntegerQ[m]) &&  !(ILtQ[n, -1] && ( !IntegerQ[m] || (EqQ[c, 0] &&
NeQ[a, 0])))

Rule 3651

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

Rubi steps

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

________________________________________________________________________________________

Mathematica [A]  time = 0.14, size = 64, normalized size = 1.07 \[ \frac {\left (a b^2-a^3\right ) \tanh (x)+a^3 x+\left (b^3-a^2 b\right ) \log (\cosh (x))-b^3 \log (a \sinh (x)+b \cosh (x))}{a^4-a^2 b^2} \]

Antiderivative was successfully verified.

[In]

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

[Out]

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

________________________________________________________________________________________

fricas [B]  time = 0.44, size = 264, normalized size = 4.40 \[ \frac {{\left (a^{3} + a^{2} b\right )} x \cosh \relax (x)^{2} + 2 \, {\left (a^{3} + a^{2} b\right )} x \cosh \relax (x) \sinh \relax (x) + {\left (a^{3} + a^{2} b\right )} x \sinh \relax (x)^{2} + 2 \, a^{3} - 2 \, a b^{2} + {\left (a^{3} + a^{2} b\right )} x - {\left (b^{3} \cosh \relax (x)^{2} + 2 \, b^{3} \cosh \relax (x) \sinh \relax (x) + b^{3} \sinh \relax (x)^{2} + b^{3}\right )} \log \left (\frac {2 \, {\left (b \cosh \relax (x) + a \sinh \relax (x)\right )}}{\cosh \relax (x) - \sinh \relax (x)}\right ) - {\left (a^{2} b - b^{3} + {\left (a^{2} b - b^{3}\right )} \cosh \relax (x)^{2} + 2 \, {\left (a^{2} b - b^{3}\right )} \cosh \relax (x) \sinh \relax (x) + {\left (a^{2} b - b^{3}\right )} \sinh \relax (x)^{2}\right )} \log \left (\frac {2 \, \cosh \relax (x)}{\cosh \relax (x) - \sinh \relax (x)}\right )}{a^{4} - a^{2} b^{2} + {\left (a^{4} - a^{2} b^{2}\right )} \cosh \relax (x)^{2} + 2 \, {\left (a^{4} - a^{2} b^{2}\right )} \cosh \relax (x) \sinh \relax (x) + {\left (a^{4} - a^{2} b^{2}\right )} \sinh \relax (x)^{2}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

giac [A]  time = 0.12, size = 74, normalized size = 1.23 \[ -\frac {b^{3} \log \left ({\left | a e^{\left (2 \, x\right )} + b e^{\left (2 \, x\right )} - a + b \right |}\right )}{a^{4} - a^{2} b^{2}} + \frac {x}{a - b} - \frac {b \log \left (e^{\left (2 \, x\right )} + 1\right )}{a^{2}} + \frac {2}{a {\left (e^{\left (2 \, x\right )} + 1\right )}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

maple [A]  time = 0.14, size = 110, normalized size = 1.83 \[ -\frac {b^{3} \ln \left (\left (\tanh ^{2}\left (\frac {x}{2}\right )\right ) b +2 a \tanh \left (\frac {x}{2}\right )+b \right )}{\left (a +b \right ) \left (a -b \right ) a^{2}}-\frac {16 \ln \left (\tanh \left (\frac {x}{2}\right )-1\right )}{16 a +16 b}+\frac {16 \ln \left (\tanh \left (\frac {x}{2}\right )+1\right )}{16 a -16 b}-\frac {2 \tanh \left (\frac {x}{2}\right )}{a \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right )}-\frac {b \ln \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right )}{a^{2}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

maxima [A]  time = 0.46, size = 67, normalized size = 1.12 \[ -\frac {b^{3} \log \left (-{\left (a - b\right )} e^{\left (-2 \, x\right )} + a + b\right )}{a^{4} - a^{2} b^{2}} + \frac {x}{a + b} - \frac {b \log \left (e^{\left (-2 \, x\right )} + 1\right )}{a^{2}} - \frac {2}{a e^{\left (-2 \, x\right )} + a} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

mupad [B]  time = 1.45, size = 73, normalized size = 1.22 \[ \frac {2}{a\,\left ({\mathrm {e}}^{2\,x}+1\right )}+\frac {x}{a-b}-\frac {b^3\,\ln \left (b-a+a\,{\mathrm {e}}^{2\,x}+b\,{\mathrm {e}}^{2\,x}\right )}{a^4-a^2\,b^2}-\frac {b\,\ln \left ({\mathrm {e}}^{2\,x}+1\right )}{a^2} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

sympy [F]  time = 0.00, size = 0, normalized size = 0.00 \[ \int \frac {\tanh ^{2}{\relax (x )}}{a + b \coth {\relax (x )}}\, dx \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Integral(tanh(x)**2/(a + b*coth(x)), x)

________________________________________________________________________________________