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

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

[Out]

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

________________________________________________________________________________________

Rubi [A]
time = 0.11, antiderivative size = 91, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.231, Rules used = {3587, 755, 815} \begin {gather*} -\frac {\cosh ^2(x) (b-a \tanh (x))}{2 \left (a^2-b^2\right )}+\frac {b^3 \log (a+b \tanh (x))}{\left (a^2-b^2\right )^2}-\frac {(a+2 b) \log (1-\tanh (x))}{4 (a+b)^2}+\frac {(a-2 b) \log (\tanh (x)+1)}{4 (a-b)^2} \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

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

Rule 755

Int[((d_) + (e_.)*(x_))^(m_)*((a_) + (c_.)*(x_)^2)^(p_), x_Symbol] :> Simp[(-(d + e*x)^(m + 1))*(a*e + c*d*x)*
((a + c*x^2)^(p + 1)/(2*a*(p + 1)*(c*d^2 + a*e^2))), x] + Dist[1/(2*a*(p + 1)*(c*d^2 + a*e^2)), Int[(d + e*x)^
m*Simp[c*d^2*(2*p + 3) + a*e^2*(m + 2*p + 3) + c*e*d*(m + 2*p + 4)*x, x]*(a + c*x^2)^(p + 1), x], x] /; FreeQ[
{a, c, d, e, m}, x] && NeQ[c*d^2 + a*e^2, 0] && LtQ[p, -1] && IntQuadraticQ[a, 0, c, d, e, m, p, x]

Rule 815

