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

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

Optimal result

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

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

Mathematica [A] (verified)

Time = 0.22 (sec) , antiderivative size = 66, normalized size of antiderivative = 1.10 \[ \int \frac {\coth ^2(x)}{a+b \tanh (x)} \, dx=-\frac {\coth (x)}{a}-\frac {\log (1-\coth (x))}{2 (a+b)}+\frac {\log (1+\coth (x))}{2 (a-b)}-\frac {b^3 \log (b+a \coth (x))}{a^2 \left (a^2-b^2\right )} \] Input:

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

Output:

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

Rubi [C] (verified)

Result contains complex when optimal does not.

Time = 0.56 (sec) , antiderivative size = 77, normalized size of antiderivative = 1.28, number of steps used = 12, number of rules used = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.923, Rules used = {3042, 25, 4052, 25, 3042, 26, 4134, 26, 3042, 26, 3956, 4013}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

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

\(\Big \downarrow \) 3042

\(\displaystyle \int -\frac {1}{\tan (i x)^2 (a-i b \tan (i x))}dx\)

\(\Big \downarrow \) 25

\(\displaystyle -\int \frac {1}{\tan (i x)^2 (a-i b \tan (i x))}dx\)

\(\Big \downarrow \) 4052

\(\displaystyle \frac {\int -\frac {\coth (x) \left (-b \tanh ^2(x)-a \tanh (x)+b\right )}{a+b \tanh (x)}dx}{a}-\frac {\coth (x)}{a}\)

\(\Big \downarrow \) 25

\(\displaystyle -\frac {\int \frac {\coth (x) \left (-b \tanh ^2(x)-a \tanh (x)+b\right )}{a+b \tanh (x)}dx}{a}-\frac {\coth (x)}{a}\)

\(\Big \downarrow \) 3042

\(\displaystyle -\frac {\coth (x)}{a}-\frac {\int \frac {i \left (b \tan (i x)^2+i a \tan (i x)+b\right )}{\tan (i x) (a-i b \tan (i x))}dx}{a}\)

\(\Big \downarrow \) 26

\(\displaystyle -\frac {\coth (x)}{a}-\frac {i \int \frac {b \tan (i x)^2+i a \tan (i x)+b}{\tan (i x) (a-i b \tan (i x))}dx}{a}\)

\(\Big \downarrow \) 4134

\(\displaystyle -\frac {\coth (x)}{a}-\frac {i \left (\frac {b^3 \int -\frac {i (b+a \tanh (x))}{a+b \tanh (x)}dx}{a \left (a^2-b^2\right )}+\frac {b \int -i \coth (x)dx}{a}+\frac {i a^2 x}{a^2-b^2}\right )}{a}\)

\(\Big \downarrow \) 26

\(\displaystyle -\frac {\coth (x)}{a}-\frac {i \left (-\frac {i b^3 \int \frac {b+a \tanh (x)}{a+b \tanh (x)}dx}{a \left (a^2-b^2\right )}-\frac {i b \int \coth (x)dx}{a}+\frac {i a^2 x}{a^2-b^2}\right )}{a}\)

\(\Big \downarrow \) 3042

\(\displaystyle -\frac {\coth (x)}{a}-\frac {i \left (-\frac {i b^3 \int \frac {b-i a \tan (i x)}{a-i b \tan (i x)}dx}{a \left (a^2-b^2\right )}-\frac {i b \int -i \tan \left (i x+\frac {\pi }{2}\right )dx}{a}+\frac {i a^2 x}{a^2-b^2}\right )}{a}\)

\(\Big \downarrow \) 26

\(\displaystyle -\frac {\coth (x)}{a}-\frac {i \left (-\frac {i b^3 \int \frac {b-i a \tan (i x)}{a-i b \tan (i x)}dx}{a \left (a^2-b^2\right )}-\frac {b \int \tan \left (i x+\frac {\pi }{2}\right )dx}{a}+\frac {i a^2 x}{a^2-b^2}\right )}{a}\)

\(\Big \downarrow \) 3956

\(\displaystyle -\frac {\coth (x)}{a}-\frac {i \left (-\frac {i b^3 \int \frac {b-i a \tan (i x)}{a-i b \tan (i x)}dx}{a \left (a^2-b^2\right )}+\frac {i a^2 x}{a^2-b^2}-\frac {i b \log (\sinh (x))}{a}\right )}{a}\)

\(\Big \downarrow \) 4013

\(\displaystyle -\frac {\coth (x)}{a}-\frac {i \left (\frac {i a^2 x}{a^2-b^2}-\frac {i b^3 \log (a \cosh (x)+b \sinh (x))}{a \left (a^2-b^2\right )}-\frac {i b \log (\sinh (x))}{a}\right )}{a}\)

Input:

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

Output:

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

Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 26
Int[(Complex[0, a_])*(Fx_), x_Symbol] :> Simp[(Complex[Identity[0], a])   I 
nt[Fx, x], x] /; FreeQ[a, x] && EqQ[a^2, 1]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

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

rule 4013
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*Si 
n[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 4052
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)])^(n_), x_Symbol] :> Simp[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] + Simp[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] && IntegerQ[2*m] && LtQ[m, -1] && (LtQ[n, 0] || Integ 
erQ[m]) &&  !(ILtQ[n, -1] && ( !IntegerQ[m] || (EqQ[c, 0] && NeQ[a, 0])))
 

