\(\int \frac {\tanh ^2(x)}{\sqrt {1+\tanh (x)}} \, dx\) [131]

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

Optimal result

Integrand size = 13, antiderivative size = 42 \[ \int \frac {\tanh ^2(x)}{\sqrt {1+\tanh (x)}} \, dx=\frac {\text {arctanh}\left (\frac {\sqrt {1+\tanh (x)}}{\sqrt {2}}\right )}{\sqrt {2}}-\frac {1}{\sqrt {1+\tanh (x)}}-2 \sqrt {1+\tanh (x)} \]

[Out]

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

Rubi [A] (verified)

Time = 0.05 (sec) , antiderivative size = 42, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.308, Rules used = {3624, 3560, 3561, 212} \[ \int \frac {\tanh ^2(x)}{\sqrt {1+\tanh (x)}} \, dx=\frac {\text {arctanh}\left (\frac {\sqrt {\tanh (x)+1}}{\sqrt {2}}\right )}{\sqrt {2}}-2 \sqrt {\tanh (x)+1}-\frac {1}{\sqrt {\tanh (x)+1}} \]

[In]

Int[Tanh[x]^2/Sqrt[1 + Tanh[x]],x]

[Out]

ArcTanh[Sqrt[1 + Tanh[x]]/Sqrt[2]]/Sqrt[2] - 1/Sqrt[1 + Tanh[x]] - 2*Sqrt[1 + Tanh[x]]

Rule 212

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

Rule 3560

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[a*((a + b*Tan[c + d*x])^n/(2*b*d*n)), x] +
Dist[1/(2*a), Int[(a + b*Tan[c + d*x])^(n + 1), x], x] /; FreeQ[{a, b, c, d}, x] && EqQ[a^2 + b^2, 0] && LtQ[n
, 0]

Rule 3561

Int[Sqrt[(a_) + (b_.)*tan[(c_.) + (d_.)*(x_)]], x_Symbol] :> Dist[-2*(b/d), Subst[Int[1/(2*a - x^2), x], x, Sq
rt[a + b*Tan[c + d*x]]], x] /; FreeQ[{a, b, c, d}, x] && EqQ[a^2 + b^2, 0]

Rule 3624

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> Simp[
d^2*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Simp[c^2 - d^2 + 2*c*d*Tan[e
 + f*x], x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && NeQ[b*c - a*d, 0] &&  !LeQ[m, -1] &&  !(EqQ[m, 2] && EqQ
[a, 0])

Rubi steps \begin{align*} \text {integral}& = -2 \sqrt {1+\tanh (x)}+\int \frac {1}{\sqrt {1+\tanh (x)}} \, dx \\ & = -\frac {1}{\sqrt {1+\tanh (x)}}-2 \sqrt {1+\tanh (x)}+\frac {1}{2} \int \sqrt {1+\tanh (x)} \, dx \\ & = -\frac {1}{\sqrt {1+\tanh (x)}}-2 \sqrt {1+\tanh (x)}+\text {Subst}\left (\int \frac {1}{2-x^2} \, dx,x,\sqrt {1+\tanh (x)}\right ) \\ & = \frac {\text {arctanh}\left (\frac {\sqrt {1+\tanh (x)}}{\sqrt {2}}\right )}{\sqrt {2}}-\frac {1}{\sqrt {1+\tanh (x)}}-2 \sqrt {1+\tanh (x)} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.54 (sec) , antiderivative size = 34, normalized size of antiderivative = 0.81 \[ \int \frac {\tanh ^2(x)}{\sqrt {1+\tanh (x)}} \, dx=\frac {-\operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},\frac {1}{2} (1+\tanh (x))\right )-2 (1+\tanh (x))}{\sqrt {1+\tanh (x)}} \]

[In]

Integrate[Tanh[x]^2/Sqrt[1 + Tanh[x]],x]

[Out]

(-Hypergeometric2F1[-1/2, 1, 1/2, (1 + Tanh[x])/2] - 2*(1 + Tanh[x]))/Sqrt[1 + Tanh[x]]

Maple [A] (verified)

Time = 0.07 (sec) , antiderivative size = 35, normalized size of antiderivative = 0.83

method result size
derivativedivides \(\frac {\operatorname {arctanh}\left (\frac {\sqrt {1+\tanh \left (x \right )}\, \sqrt {2}}{2}\right ) \sqrt {2}}{2}-\frac {1}{\sqrt {1+\tanh \left (x \right )}}-2 \sqrt {1+\tanh \left (x \right )}\) \(35\)
default \(\frac {\operatorname {arctanh}\left (\frac {\sqrt {1+\tanh \left (x \right )}\, \sqrt {2}}{2}\right ) \sqrt {2}}{2}-\frac {1}{\sqrt {1+\tanh \left (x \right )}}-2 \sqrt {1+\tanh \left (x \right )}\) \(35\)

[In]

int(tanh(x)^2/(1+tanh(x))^(1/2),x,method=_RETURNVERBOSE)

[Out]

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 182 vs. \(2 (34) = 68\).

