\(\int \tanh ^2(a+2 \log (x)) \, dx\) [156]

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

Optimal result

Integrand size = 9, antiderivative size = 165 \[ \int \tanh ^2(a+2 \log (x)) \, dx=x+\frac {x}{1+e^{2 a} x^4}+\frac {e^{-a/2} \arctan \left (1-\sqrt {2} e^{a/2} x\right )}{2 \sqrt {2}}-\frac {e^{-a/2} \arctan \left (1+\sqrt {2} e^{a/2} x\right )}{2 \sqrt {2}}+\frac {e^{-a/2} \log \left (1-\sqrt {2} e^{a/2} x+e^a x^2\right )}{4 \sqrt {2}}-\frac {e^{-a/2} \log \left (1+\sqrt {2} e^{a/2} x+e^a x^2\right )}{4 \sqrt {2}} \]

[Out]

x+x/(1+exp(2*a)*x^4)-1/4*arctan(-1+exp(1/2*a)*x*2^(1/2))/exp(1/2*a)*2^(1/2)-1/4*arctan(1+exp(1/2*a)*x*2^(1/2))
/exp(1/2*a)*2^(1/2)+1/8*ln(1+exp(a)*x^2-exp(1/2*a)*x*2^(1/2))/exp(1/2*a)*2^(1/2)-1/8*ln(1+exp(a)*x^2+exp(1/2*a
)*x*2^(1/2))/exp(1/2*a)*2^(1/2)

Rubi [A] (verified)

Time = 0.10 (sec) , antiderivative size = 165, normalized size of antiderivative = 1.00, number of steps used = 13, number of rules used = 9, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 1.000, Rules used = {5652, 398, 294, 217, 1179, 642, 1176, 631, 210} \[ \int \tanh ^2(a+2 \log (x)) \, dx=\frac {e^{-a/2} \arctan \left (1-\sqrt {2} e^{a/2} x\right )}{2 \sqrt {2}}-\frac {e^{-a/2} \arctan \left (\sqrt {2} e^{a/2} x+1\right )}{2 \sqrt {2}}+\frac {x}{e^{2 a} x^4+1}+\frac {e^{-a/2} \log \left (e^a x^2-\sqrt {2} e^{a/2} x+1\right )}{4 \sqrt {2}}-\frac {e^{-a/2} \log \left (e^a x^2+\sqrt {2} e^{a/2} x+1\right )}{4 \sqrt {2}}+x \]

[In]

Int[Tanh[a + 2*Log[x]]^2,x]

[Out]

x + x/(1 + E^(2*a)*x^4) + ArcTan[1 - Sqrt[2]*E^(a/2)*x]/(2*Sqrt[2]*E^(a/2)) - ArcTan[1 + Sqrt[2]*E^(a/2)*x]/(2
*Sqrt[2]*E^(a/2)) + Log[1 - Sqrt[2]*E^(a/2)*x + E^a*x^2]/(4*Sqrt[2]*E^(a/2)) - Log[1 + Sqrt[2]*E^(a/2)*x + E^a
*x^2]/(4*Sqrt[2]*E^(a/2))

Rule 210

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

Rule 217

Int[((a_) + (b_.)*(x_)^4)^(-1), x_Symbol] :> With[{r = Numerator[Rt[a/b, 2]], s = Denominator[Rt[a/b, 2]]}, Di
st[1/(2*r), Int[(r - s*x^2)/(a + b*x^4), x], x] + Dist[1/(2*r), Int[(r + s*x^2)/(a + b*x^4), x], x]] /; FreeQ[
{a, b}, x] && (GtQ[a/b, 0] || (PosQ[a/b] && AtomQ[SplitProduct[SumBaseQ, a]] && AtomQ[SplitProduct[SumBaseQ, b
]]))

Rule 294