rule 4134
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] + (Simp[(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] - Sim 
p[(c^2*C - B*c*d + A*d^2)/((b*c - a*d)*(c^2 + d^2))   Int[(d - c*Tan[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]
 
Maple [A] (verified)

Time = 0.44 (sec) , antiderivative size = 71, normalized size of antiderivative = 1.18

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

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 271 vs. \(2 (60) = 120\).

Time = 0.10 (sec) , antiderivative size = 271, normalized size of antiderivative = 4.52 \[ \int \frac {\coth ^2(x)}{a+b \tanh (x)} \, dx=-\frac {{\left (a^{3} + a^{2} b\right )} x \cosh \left (x\right )^{2} + 2 \, {\left (a^{3} + a^{2} b\right )} x \cosh \left (x\right ) \sinh \left (x\right ) + {\left (a^{3} + a^{2} b\right )} x \sinh \left (x\right )^{2} - 2 \, a^{3} + 2 \, a b^{2} - {\left (a^{3} + a^{2} b\right )} x - {\left (b^{3} \cosh \left (x\right )^{2} + 2 \, b^{3} \cosh \left (x\right ) \sinh \left (x\right ) + b^{3} \sinh \left (x\right )^{2} - b^{3}\right )} \log \left (\frac {2 \, {\left (a \cosh \left (x\right ) + b \sinh \left (x\right )\right )}}{\cosh \left (x\right ) - \sinh \left (x\right )}\right ) + {\left (a^{2} b - b^{3} - {\left (a^{2} b - b^{3}\right )} \cosh \left (x\right )^{2} - 2 \, {\left (a^{2} b - b^{3}\right )} \cosh \left (x\right ) \sinh \left (x\right ) - {\left (a^{2} b - b^{3}\right )} \sinh \left (x\right )^{2}\right )} \log \left (\frac {2 \, \sinh \left (x\right )}{\cosh \left (x\right ) - \sinh \left (x\right )}\right )}{a^{4} - a^{2} b^{2} - {\left (a^{4} - a^{2} b^{2}\right )} \cosh \left (x\right )^{2} - 2 \, {\left (a^{4} - a^{2} b^{2}\right )} \cosh \left (x\right ) \sinh \left (x\right ) - {\left (a^{4} - a^{2} b^{2}\right )} \sinh \left (x\right )^{2}} \] Input:

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

Output:

-((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*(a*cosh(x) + b*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*sinh(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)
 

Sympy [F]

\[ \int \frac {\coth ^2(x)}{a+b \tanh (x)} \, dx=\int \frac {\coth ^{2}{\left (x \right )}}{a + b \tanh {\left (x \right )}}\, dx \] Input:

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

Output:

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

Maxima [A] (verification not implemented)

Time = 0.05 (sec) , antiderivative size = 86, normalized size of antiderivative = 1.43 \[ \int \frac {\coth ^2(x)}{a+b \tanh (x)} \, dx=-\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 (-x\right )} + 1\right )}{a^{2}} - \frac {b \log \left (e^{\left (-x\right )} - 1\right )}{a^{2}} + \frac {2}{a e^{\left (-2 \, x\right )} - a} \] Input:

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

Output:

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

Giac [A] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.25 \[ \int \frac {\coth ^2(x)}{a+b \tanh (x)} \, dx=-\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 ({\left | e^{\left (2 \, x\right )} - 1 \right |}\right )}{a^{2}} - \frac {2}{a {\left (e^{\left (2 \, x\right )} - 1\right )}} \] Input:

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

Output:

-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(abs(e^(2*x) - 1))/a^2 - 2/(a*(e^(2*x) - 1))
 

Mupad [B] (verification not implemented)

Time = 2.39 (sec) , antiderivative size = 73, normalized size of antiderivative = 1.22 \[ \int \frac {\coth ^2(x)}{a+b \tanh (x)} \, dx=\frac {x}{a-b}-\frac {2}{a\,\left ({\mathrm {e}}^{2\,x}-1\right )}-\frac {b^3\,\ln \left (a-b+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} \] Input:

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

Output:

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

Reduce [B] (verification not implemented)

Time = 3.05 (sec) , antiderivative size = 252, normalized size of antiderivative = 4.20 \[ \int \frac {\coth ^2(x)}{a+b \tanh (x)} \, dx=\frac {-e^{2 x} \mathrm {log}\left (e^{x}-1\right ) a^{2} b +e^{2 x} \mathrm {log}\left (e^{x}-1\right ) b^{3}-e^{2 x} \mathrm {log}\left (e^{x}+1\right ) a^{2} b +e^{2 x} \mathrm {log}\left (e^{x}+1\right ) b^{3}-e^{2 x} \mathrm {log}\left (e^{2 x} a +e^{2 x} b +a -b \right ) b^{3}+e^{2 x} a^{3} x -2 e^{2 x} a^{3}+e^{2 x} a^{2} b x +2 e^{2 x} a \,b^{2}+\mathrm {log}\left (e^{x}-1\right ) a^{2} b -\mathrm {log}\left (e^{x}-1\right ) b^{3}+\mathrm {log}\left (e^{x}+1\right ) a^{2} b -\mathrm {log}\left (e^{x}+1\right ) b^{3}+\mathrm {log}\left (e^{2 x} a +e^{2 x} b +a -b \right ) b^{3}-a^{3} x -a^{2} b x}{a^{2} \left (e^{2 x} a^{2}-e^{2 x} b^{2}-a^{2}+b^{2}\right )} \] Input:

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

Output:

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