Time = 0.25 (sec) , antiderivative size = 182, normalized size of antiderivative = 4.33 \[ \int \frac {\tanh ^2(x)}{\sqrt {1+\tanh (x)}} \, dx=-\frac {2 \, \sqrt {2} {\left (5 \, \sqrt {2} \cosh \left (x\right )^{2} + 10 \, \sqrt {2} \cosh \left (x\right ) \sinh \left (x\right ) + 5 \, \sqrt {2} \sinh \left (x\right )^{2} + \sqrt {2}\right )} \sqrt {\frac {\cosh \left (x\right )}{\cosh \left (x\right ) - \sinh \left (x\right )}} - {\left (\sqrt {2} \cosh \left (x\right )^{3} + 3 \, \sqrt {2} \cosh \left (x\right ) \sinh \left (x\right )^{2} + \sqrt {2} \sinh \left (x\right )^{3} + {\left (3 \, \sqrt {2} \cosh \left (x\right )^{2} + \sqrt {2}\right )} \sinh \left (x\right ) + \sqrt {2} \cosh \left (x\right )\right )} \log \left (-2 \, \sqrt {2} \sqrt {\frac {\cosh \left (x\right )}{\cosh \left (x\right ) - \sinh \left (x\right )}} {\left (\cosh \left (x\right ) + \sinh \left (x\right )\right )} - 2 \, \cosh \left (x\right )^{2} - 4 \, \cosh \left (x\right ) \sinh \left (x\right ) - 2 \, \sinh \left (x\right )^{2} - 1\right )}{4 \, {\left (\cosh \left (x\right )^{3} + 3 \, \cosh \left (x\right ) \sinh \left (x\right )^{2} + \sinh \left (x\right )^{3} + {\left (3 \, \cosh \left (x\right )^{2} + 1\right )} \sinh \left (x\right ) + \cosh \left (x\right )\right )}} \]

[In]

integrate(tanh(x)^2/(1+tanh(x))^(1/2),x, algorithm="fricas")

[Out]

-1/4*(2*sqrt(2)*(5*sqrt(2)*cosh(x)^2 + 10*sqrt(2)*cosh(x)*sinh(x) + 5*sqrt(2)*sinh(x)^2 + sqrt(2))*sqrt(cosh(x
)/(cosh(x) - sinh(x))) - (sqrt(2)*cosh(x)^3 + 3*sqrt(2)*cosh(x)*sinh(x)^2 + sqrt(2)*sinh(x)^3 + (3*sqrt(2)*cos
h(x)^2 + sqrt(2))*sinh(x) + sqrt(2)*cosh(x))*log(-2*sqrt(2)*sqrt(cosh(x)/(cosh(x) - sinh(x)))*(cosh(x) + sinh(
x)) - 2*cosh(x)^2 - 4*cosh(x)*sinh(x) - 2*sinh(x)^2 - 1))/(cosh(x)^3 + 3*cosh(x)*sinh(x)^2 + sinh(x)^3 + (3*co
sh(x)^2 + 1)*sinh(x) + cosh(x))

Sympy [A] (verification not implemented)

Time = 1.47 (sec) , antiderivative size = 58, normalized size of antiderivative = 1.38 \[ \int \frac {\tanh ^2(x)}{\sqrt {1+\tanh (x)}} \, dx=- \frac {\sqrt {2} \left (\log {\left (\sqrt {\tanh {\left (x \right )} + 1} - \sqrt {2} \right )} - \log {\left (\sqrt {\tanh {\left (x \right )} + 1} + \sqrt {2} \right )}\right )}{4} - 2 \sqrt {\tanh {\left (x \right )} + 1} - \frac {1}{\sqrt {\tanh {\left (x \right )} + 1}} \]

[In]

integrate(tanh(x)**2/(1+tanh(x))**(1/2),x)

[Out]

-sqrt(2)*(log(sqrt(tanh(x) + 1) - sqrt(2)) - log(sqrt(tanh(x) + 1) + sqrt(2)))/4 - 2*sqrt(tanh(x) + 1) - 1/sqr
t(tanh(x) + 1)

Maxima [F]

\[ \int \frac {\tanh ^2(x)}{\sqrt {1+\tanh (x)}} \, dx=\int { \frac {\tanh \left (x\right )^{2}}{\sqrt {\tanh \left (x\right ) + 1}} \,d x } \]

[In]

integrate(tanh(x)^2/(1+tanh(x))^(1/2),x, algorithm="maxima")

[Out]

integrate(tanh(x)^2/sqrt(tanh(x) + 1), x)

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.29 \[ \int \frac {\tanh ^2(x)}{\sqrt {1+\tanh (x)}} \, dx=-\frac {1}{4} \, \sqrt {2} \log \left (-4 \, \sqrt {e^{\left (4 \, x\right )} + e^{\left (2 \, x\right )}} + 4 \, e^{\left (2 \, x\right )} + 2\right ) - \frac {5 \, \sqrt {2} e^{\left (2 \, x\right )} + \sqrt {2}}{2 \, \sqrt {e^{\left (4 \, x\right )} + e^{\left (2 \, x\right )}}} \]

[In]

integrate(tanh(x)^2/(1+tanh(x))^(1/2),x, algorithm="giac")

[Out]

-1/4*sqrt(2)*log(-4*sqrt(e^(4*x) + e^(2*x)) + 4*e^(2*x) + 2) - 1/2*(5*sqrt(2)*e^(2*x) + sqrt(2))/sqrt(e^(4*x)
+ e^(2*x))

Mupad [B] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 36, normalized size of antiderivative = 0.86 \[ \int \frac {\tanh ^2(x)}{\sqrt {1+\tanh (x)}} \, dx=\frac {\sqrt {2}\,\mathrm {atanh}\left (\frac {\sqrt {2}\,\sqrt {\mathrm {tanh}\left (x\right )+1}}{2}\right )}{2}-\frac {3}{\sqrt {\mathrm {tanh}\left (x\right )+1}}-\frac {2\,\mathrm {tanh}\left (x\right )}{\sqrt {\mathrm {tanh}\left (x\right )+1}} \]

[In]

int(tanh(x)^2/(tanh(x) + 1)^(1/2),x)

[Out]

(2^(1/2)*atanh((2^(1/2)*(tanh(x) + 1)^(1/2))/2))/2 - 3/(tanh(x) + 1)^(1/2) - (2*tanh(x))/(tanh(x) + 1)^(1/2)