Int[((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[c^(n - 1)*(c*x)^(m - n + 1)*((a + b*x^
n)^(p + 1)/(b*n*(p + 1))), x] - Dist[c^n*((m - n + 1)/(b*n*(p + 1))), Int[(c*x)^(m - n)*(a + b*x^n)^(p + 1), x
], x] /; FreeQ[{a, b, c}, x] && IGtQ[n, 0] && LtQ[p, -1] && GtQ[m + 1, n] &&  !ILtQ[(m + n*(p + 1) + 1)/n, 0]
&& IntBinomialQ[a, b, c, n, m, p, x]

Rule 398

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Int[PolynomialDivide[(a + b*x^n)
^p, (c + d*x^n)^(-q), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && IGtQ[p, 0] && ILt
Q[q, 0] && GeQ[p, -q]

Rule 631

Int[((a_) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> With[{q = 1 - 4*Simplify[a*(c/b^2)]}, Dist[-2/b, Sub
st[Int[1/(q - x^2), x], x, 1 + 2*c*(x/b)], x] /; RationalQ[q] && (EqQ[q^2, 1] ||  !RationalQ[b^2 - 4*a*c])] /;
 FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 642

Int[((d_) + (e_.)*(x_))/((a_.) + (b_.)*(x_) + (c_.)*(x_)^2), x_Symbol] :> Simp[d*(Log[RemoveContent[a + b*x +
c*x^2, x]]/b), x] /; FreeQ[{a, b, c, d, e}, x] && EqQ[2*c*d - b*e, 0]

Rule 1176

Int[((d_) + (e_.)*(x_)^2)/((a_) + (c_.)*(x_)^4), x_Symbol] :> With[{q = Rt[2*(d/e), 2]}, Dist[e/(2*c), Int[1/S
imp[d/e + q*x + x^2, x], x], x] + Dist[e/(2*c), Int[1/Simp[d/e - q*x + x^2, x], x], x]] /; FreeQ[{a, c, d, e},
 x] && EqQ[c*d^2 - a*e^2, 0] && PosQ[d*e]

Rule 1179

Int[((d_) + (e_.)*(x_)^2)/((a_) + (c_.)*(x_)^4), x_Symbol] :> With[{q = Rt[-2*(d/e), 2]}, Dist[e/(2*c*q), Int[
(q - 2*x)/Simp[d/e + q*x - x^2, x], x], x] + Dist[e/(2*c*q), Int[(q + 2*x)/Simp[d/e - q*x - x^2, x], x], x]] /
; FreeQ[{a, c, d, e}, x] && EqQ[c*d^2 - a*e^2, 0] && NegQ[d*e]

Rule 5652

Int[Tanh[((a_.) + Log[x_]*(b_.))*(d_.)]^(p_.), x_Symbol] :> Int[(-1 + E^(2*a*d)*x^(2*b*d))^p/(1 + E^(2*a*d)*x^
(2*b*d))^p, x] /; FreeQ[{a, b, d, p}, x]

Rubi steps \begin{align*} \text {integral}& = \int \frac {\left (-1+e^{2 a} x^4\right )^2}{\left (1+e^{2 a} x^4\right )^2} \, dx \\ & = \int \left (1-\frac {4 e^{2 a} x^4}{\left (1+e^{2 a} x^4\right )^2}\right ) \, dx \\ & = x-\left (4 e^{2 a}\right ) \int \frac {x^4}{\left (1+e^{2 a} x^4\right )^2} \, dx \\ & = x+\frac {x}{1+e^{2 a} x^4}-\int \frac {1}{1+e^{2 a} x^4} \, dx \\ & = x+\frac {x}{1+e^{2 a} x^4}-\frac {1}{2} \int \frac {1-e^a x^2}{1+e^{2 a} x^4} \, dx-\frac {1}{2} \int \frac {1+e^a x^2}{1+e^{2 a} x^4} \, dx \\ & = x+\frac {x}{1+e^{2 a} x^4}-\frac {1}{4} e^{-a} \int \frac {1}{e^{-a}-\sqrt {2} e^{-a/2} x+x^2} \, dx-\frac {1}{4} e^{-a} \int \frac {1}{e^{-a}+\sqrt {2} e^{-a/2} x+x^2} \, dx+\frac {e^{-a/2} \int \frac {\sqrt {2} e^{-a/2}+2 x}{-e^{-a}-\sqrt {2} e^{-a/2} x-x^2} \, dx}{4 \sqrt {2}}+\frac {e^{-a/2} \int \frac {\sqrt {2} e^{-a/2}-2 x}{-e^{-a}+\sqrt {2} e^{-a/2} x-x^2} \, dx}{4 \sqrt {2}} \\ & = x+\frac {x}{1+e^{2 a} x^4}+\frac {e^{-a/2} \log \left (1-\sqrt {2} e^{a/2} x+e^a x^2\right )}{4 \sqrt {2}}-\frac {e^{-a/2} \log \left (1+\sqrt {2} e^{a/2} x+e^a x^2\right )}{4 \sqrt {2}}-\frac {e^{-a/2} \text {Subst}\left (\int \frac {1}{-1-x^2} \, dx,x,1-\sqrt {2} e^{a/2} x\right )}{2 \sqrt {2}}+\frac {e^{-a/2} \text {Subst}\left (\int \frac {1}{-1-x^2} \, dx,x,1+\sqrt {2} e^{a/2} x\right )}{2 \sqrt {2}} \\ & = x+\frac {x}{1+e^{2 a} x^4}+\frac {e^{-a/2} \arctan \left (1-\sqrt {2} e^{a/2} x\right )}{2 \sqrt {2}}-\frac {e^{-a/2} \arctan \left (1+\sqrt {2} e^{a/2} x\right )}{2 \sqrt {2}}+\frac {e^{-a/2} \log \left (1-\sqrt {2} e^{a/2} x+e^a x^2\right )}{4 \sqrt {2}}-\frac {e^{-a/2} \log \left (1+\sqrt {2} e^{a/2} x+e^a x^2\right )}{4 \sqrt {2}} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.44 (sec) , antiderivative size = 146, normalized size of antiderivative = 0.88 \[ \int \tanh ^2(a+2 \log (x)) \, dx=\frac {1}{4} \left (4 x+\frac {4 x}{1+e^{2 a} x^4}+\sqrt [4]{-1} e^{-a/2} \log \left (\sqrt [4]{-1} e^{-a/2}-x\right )+(-1)^{3/4} e^{-a/2} \log \left ((-1)^{3/4} e^{-a/2}-x\right )-\sqrt [4]{-1} e^{-a/2} \log \left (\sqrt [4]{-1} e^{-a/2}+x\right )-(-1)^{3/4} e^{-a/2} \log \left ((-1)^{3/4} e^{-a/2}+x\right )\right ) \]

[In]

Integrate[Tanh[a + 2*Log[x]]^2,x]

[Out]

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

Maple [C] (verified)

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

Time = 0.05 (sec) , antiderivative size = 47, normalized size of antiderivative = 0.28

method result size
risch \(x +\frac {x}{1+{\mathrm e}^{2 a} x^{4}}-\frac {{\mathrm e}^{-2 a} \left (\munderset {\textit {\_R} =\operatorname {RootOf}\left ({\mathrm e}^{2 a} \textit {\_Z}^{4}+1\right )}{\sum }\frac {\ln \left (x -\textit {\_R} \right )}{\textit {\_R}^{3}}\right )}{4}\) \(47\)

[In]

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

[Out]

x+x/(1+exp(2*a)*x^4)-1/4*exp(-2*a)*sum(1/_R^3*ln(x-_R),_R=RootOf(exp(2*a)*_Z^4+1))

Fricas [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 0.25 (sec) , antiderivative size = 156, normalized size of antiderivative = 0.95 \[ \int \tanh ^2(a+2 \log (x)) \, dx=\frac {4 \, x^{5} e^{\left (2 \, a\right )} - {\left (x^{4} e^{\left (2 \, a\right )} + 1\right )} \left (-e^{\left (-2 \, a\right )}\right )^{\frac {1}{4}} \log \left (x + \left (-e^{\left (-2 \, a\right )}\right )^{\frac {1}{4}}\right ) + {\left (-i \, x^{4} e^{\left (2 \, a\right )} - i\right )} \left (-e^{\left (-2 \, a\right )}\right )^{\frac {1}{4}} \log \left (x + i \, \left (-e^{\left (-2 \, a\right )}\right )^{\frac {1}{4}}\right ) + {\left (i \, x^{4} e^{\left (2 \, a\right )} + i\right )} \left (-e^{\left (-2 \, a\right )}\right )^{\frac {1}{4}} \log \left (x - i \, \left (-e^{\left (-2 \, a\right )}\right )^{\frac {1}{4}}\right ) + {\left (x^{4} e^{\left (2 \, a\right )} + 1\right )} \left (-e^{\left (-2 \, a\right )}\right )^{\frac {1}{4}} \log \left (x - \left (-e^{\left (-2 \, a\right )}\right )^{\frac {1}{4}}\right ) + 8 \, x}{4 \, {\left (x^{4} e^{\left (2 \, a\right )} + 1\right )}} \]

[In]

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

[Out]

1/4*(4*x^5*e^(2*a) - (x^4*e^(2*a) + 1)*(-e^(-2*a))^(1/4)*log(x + (-e^(-2*a))^(1/4)) + (-I*x^4*e^(2*a) - I)*(-e
^(-2*a))^(1/4)*log(x + I*(-e^(-2*a))^(1/4)) + (I*x^4*e^(2*a) + I)*(-e^(-2*a))^(1/4)*log(x - I*(-e^(-2*a))^(1/4
)) + (x^4*e^(2*a) + 1)*(-e^(-2*a))^(1/4)*log(x - (-e^(-2*a))^(1/4)) + 8*x)/(x^4*e^(2*a) + 1)

Sympy [F]

\[ \int \tanh ^2(a+2 \log (x)) \, dx=\int \tanh ^{2}{\left (a + 2 \log {\left (x \right )} \right )}\, dx \]

[In]

integrate(tanh(a+2*ln(x))**2,x)

[Out]

Integral(tanh(a + 2*log(x))**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 138, normalized size of antiderivative = 0.84 \[ \int \tanh ^2(a+2 \log (x)) \, dx=-\frac {1}{4} \, \sqrt {2} \arctan \left (\frac {1}{2} \, \sqrt {2} {\left (2 \, x e^{a} + \sqrt {2} e^{\left (\frac {1}{2} \, a\right )}\right )} e^{\left (-\frac {1}{2} \, a\right )}\right ) e^{\left (-\frac {1}{2} \, a\right )} - \frac {1}{4} \, \sqrt {2} \arctan \left (\frac {1}{2} \, \sqrt {2} {\left (2 \, x e^{a} - \sqrt {2} e^{\left (\frac {1}{2} \, a\right )}\right )} e^{\left (-\frac {1}{2} \, a\right )}\right ) e^{\left (-\frac {1}{2} \, a\right )} - \frac {1}{8} \, \sqrt {2} e^{\left (-\frac {1}{2} \, a\right )} \log \left (x^{2} e^{a} + \sqrt {2} x e^{\left (\frac {1}{2} \, a\right )} + 1\right ) + \frac {1}{8} \, \sqrt {2} e^{\left (-\frac {1}{2} \, a\right )} \log \left (x^{2} e^{a} - \sqrt {2} x e^{\left (\frac {1}{2} \, a\right )} + 1\right ) + x + \frac {x}{x^{4} e^{\left (2 \, a\right )} + 1} \]

[In]

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

[Out]

-1/4*sqrt(2)*arctan(1/2*sqrt(2)*(2*x*e^a + sqrt(2)*e^(1/2*a))*e^(-1/2*a))*e^(-1/2*a) - 1/4*sqrt(2)*arctan(1/2*
sqrt(2)*(2*x*e^a - sqrt(2)*e^(1/2*a))*e^(-1/2*a))*e^(-1/2*a) - 1/8*sqrt(2)*e^(-1/2*a)*log(x^2*e^a + sqrt(2)*x*
e^(1/2*a) + 1) + 1/8*sqrt(2)*e^(-1/2*a)*log(x^2*e^a - sqrt(2)*x*e^(1/2*a) + 1) + x + x/(x^4*e^(2*a) + 1)

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 133, normalized size of antiderivative = 0.81 \[ \int \tanh ^2(a+2 \log (x)) \, dx=-\frac {1}{4} \, \sqrt {2} \arctan \left (\frac {1}{2} \, \sqrt {2} {\left (\sqrt {2} e^{\left (-\frac {1}{2} \, a\right )} + 2 \, x\right )} e^{\left (\frac {1}{2} \, a\right )}\right ) e^{\left (-\frac {1}{2} \, a\right )} - \frac {1}{4} \, \sqrt {2} \arctan \left (-\frac {1}{2} \, \sqrt {2} {\left (\sqrt {2} e^{\left (-\frac {1}{2} \, a\right )} - 2 \, x\right )} e^{\left (\frac {1}{2} \, a\right )}\right ) e^{\left (-\frac {1}{2} \, a\right )} - \frac {1}{8} \, \sqrt {2} e^{\left (-\frac {1}{2} \, a\right )} \log \left (\sqrt {2} x e^{\left (-\frac {1}{2} \, a\right )} + x^{2} + e^{\left (-a\right )}\right ) + \frac {1}{8} \, \sqrt {2} e^{\left (-\frac {1}{2} \, a\right )} \log \left (-\sqrt {2} x e^{\left (-\frac {1}{2} \, a\right )} + x^{2} + e^{\left (-a\right )}\right ) + x + \frac {x}{x^{4} e^{\left (2 \, a\right )} + 1} \]

[In]

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

[Out]

-1/4*sqrt(2)*arctan(1/2*sqrt(2)*(sqrt(2)*e^(-1/2*a) + 2*x)*e^(1/2*a))*e^(-1/2*a) - 1/4*sqrt(2)*arctan(-1/2*sqr
t(2)*(sqrt(2)*e^(-1/2*a) - 2*x)*e^(1/2*a))*e^(-1/2*a) - 1/8*sqrt(2)*e^(-1/2*a)*log(sqrt(2)*x*e^(-1/2*a) + x^2
+ e^(-a)) + 1/8*sqrt(2)*e^(-1/2*a)*log(-sqrt(2)*x*e^(-1/2*a) + x^2 + e^(-a)) + x + x/(x^4*e^(2*a) + 1)

Mupad [B] (verification not implemented)

Time = 1.72 (sec) , antiderivative size = 61, normalized size of antiderivative = 0.37 \[ \int \tanh ^2(a+2 \log (x)) \, dx=x-\frac {\mathrm {atan}\left (x\,{\left (-{\mathrm {e}}^{2\,a}\right )}^{1/4}\right )}{2\,{\left (-{\mathrm {e}}^{2\,a}\right )}^{1/4}}+\frac {x}{{\mathrm {e}}^{2\,a}\,x^4+1}+\frac {\mathrm {atan}\left (x\,{\left (-{\mathrm {e}}^{2\,a}\right )}^{1/4}\,1{}\mathrm {i}\right )\,1{}\mathrm {i}}{2\,{\left (-{\mathrm {e}}^{2\,a}\right )}^{1/4}} \]

[In]

int(tanh(a + 2*log(x))^2,x)

[Out]

x - atan(x*(-exp(2*a))^(1/4))/(2*(-exp(2*a))^(1/4)) + (atan(x*(-exp(2*a))^(1/4)*1i)*1i)/(2*(-exp(2*a))^(1/4))
+ x/(x^4*exp(2*a) + 1)