\(\int x \tanh ^2(x) \, dx\) [596]

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

Optimal result

Integrand size = 6, antiderivative size = 16 \[ \int x \tanh ^2(x) \, dx=\frac {x^2}{2}+\log (\cosh (x))-x \tanh (x) \]

[Out]

1/2*x^2+ln(cosh(x))-x*tanh(x)

Rubi [A] (verified)

Time = 0.01 (sec) , antiderivative size = 16, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.500, Rules used = {3801, 3556, 30} \[ \int x \tanh ^2(x) \, dx=\frac {x^2}{2}-x \tanh (x)+\log (\cosh (x)) \]

[In]

Int[x*Tanh[x]^2,x]

[Out]

x^2/2 + Log[Cosh[x]] - x*Tanh[x]

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3801

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

Rubi steps \begin{align*} \text {integral}& = -x \tanh (x)+\int x \, dx+\int \tanh (x) \, dx \\ & = \frac {x^2}{2}+\log (\cosh (x))-x \tanh (x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.01 (sec) , antiderivative size = 16, normalized size of antiderivative = 1.00 \[ \int x \tanh ^2(x) \, dx=\frac {x^2}{2}+\log (\cosh (x))-x \tanh (x) \]

[In]

Integrate[x*Tanh[x]^2,x]

[Out]

x^2/2 + Log[Cosh[x]] - x*Tanh[x]

Maple [A] (verified)

Time = 0.04 (sec) , antiderivative size = 24, normalized size of antiderivative = 1.50

method result size
parallelrisch \(\frac {x^{2}}{2}-x \tanh \left (x \right )-x -\ln \left (1-\tanh \left (x \right )\right )\) \(24\)
risch \(\frac {x^{2}}{2}-2 x +\frac {2 x}{1+{\mathrm e}^{2 x}}+\ln \left (1+{\mathrm e}^{2 x}\right )\) \(28\)

[In]

int(x*tanh(x)^2,x,method=_RETURNVERBOSE)

[Out]

1/2*x^2-x*tanh(x)-x-ln(1-tanh(x))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 93 vs. \(2 (14) = 28\).

Time = 0.25 (sec) , antiderivative size = 93, normalized size of antiderivative = 5.81 \[ \int x \tanh ^2(x) \, dx=\frac {{\left (x^{2} - 4 \, x\right )} \cosh \left (x\right )^{2} + 2 \, {\left (x^{2} - 4 \, x\right )} \cosh \left (x\right ) \sinh \left (x\right ) + {\left (x^{2} - 4 \, x\right )} \sinh \left (x\right )^{2} + x^{2} + 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 {2 \, \cosh \left (x\right )}{\cosh \left (x\right ) - \sinh \left (x\right )}\right )}{2 \, {\left (\cosh \left (x\right )^{2} + 2 \, \cosh \left (x\right ) \sinh \left (x\right ) + \sinh \left (x\right )^{2} + 1\right )}} \]

[In]

integrate(x*tanh(x)^2,x, algorithm="fricas")

[Out]

1/2*((x^2 - 4*x)*cosh(x)^2 + 2*(x^2 - 4*x)*cosh(x)*sinh(x) + (x^2 - 4*x)*sinh(x)^2 + x^2 + 2*(cosh(x)^2 + 2*co
sh(x)*sinh(x) + sinh(x)^2 + 1)*log(2*cosh(x)/(cosh(x) - sinh(x))))/(cosh(x)^2 + 2*cosh(x)*sinh(x) + sinh(x)^2
+ 1)

Sympy [A] (verification not implemented)

Time = 0.06 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.06 \[ \int x \tanh ^2(x) \, dx=\frac {x^{2}}{2} - x \tanh {\left (x \right )} + x - \log {\left (\tanh {\left (x \right )} + 1 \right )} \]

[In]

integrate(x*tanh(x)**2,x)

[Out]

x**2/2 - x*tanh(x) + x - log(tanh(x) + 1)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 49 vs. \(2 (14) = 28\).

Time = 0.31 (sec) , antiderivative size = 49, normalized size of antiderivative = 3.06 \[ \int x \tanh ^2(x) \, dx=-\frac {x e^{\left (2 \, x\right )}}{e^{\left (2 \, x\right )} + 1} + \frac {x^{2} + {\left (x^{2} - 2 \, x\right )} e^{\left (2 \, x\right )}}{2 \, {\left (e^{\left (2 \, x\right )} + 1\right )}} + \log \left (e^{\left (2 \, x\right )} + 1\right ) \]

[In]

integrate(x*tanh(x)^2,x, algorithm="maxima")

[Out]

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

Giac [B] (verification not implemented)

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

Time = 0.30 (sec) , antiderivative size = 51, normalized size of antiderivative = 3.19 \[ \int x \tanh ^2(x) \, dx=\frac {x^{2} e^{\left (2 \, x\right )} + x^{2} - 4 \, x e^{\left (2 \, x\right )} + 2 \, e^{\left (2 \, x\right )} \log \left (e^{\left (2 \, x\right )} + 1\right ) + 2 \, \log \left (e^{\left (2 \, x\right )} + 1\right )}{2 \, {\left (e^{\left (2 \, x\right )} + 1\right )}} \]

[In]

integrate(x*tanh(x)^2,x, algorithm="giac")

[Out]

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

Mupad [B] (verification not implemented)

Time = 0.43 (sec) , antiderivative size = 21, normalized size of antiderivative = 1.31 \[ \int x \tanh ^2(x) \, dx=\ln \left ({\mathrm {e}}^{2\,x}+1\right )-x-x\,\mathrm {tanh}\left (x\right )+\frac {x^2}{2} \]

[In]

int(x*tanh(x)^2,x)

[Out]

log(exp(2*x) + 1) - x - x*tanh(x) + x^2/2