Optimal. Leaf size=76 \[ \frac {a x}{a^2-b^2}-\frac {b \log (\cosh (x))}{a^2-b^2}-\frac {a^4 \log (a+b \tanh (x))}{b^3 \left (a^2-b^2\right )}+\frac {a \tanh (x)}{b^2}-\frac {\tanh ^2(x)}{2 b} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.16, antiderivative size = 76, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.462, Rules used = {3647, 3728,
3708, 3698, 31, 3556} \begin {gather*} \frac {a x}{a^2-b^2}-\frac {b \log (\cosh (x))}{a^2-b^2}-\frac {a^4 \log (a+b \tanh (x))}{b^3 \left (a^2-b^2\right )}+\frac {a \tanh (x)}{b^2}-\frac {\tanh ^2(x)}{2 b} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 31
Rule 3556
Rule 3647
Rule 3698
Rule 3708
Rule 3728
Rubi steps
\begin {align*} \int \frac {\tanh ^4(x)}{a+b \tanh (x)} \, dx &=-\frac {\tanh ^2(x)}{2 b}-\frac {\int \frac {\tanh (x) \left (-2 a-2 b \tanh (x)+2 a \tanh ^2(x)\right )}{a+b \tanh (x)} \, dx}{2 b}\\ &=\frac {a \tanh (x)}{b^2}-\frac {\tanh ^2(x)}{2 b}-\frac {\int \frac {2 a^2-2 \left (a^2+b^2\right ) \tanh ^2(x)}{a+b \tanh (x)} \, dx}{2 b^2}\\ &=\frac {a x}{a^2-b^2}+\frac {a \tanh (x)}{b^2}-\frac {\tanh ^2(x)}{2 b}-\frac {a^4 \int \frac {1-\tanh ^2(x)}{a+b \tanh (x)} \, dx}{b^2 \left (a^2-b^2\right )}-\frac {b \int \tanh (x) \, dx}{a^2-b^2}\\ &=\frac {a x}{a^2-b^2}-\frac {b \log (\cosh (x))}{a^2-b^2}+\frac {a \tanh (x)}{b^2}-\frac {\tanh ^2(x)}{2 b}-\frac {a^4 \text {Subst}\left (\int \frac {1}{a+x} \, dx,x,b \tanh (x)\right )}{b^3 \left (a^2-b^2\right )}\\ &=\frac {a x}{a^2-b^2}-\frac {b \log (\cosh (x))}{a^2-b^2}-\frac {a^4 \log (a+b \tanh (x))}{b^3 \left (a^2-b^2\right )}+\frac {a \tanh (x)}{b^2}-\frac {\tanh ^2(x)}{2 b}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.22, size = 88, normalized size = 1.16 \begin {gather*} \frac {b^2 \left (a^2-b^2\right ) \text {sech}^2(x)+2 \left (a b^3 x+\left (a^4-b^4\right ) \log (\cosh (x))-a^4 \log (a \cosh (x)+b \sinh (x))+a b \left (a^2-b^2\right ) \tanh (x)\right )}{2 (a-b) b^3 (a+b)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.32, size = 76, normalized size = 1.00
method | result | size |
derivativedivides | \(\frac {-\frac {b \left (\tanh ^{2}\left (x \right )\right )}{2}+a \tanh \left (x \right )}{b^{2}}+\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 {a^{4} \ln \left (a +b \tanh \left (x \right )\right )}{b^{3} \left (a +b \right ) \left (a -b \right )}\) | \(76\) |
default | \(\frac {-\frac {b \left (\tanh ^{2}\left (x \right )\right )}{2}+a \tanh \left (x \right )}{b^{2}}+\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 {a^{4} \ln \left (a +b \tanh \left (x \right )\right )}{b^{3} \left (a +b \right ) \left (a -b \right )}\) | \(76\) |
risch | \(\frac {x}{a +b}-\frac {2 x \,a^{2}}{b^{3}}-\frac {2 x}{b}+\frac {2 x \,a^{4}}{b^{3} \left (a^{2}-b^{2}\right )}-\frac {2 \left ({\mathrm e}^{2 x} a -b \,{\mathrm e}^{2 x}+a \right )}{\left (1+{\mathrm e}^{2 x}\right )^{2} b^{2}}+\frac {\ln \left (1+{\mathrm e}^{2 x}\right ) a^{2}}{b^{3}}+\frac {\ln \left (1+{\mathrm e}^{2 x}\right )}{b}-\frac {a^{4} \ln \left ({\mathrm e}^{2 x}+\frac {a -b}{a +b}\right )}{b^{3} \left (a^{2}-b^{2}\right )}\) | \(133\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.48, size = 100, normalized size = 1.32 \begin {gather*} -\frac {a^{4} \log \left (-{\left (a - b\right )} e^{\left (-2 \, x\right )} - a - b\right )}{a^{2} b^{3} - b^{5}} + \frac {2 \, {\left ({\left (a + b\right )} e^{\left (-2 \, x\right )} + a\right )}}{2 \, b^{2} e^{\left (-2 \, x\right )} + b^{2} e^{\left (-4 \, x\right )} + b^{2}} + \frac {x}{a + b} + \frac {{\left (a^{2} + b^{2}\right )} \log \left (e^{\left (-2 \, x\right )} + 1\right )}{b^{3}} \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. 644 vs.
\(2 (74) = 148\).
time = 0.37, size = 644, normalized size = 8.47 \begin {gather*} \frac {{\left (a b^{3} + b^{4}\right )} x \cosh \left (x\right )^{4} + 4 \, {\left (a b^{3} + b^{4}\right )} x \cosh \left (x\right ) \sinh \left (x\right )^{3} + {\left (a b^{3} + b^{4}\right )} x \sinh \left (x\right )^{4} - 2 \, a^{3} b + 2 \, a b^{3} - 2 \, {\left (a^{3} b - a^{2} b^{2} - a b^{3} + b^{4} - {\left (a b^{3} + b^{4}\right )} x\right )} \cosh \left (x\right )^{2} - 2 \, {\left (a^{3} b - a^{2} b^{2} - a b^{3} + b^{4} - 3 \, {\left (a b^{3} + b^{4}\right )} x \cosh \left (x\right )^{2} - {\left (a b^{3} + b^{4}\right )} x\right )} \sinh \left (x\right )^{2} + {\left (a b^{3} + b^{4}\right )} x - {\left (a^{4} \cosh \left (x\right )^{4} + 4 \, a^{4} \cosh \left (x\right ) \sinh \left (x\right )^{3} + a^{4} \sinh \left (x\right )^{4} + 2 \, a^{4} \cosh \left (x\right )^{2} + a^{4} + 2 \, {\left (3 \, a^{4} \cosh \left (x\right )^{2} + a^{4}\right )} \sinh \left (x\right )^{2} + 4 \, {\left (a^{4} \cosh \left (x\right )^{3} + a^{4} \cosh \left (x\right )\right )} \sinh \left (x\right )\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 ({\left (a^{4} - b^{4}\right )} \cosh \left (x\right )^{4} + 4 \, {\left (a^{4} - b^{4}\right )} \cosh \left (x\right ) \sinh \left (x\right )^{3} + {\left (a^{4} - b^{4}\right )} \sinh \left (x\right )^{4} + a^{4} - b^{4} + 2 \, {\left (a^{4} - b^{4}\right )} \cosh \left (x\right )^{2} + 2 \, {\left (a^{4} - b^{4} + 3 \, {\left (a^{4} - b^{4}\right )} \cosh \left (x\right )^{2}\right )} \sinh \left (x\right )^{2} + 4 \, {\left ({\left (a^{4} - b^{4}\right )} \cosh \left (x\right )^{3} + {\left (a^{4} - b^{4}\right )} \cosh \left (x\right )\right )} \sinh \left (x\right )\right )} \log \left (\frac {2 \, \cosh \left (x\right )}{\cosh \left (x\right ) - \sinh \left (x\right )}\right ) + 4 \, {\left ({\left (a b^{3} + b^{4}\right )} x \cosh \left (x\right )^{3} - {\left (a^{3} b - a^{2} b^{2} - a b^{3} + b^{4} - {\left (a b^{3} + b^{4}\right )} x\right )} \cosh \left (x\right )\right )} \sinh \left (x\right )}{a^{2} b^{3} - b^{5} + {\left (a^{2} b^{3} - b^{5}\right )} \cosh \left (x\right )^{4} + 4 \, {\left (a^{2} b^{3} - b^{5}\right )} \cosh \left (x\right ) \sinh \left (x\right )^{3} + {\left (a^{2} b^{3} - b^{5}\right )} \sinh \left (x\right )^{4} + 2 \, {\left (a^{2} b^{3} - b^{5}\right )} \cosh \left (x\right )^{2} + 2 \, {\left (a^{2} b^{3} - b^{5} + 3 \, {\left (a^{2} b^{3} - b^{5}\right )} \cosh \left (x\right )^{2}\right )} \sinh \left (x\right )^{2} + 4 \, {\left ({\left (a^{2} b^{3} - b^{5}\right )} \cosh \left (x\right )^{3} + {\left (a^{2} b^{3} - b^{5}\right )} \cosh \left (x\right )\right )} \sinh \left (x\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 442 vs.
\(2 (61) = 122\).
time = 0.48, size = 442, normalized size = 5.82 \begin {gather*} \begin {cases} \tilde {\infty } \left (x - \log {\left (\tanh {\left (x \right )} + 1 \right )} - \frac {\tanh ^{2}{\left (x \right )}}{2}\right ) & \text {for}\: a = 0 \wedge b = 0 \\\frac {7 x \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} - \frac {7 x}{2 b \tanh {\left (x \right )} - 2 b} - \frac {4 \log {\left (\tanh {\left (x \right )} + 1 \right )} \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} + \frac {4 \log {\left (\tanh {\left (x \right )} + 1 \right )}}{2 b \tanh {\left (x \right )} - 2 b} - \frac {\tanh ^{3}{\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} - \frac {\tanh ^{2}{\left (x \right )}}{2 b \tanh {\left (x \right )} - 2 b} + \frac {3}{2 b \tanh {\left (x \right )} - 2 b} & \text {for}\: a = - b \\\frac {x \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} + 2 b} + \frac {x}{2 b \tanh {\left (x \right )} + 2 b} - \frac {4 \log {\left (\tanh {\left (x \right )} + 1 \right )} \tanh {\left (x \right )}}{2 b \tanh {\left (x \right )} + 2 b} - \frac {4 \log {\left (\tanh {\left (x \right )} + 1 \right )}}{2 b \tanh {\left (x \right )} + 2 b} - \frac {\tanh ^{3}{\left (x \right )}}{2 b \tanh {\left (x \right )} + 2 b} + \frac {\tanh ^{2}{\left (x \right )}}{2 b \tanh {\left (x \right )} + 2 b} - \frac {3}{2 b \tanh {\left (x \right )} + 2 b} & \text {for}\: a = b \\\frac {x - \frac {\tanh ^{3}{\left (x \right )}}{3} - \tanh {\left (x \right )}}{a} & \text {for}\: b = 0 \\- \frac {2 a^{4} \log {\left (\frac {a}{b} + \tanh {\left (x \right )} \right )}}{2 a^{2} b^{3} - 2 b^{5}} + \frac {2 a^{3} b \tanh {\left (x \right )}}{2 a^{2} b^{3} - 2 b^{5}} - \frac {a^{2} b^{2} \tanh ^{2}{\left (x \right )}}{2 a^{2} b^{3} - 2 b^{5}} + \frac {2 a b^{3} x}{2 a^{2} b^{3} - 2 b^{5}} - \frac {2 a b^{3} \tanh {\left (x \right )}}{2 a^{2} b^{3} - 2 b^{5}} - \frac {2 b^{4} x}{2 a^{2} b^{3} - 2 b^{5}} + \frac {2 b^{4} \log {\left (\tanh {\left (x \right )} + 1 \right )}}{2 a^{2} b^{3} - 2 b^{5}} + \frac {b^{4} \tanh ^{2}{\left (x \right )}}{2 a^{2} b^{3} - 2 b^{5}} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.40, size = 98, normalized size = 1.29 \begin {gather*} -\frac {a^{4} \log \left ({\left | a e^{\left (2 \, x\right )} + b e^{\left (2 \, x\right )} + a - b \right |}\right )}{a^{2} b^{3} - b^{5}} + \frac {x}{a - b} + \frac {{\left (a^{2} + b^{2}\right )} \log \left (e^{\left (2 \, x\right )} + 1\right )}{b^{3}} - \frac {2 \, {\left (a b + {\left (a b - b^{2}\right )} e^{\left (2 \, x\right )}\right )}}{b^{3} {\left (e^{\left (2 \, x\right )} + 1\right )}^{2}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 0.17, size = 68, normalized size = 0.89 \begin {gather*} \frac {x}{a+b}-\frac {{\mathrm {tanh}\left (x\right )}^2}{2\,b}+\frac {b\,\ln \left (\mathrm {tanh}\left (x\right )+1\right )}{a^2-b^2}+\frac {a\,\mathrm {tanh}\left (x\right )}{b^2}-\frac {a^4\,\ln \left (a+b\,\mathrm {tanh}\left (x\right )\right )}{b^3\,\left (a^2-b^2\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________