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

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

Optimal result

Integrand size = 13, antiderivative size = 61 \[ \int \frac {\tanh ^2(x)}{a+b \cosh (x)} \, dx=\frac {b \arctan (\sinh (x))}{a^2}+\frac {2 \sqrt {a-b} \sqrt {a+b} \text {arctanh}\left (\frac {\sqrt {a-b} \tanh \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{a^2}-\frac {\tanh (x)}{a} \] Output:

b*arctan(sinh(x))/a^2+2*(a-b)^(1/2)*(a+b)^(1/2)*arctanh((a-b)^(1/2)*tanh(1 
/2*x)/(a+b)^(1/2))/a^2-tanh(x)/a
 

Mathematica [A] (verified)

Time = 0.11 (sec) , antiderivative size = 61, normalized size of antiderivative = 1.00 \[ \int \frac {\tanh ^2(x)}{a+b \cosh (x)} \, dx=\frac {2 b \arctan \left (\tanh \left (\frac {x}{2}\right )\right )+2 \sqrt {-a^2+b^2} \arctan \left (\frac {(a-b) \tanh \left (\frac {x}{2}\right )}{\sqrt {-a^2+b^2}}\right )-a \tanh (x)}{a^2} \] Input:

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

Output:

(2*b*ArcTan[Tanh[x/2]] + 2*Sqrt[-a^2 + b^2]*ArcTan[((a - b)*Tanh[x/2])/Sqr 
t[-a^2 + b^2]] - a*Tanh[x])/a^2
 

Rubi [A] (verified)

Time = 0.69 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.23, number of steps used = 13, number of rules used = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.923, Rules used = {3042, 25, 3202, 3042, 3535, 25, 3042, 3480, 3042, 3138, 221, 4257}

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 {\tanh ^2(x)}{a+b \cosh (x)} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 25

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

\(\Big \downarrow \) 3202

\(\displaystyle -\int \frac {\left (1-\cosh ^2(x)\right ) \text {sech}^2(x)}{a+b \cosh (x)}dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3535

\(\displaystyle -\frac {\int -\frac {(b+a \cosh (x)) \text {sech}(x)}{a+b \cosh (x)}dx}{a}-\frac {\tanh (x)}{a}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {\int \frac {(b+a \cosh (x)) \text {sech}(x)}{a+b \cosh (x)}dx}{a}-\frac {\tanh (x)}{a}\)

\(\Big \downarrow \) 3042

\(\displaystyle -\frac {\tanh (x)}{a}+\frac {\int \frac {b+a \sin \left (i x+\frac {\pi }{2}\right )}{\sin \left (i x+\frac {\pi }{2}\right ) \left (a+b \sin \left (i x+\frac {\pi }{2}\right )\right )}dx}{a}\)

\(\Big \downarrow \) 3480

\(\displaystyle \frac {\frac {\left (a^2-b^2\right ) \int \frac {1}{a+b \cosh (x)}dx}{a}+\frac {b \int \text {sech}(x)dx}{a}}{a}-\frac {\tanh (x)}{a}\)

\(\Big \downarrow \) 3042

\(\displaystyle -\frac {\tanh (x)}{a}+\frac {\frac {\left (a^2-b^2\right ) \int \frac {1}{a+b \sin \left (i x+\frac {\pi }{2}\right )}dx}{a}+\frac {b \int \csc \left (i x+\frac {\pi }{2}\right )dx}{a}}{a}\)

\(\Big \downarrow \) 3138

\(\displaystyle -\frac {\tanh (x)}{a}+\frac {\frac {2 \left (a^2-b^2\right ) \int \frac {1}{-\left ((a-b) \tanh ^2\left (\frac {x}{2}\right )\right )+a+b}d\tanh \left (\frac {x}{2}\right )}{a}+\frac {b \int \csc \left (i x+\frac {\pi }{2}\right )dx}{a}}{a}\)

\(\Big \downarrow \) 221

\(\displaystyle -\frac {\tanh (x)}{a}+\frac {\frac {2 \left (a^2-b^2\right ) \text {arctanh}\left (\frac {\sqrt {a-b} \tanh \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{a \sqrt {a-b} \sqrt {a+b}}+\frac {b \int \csc \left (i x+\frac {\pi }{2}\right )dx}{a}}{a}\)

\(\Big \downarrow \) 4257

\(\displaystyle \frac {\frac {2 \left (a^2-b^2\right ) \text {arctanh}\left (\frac {\sqrt {a-b} \tanh \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{a \sqrt {a-b} \sqrt {a+b}}+\frac {b \arctan (\sinh (x))}{a}}{a}-\frac {\tanh (x)}{a}\)

Input:

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

Output:

((b*ArcTan[Sinh[x]])/a + (2*(a^2 - b^2)*ArcTanh[(Sqrt[a - b]*Tanh[x/2])/Sq 
rt[a + b]])/(a*Sqrt[a - b]*Sqrt[a + b]))/a - Tanh[x]/a
 

Defintions of rubi rules used

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

rule 221
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[-a/b, 2]/a)*ArcTanh[x 
/Rt[-a/b, 2]], x] /; FreeQ[{a, b}, x] && NegQ[a/b]
 

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

rule 3138
Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{ 
e = FreeFactors[Tan[(c + d*x)/2], x]}, Simp[2*(e/d)   Subst[Int[1/(a + b + 
(a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] 
 && NeQ[a^2 - b^2, 0]
 

rule 3202
Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)/tan[(e_.) + (f_.)*(x_)]^2, 
x_Symbol] :> Int[(a + b*Sin[e + f*x])^m*((1 - Sin[e + f*x]^2)/Sin[e + f*x]^ 
2), x] /; FreeQ[{a, b, e, f, m}, x] && NeQ[a^2 - b^2, 0]
 

rule 3480
Int[((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)])/(((a_.) + (b_.)*sin[(e_.) + (f_ 
.)*(x_)])*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)])), x_Symbol] :> Simp[(A*b 
- a*B)/(b*c - a*d)   Int[1/(a + b*Sin[e + f*x]), x], x] + Simp[(B*c - A*d)/ 
(b*c - a*d)   Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f 
, A, B}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 - d^2, 0]
 

rule 3535
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*sin[(e_.) + 
 (f_.)*(x_)])^(n_)*((A_.) + (C_.)*sin[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> 
Simp[(-(A*b^2 + a^2*C))*Cos[e + f*x]*(a + b*Sin[e + f*x])^(m + 1)*((c + d*S 
in[e + f*x])^(n + 1)/(f*(m + 1)*(b*c - a*d)*(a^2 - b^2))), x] + Simp[1/((m 
+ 1)*(b*c - a*d)*(a^2 - b^2))   Int[(a + b*Sin[e + f*x])^(m + 1)*(c + d*Sin 
[e + f*x])^n*Simp[a*(m + 1)*(b*c - a*d)*(A + C) + d*(A*b^2 + a^2*C)*(m + n 
+ 2) - (c*(A*b^2 + a^2*C) + b*(m + 1)*(b*c - a*d)*(A + C))*Sin[e + f*x] - d 
*(A*b^2 + a^2*C)*(m + n + 3)*Sin[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, 
d, e, f, A, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 
- d^2, 0] && LtQ[m, -1] && ((EqQ[a, 0] && IntegerQ[m] &&  !IntegerQ[n]) || 
 !(IntegerQ[2*n] && LtQ[n, -1] && ((IntegerQ[n] &&  !IntegerQ[m]) || EqQ[a, 
 0])))
 

rule 4257
Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] 
 /; FreeQ[{c, d}, x]
 
Maple [A] (verified)

Time = 0.58 (sec) , antiderivative size = 78, normalized size of antiderivative = 1.28

method result size
default \(\frac {-\frac {2 a \tanh \left (\frac {x}{2}\right )}{\tanh \left (\frac {x}{2}\right )^{2}+1}+2 b \arctan \left (\tanh \left (\frac {x}{2}\right )\right )}{a^{2}}+\frac {2 \left (a +b \right ) \left (a -b \right ) \operatorname {arctanh}\left (\frac {\left (a -b \right ) \tanh \left (\frac {x}{2}\right )}{\sqrt {\left (a +b \right ) \left (a -b \right )}}\right )}{a^{2} \sqrt {\left (a +b \right ) \left (a -b \right )}}\) \(78\)
risch \(\frac {2}{a \left ({\mathrm e}^{2 x}+1\right )}+\frac {\sqrt {a^{2}-b^{2}}\, \ln \left ({\mathrm e}^{x}-\frac {-a +\sqrt {a^{2}-b^{2}}}{b}\right )}{a^{2}}-\frac {\sqrt {a^{2}-b^{2}}\, \ln \left ({\mathrm e}^{x}+\frac {a +\sqrt {a^{2}-b^{2}}}{b}\right )}{a^{2}}+\frac {i b \ln \left ({\mathrm e}^{x}+i\right )}{a^{2}}-\frac {i b \ln \left ({\mathrm e}^{x}-i\right )}{a^{2}}\) \(117\)

Input:

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

Output:

2/a^2*(-a*tanh(1/2*x)/(tanh(1/2*x)^2+1)+b*arctan(tanh(1/2*x)))+2*(a+b)*(a- 
b)/a^2/((a+b)*(a-b))^(1/2)*arctanh((a-b)*tanh(1/2*x)/((a+b)*(a-b))^(1/2))
 

Fricas [B] (verification not implemented)

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

Time = 0.12 (sec) , antiderivative size = 326, normalized size of antiderivative = 5.34 \[ \int \frac {\tanh ^2(x)}{a+b \cosh (x)} \, dx=\left [\frac {\sqrt {a^{2} - b^{2}} {\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 {b^{2} \cosh \left (x\right )^{2} + b^{2} \sinh \left (x\right )^{2} + 2 \, a b \cosh \left (x\right ) + 2 \, a^{2} - b^{2} + 2 \, {\left (b^{2} \cosh \left (x\right ) + a b\right )} \sinh \left (x\right ) - 2 \, \sqrt {a^{2} - b^{2}} {\left (b \cosh \left (x\right ) + b \sinh \left (x\right ) + a\right )}}{b \cosh \left (x\right )^{2} + b \sinh \left (x\right )^{2} + 2 \, a \cosh \left (x\right ) + 2 \, {\left (b \cosh \left (x\right ) + a\right )} \sinh \left (x\right ) + b}\right ) + 2 \, {\left (b \cosh \left (x\right )^{2} + 2 \, b \cosh \left (x\right ) \sinh \left (x\right ) + b \sinh \left (x\right )^{2} + b\right )} \arctan \left (\cosh \left (x\right ) + \sinh \left (x\right )\right ) + 2 \, a}{a^{2} \cosh \left (x\right )^{2} + 2 \, a^{2} \cosh \left (x\right ) \sinh \left (x\right ) + a^{2} \sinh \left (x\right )^{2} + a^{2}}, -\frac {2 \, {\left (\sqrt {-a^{2} + b^{2}} {\left (\cosh \left (x\right )^{2} + 2 \, \cosh \left (x\right ) \sinh \left (x\right ) + \sinh \left (x\right )^{2} + 1\right )} \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \cosh \left (x\right ) + b \sinh \left (x\right ) + a\right )}}{a^{2} - b^{2}}\right ) - {\left (b \cosh \left (x\right )^{2} + 2 \, b \cosh \left (x\right ) \sinh \left (x\right ) + b \sinh \left (x\right )^{2} + b\right )} \arctan \left (\cosh \left (x\right ) + \sinh \left (x\right )\right ) - a\right )}}{a^{2} \cosh \left (x\right )^{2} + 2 \, a^{2} \cosh \left (x\right ) \sinh \left (x\right ) + a^{2} \sinh \left (x\right )^{2} + a^{2}}\right ] \] Input:

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

Output:

[(sqrt(a^2 - b^2)*(cosh(x)^2 + 2*cosh(x)*sinh(x) + sinh(x)^2 + 1)*log((b^2 
*cosh(x)^2 + b^2*sinh(x)^2 + 2*a*b*cosh(x) + 2*a^2 - b^2 + 2*(b^2*cosh(x) 
+ a*b)*sinh(x) - 2*sqrt(a^2 - b^2)*(b*cosh(x) + b*sinh(x) + a))/(b*cosh(x) 
^2 + b*sinh(x)^2 + 2*a*cosh(x) + 2*(b*cosh(x) + a)*sinh(x) + b)) + 2*(b*co 
sh(x)^2 + 2*b*cosh(x)*sinh(x) + b*sinh(x)^2 + b)*arctan(cosh(x) + sinh(x)) 
 + 2*a)/(a^2*cosh(x)^2 + 2*a^2*cosh(x)*sinh(x) + a^2*sinh(x)^2 + a^2), -2* 
(sqrt(-a^2 + b^2)*(cosh(x)^2 + 2*cosh(x)*sinh(x) + sinh(x)^2 + 1)*arctan(- 
sqrt(-a^2 + b^2)*(b*cosh(x) + b*sinh(x) + a)/(a^2 - b^2)) - (b*cosh(x)^2 + 
 2*b*cosh(x)*sinh(x) + b*sinh(x)^2 + b)*arctan(cosh(x) + sinh(x)) - a)/(a^ 
2*cosh(x)^2 + 2*a^2*cosh(x)*sinh(x) + a^2*sinh(x)^2 + a^2)]
 

Sympy [F]

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

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

Output:

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

Maxima [F(-2)]

Exception generated. \[ \int \frac {\tanh ^2(x)}{a+b \cosh (x)} \, dx=\text {Exception raised: ValueError} \] Input:

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

Output:

Exception raised: ValueError >> Computation failed since Maxima requested 
additional constraints; using the 'assume' command before evaluation *may* 
 help (example of legal syntax is 'assume(4*a^2-4*b^2>0)', see `assume?` f 
or more de
 

Giac [A] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 67, normalized size of antiderivative = 1.10 \[ \int \frac {\tanh ^2(x)}{a+b \cosh (x)} \, dx=\frac {2 \, b \arctan \left (e^{x}\right )}{a^{2}} + \frac {2 \, {\left (a^{2} - b^{2}\right )} \arctan \left (\frac {b e^{x} + a}{\sqrt {-a^{2} + b^{2}}}\right )}{\sqrt {-a^{2} + b^{2}} a^{2}} + \frac {2}{a {\left (e^{\left (2 \, x\right )} + 1\right )}} \] Input:

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

Output:

2*b*arctan(e^x)/a^2 + 2*(a^2 - b^2)*arctan((b*e^x + a)/sqrt(-a^2 + b^2))/( 
sqrt(-a^2 + b^2)*a^2) + 2/(a*(e^(2*x) + 1))
 

Mupad [B] (verification not implemented)

Time = 4.60 (sec) , antiderivative size = 285, normalized size of antiderivative = 4.67 \[ \int \frac {\tanh ^2(x)}{a+b \cosh (x)} \, dx=\frac {2}{a+a\,{\mathrm {e}}^{2\,x}}+\frac {\ln \left (64\,a^3\,b-64\,a\,b^3-32\,b^3\,\sqrt {a^2-b^2}+128\,a^4\,{\mathrm {e}}^x+32\,b^4\,{\mathrm {e}}^x+64\,a^2\,b\,\sqrt {a^2-b^2}+128\,a^3\,{\mathrm {e}}^x\,\sqrt {a^2-b^2}-160\,a^2\,b^2\,{\mathrm {e}}^x-96\,a\,b^2\,{\mathrm {e}}^x\,\sqrt {a^2-b^2}\right )\,\sqrt {a^2-b^2}}{a^2}-\frac {\ln \left (64\,a^3\,b-64\,a\,b^3+32\,b^3\,\sqrt {a^2-b^2}+128\,a^4\,{\mathrm {e}}^x+32\,b^4\,{\mathrm {e}}^x-64\,a^2\,b\,\sqrt {a^2-b^2}-128\,a^3\,{\mathrm {e}}^x\,\sqrt {a^2-b^2}-160\,a^2\,b^2\,{\mathrm {e}}^x+96\,a\,b^2\,{\mathrm {e}}^x\,\sqrt {a^2-b^2}\right )\,\sqrt {a^2-b^2}}{a^2}-\frac {b\,\left (\ln \left ({\mathrm {e}}^x-\mathrm {i}\right )\,1{}\mathrm {i}-\ln \left ({\mathrm {e}}^x+1{}\mathrm {i}\right )\,1{}\mathrm {i}\right )}{a^2} \] Input:

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

Output:

2/(a + a*exp(2*x)) + (log(64*a^3*b - 64*a*b^3 - 32*b^3*(a^2 - b^2)^(1/2) + 
 128*a^4*exp(x) + 32*b^4*exp(x) + 64*a^2*b*(a^2 - b^2)^(1/2) + 128*a^3*exp 
(x)*(a^2 - b^2)^(1/2) - 160*a^2*b^2*exp(x) - 96*a*b^2*exp(x)*(a^2 - b^2)^( 
1/2))*(a^2 - b^2)^(1/2))/a^2 - (log(64*a^3*b - 64*a*b^3 + 32*b^3*(a^2 - b^ 
2)^(1/2) + 128*a^4*exp(x) + 32*b^4*exp(x) - 64*a^2*b*(a^2 - b^2)^(1/2) - 1 
28*a^3*exp(x)*(a^2 - b^2)^(1/2) - 160*a^2*b^2*exp(x) + 96*a*b^2*exp(x)*(a^ 
2 - b^2)^(1/2))*(a^2 - b^2)^(1/2))/a^2 - (b*(log(exp(x) - 1i)*1i - log(exp 
(x) + 1i)*1i))/a^2
 

Reduce [B] (verification not implemented)

Time = 0.21 (sec) , antiderivative size = 111, normalized size of antiderivative = 1.82 \[ \int \frac {\tanh ^2(x)}{a+b \cosh (x)} \, dx=\frac {2 e^{2 x} \mathit {atan} \left (e^{x}\right ) b +2 \mathit {atan} \left (e^{x}\right ) b -2 e^{2 x} \sqrt {-a^{2}+b^{2}}\, \mathit {atan} \left (\frac {e^{x} b +a}{\sqrt {-a^{2}+b^{2}}}\right )-2 \sqrt {-a^{2}+b^{2}}\, \mathit {atan} \left (\frac {e^{x} b +a}{\sqrt {-a^{2}+b^{2}}}\right )-2 e^{2 x} a}{a^{2} \left (e^{2 x}+1\right )} \] Input:

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

Output:

(2*(e**(2*x)*atan(e**x)*b + atan(e**x)*b - e**(2*x)*sqrt( - a**2 + b**2)*a 
tan((e**x*b + a)/sqrt( - a**2 + b**2)) - sqrt( - a**2 + b**2)*atan((e**x*b 
 + a)/sqrt( - a**2 + b**2)) - e**(2*x)*a))/(a**2*(e**(2*x) + 1))