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]
________________________________________________________________________________________
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]
[Out]
Rule 755
Rule 815
Rule 3587
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________