Int[(((d_.) + (e_.)*(x_))^(m_)*((f_.) + (g_.)*(x_)))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Int[ExpandIntegrand[(
d + e*x)^m*((f + g*x)/(a + c*x^2)), x], x] /; FreeQ[{a, c, d, e, f, g}, x] && NeQ[c*d^2 + a*e^2, 0] && Integer
Q[m]

Rule 3587

Int[sec[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Dist[1/(b*f), Subst
[Int[(a + x)^n*(1 + x^2/b^2)^(m/2 - 1), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x] && NeQ[a^2 + b
^2, 0] && IntegerQ[m/2]

Rubi steps

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

________________________________________________________________________________________

Mathematica [A]
time = 0.09, size = 75, normalized size = 0.82 \begin {gather*} \frac {2 a^3 x-6 a b^2 x+\left (-a^2 b+b^3\right ) \cosh (2 x)+4 b^3 \log (a \cosh (x)+b \sinh (x))+a \left (a^2-b^2\right ) \sinh (2 x)}{4 (a-b)^2 (a+b)^2} \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

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

________________________________________________________________________________________

Maple [A]
time = 0.71, size = 153, normalized size = 1.68

method result size
risch \(\frac {x b}{\left (a +b \right )^{2}}+\frac {a x}{2 \left (a +b \right )^{2}}+\frac {{\mathrm e}^{2 x}}{8 a +8 b}-\frac {{\mathrm e}^{-2 x}}{8 \left (a -b \right )}-\frac {2 b^{3} x}{a^{4}-2 a^{2} b^{2}+b^{4}}+\frac {b^{3} \ln \left ({\mathrm e}^{2 x}+\frac {a -b}{a +b}\right )}{a^{4}-2 a^{2} b^{2}+b^{4}}\) \(104\)
default \(\frac {b^{3} \ln \left (a \left (\tanh ^{2}\left (\frac {x}{2}\right )\right )+2 b \tanh \left (\frac {x}{2}\right )+a \right )}{\left (a -b \right )^{2} \left (a +b \right )^{2}}-\frac {1}{\left (2 a -2 b \right ) \left (\tanh \left (\frac {x}{2}\right )+1\right )^{2}}+\frac {2}{\left (4 a -4 b \right ) \left (\tanh \left (\frac {x}{2}\right )+1\right )}+\frac {\left (-2 b +a \right ) \ln \left (\tanh \left (\frac {x}{2}\right )+1\right )}{2 \left (a -b \right )^{2}}+\frac {1}{\left (2 b +2 a \right ) \left (\tanh \left (\frac {x}{2}\right )-1\right )^{2}}+\frac {2}{\left (4 a +4 b \right ) \left (\tanh \left (\frac {x}{2}\right )-1\right )}+\frac {\left (-2 b -a \right ) \ln \left (\tanh \left (\frac {x}{2}\right )-1\right )}{2 \left (a +b \right )^{2}}\) \(153\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Maxima [A]
time = 0.29, size = 86, normalized size = 0.95 \begin {gather*} \frac {b^{3} \log \left (-{\left (a - b\right )} e^{\left (-2 \, x\right )} - a - b\right )}{a^{4} - 2 \, a^{2} b^{2} + b^{4}} + \frac {{\left (a + 2 \, b\right )} x}{2 \, {\left (a^{2} + 2 \, a b + b^{2}\right )}} + \frac {e^{\left (2 \, x\right )}}{8 \, {\left (a + b\right )}} - \frac {e^{\left (-2 \, x\right )}}{8 \, {\left (a - b\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 331 vs. \(2 (86) = 172\).
time = 0.40, size = 331, normalized size = 3.64 \begin {gather*} \frac {{\left (a^{3} - a^{2} b - a b^{2} + b^{3}\right )} \cosh \left (x\right )^{4} + 4 \, {\left (a^{3} - a^{2} b - a b^{2} + b^{3}\right )} \cosh \left (x\right ) \sinh \left (x\right )^{3} + {\left (a^{3} - a^{2} b - a b^{2} + b^{3}\right )} \sinh \left (x\right )^{4} + 4 \, {\left (a^{3} - 3 \, a b^{2} - 2 \, b^{3}\right )} x \cosh \left (x\right )^{2} - a^{3} - a^{2} b + a b^{2} + b^{3} + 2 \, {\left (3 \, {\left (a^{3} - a^{2} b - a b^{2} + b^{3}\right )} \cosh \left (x\right )^{2} + 2 \, {\left (a^{3} - 3 \, a b^{2} - 2 \, b^{3}\right )} x\right )} \sinh \left (x\right )^{2} + 8 \, {\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}\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 ) + 4 \, {\left ({\left (a^{3} - a^{2} b - a b^{2} + b^{3}\right )} \cosh \left (x\right )^{3} + 2 \, {\left (a^{3} - 3 \, a b^{2} - 2 \, b^{3}\right )} x \cosh \left (x\right )\right )} \sinh \left (x\right )}{8 \, {\left ({\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} \cosh \left (x\right )^{2} + 2 \, {\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} \cosh \left (x\right ) \sinh \left (x\right ) + {\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} \sinh \left (x\right )^{2}\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\cosh ^{2}{\left (x \right )}}{a + b \tanh {\left (x \right )}}\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Giac [A]
time = 0.42, size = 111, normalized size = 1.22 \begin {gather*} \frac {b^{3} \log \left ({\left | a e^{\left (2 \, x\right )} + b e^{\left (2 \, x\right )} + a - b \right |}\right )}{a^{4} - 2 \, a^{2} b^{2} + b^{4}} + \frac {{\left (a - 2 \, b\right )} x}{2 \, {\left (a^{2} - 2 \, a b + b^{2}\right )}} - \frac {{\left (2 \, a e^{\left (2 \, x\right )} - 4 \, b e^{\left (2 \, x\right )} + a - b\right )} e^{\left (-2 \, x\right )}}{8 \, {\left (a^{2} - 2 \, a b + b^{2}\right )}} + \frac {e^{\left (2 \, x\right )}}{8 \, {\left (a + b\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Mupad [B]
time = 1.28, size = 84, normalized size = 0.92 \begin {gather*} \frac {{\mathrm {e}}^{2\,x}}{8\,a+8\,b}-\frac {{\mathrm {e}}^{-2\,x}}{8\,a-8\,b}+\frac {b^3\,\ln \left (a-b+a\,{\mathrm {e}}^{2\,x}+b\,{\mathrm {e}}^{2\,x}\right )}{a^4-2\,a^2\,b^2+b^4}+\frac {x\,\left (a-2\,b\right )}{2\,{\left (a-b\right )}^2} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________