\(\int \frac {1}{(\text {sech}^2(x)-\tanh ^2(x))^2} \, dx\) [818]

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

Optimal result

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

[Out]

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

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 31, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.308, Rules used = {425, 12, 492, 212} \[ \int \frac {1}{\left (\text {sech}^2(x)-\tanh ^2(x)\right )^2} \, dx=-\frac {\text {arctanh}\left (\sqrt {2} \tanh (x)\right )}{\sqrt {2}}+x+\frac {\tanh (x)}{1-2 \tanh ^2(x)} \]

[In]

Int[(Sech[x]^2 - Tanh[x]^2)^(-2),x]

[Out]

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

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, 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 425

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Simp[(-b)*x*(a + b*x^n)^(p + 1)*
((c + d*x^n)^(q + 1)/(a*n*(p + 1)*(b*c - a*d))), x] + Dist[1/(a*n*(p + 1)*(b*c - a*d)), Int[(a + b*x^n)^(p + 1
)*(c + d*x^n)^q*Simp[b*c + n*(p + 1)*(b*c - a*d) + d*b*(n*(p + q + 2) + 1)*x^n, x], x], x] /; FreeQ[{a, b, c,
d, n, q}, x] && NeQ[b*c - a*d, 0] && LtQ[p, -1] &&  !( !IntegerQ[p] && IntegerQ[q] && LtQ[q, -1]) && IntBinomi
alQ[a, b, c, d, n, p, q, x]

Rule 492

Int[((e_.)*(x_))^(m_.)/(((a_) + (b_.)*(x_)^(n_))*((c_) + (d_.)*(x_)^(n_))), x_Symbol] :> Dist[(-a)*(e^n/(b*c -
 a*d)), Int[(e*x)^(m - n)/(a + b*x^n), x], x] + Dist[c*(e^n/(b*c - a*d)), Int[(e*x)^(m - n)/(c + d*x^n), x], x
] /; FreeQ[{a, b, c, d, e, m}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && LeQ[n, m, 2*n - 1]

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

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 6.25 (sec) , antiderivative size = 549, normalized size of antiderivative = 17.71 \[ \int \frac {1}{\left (\text {sech}^2(x)-\tanh ^2(x)\right )^2} \, dx=\frac {\text {sech}(x) \left (-4 \sinh (x)-4 \sinh ^3(x)-(1+i) \sqrt {2} \left (\arctan \left (\frac {(1+i) \sqrt {(-1-i) (i+\sinh (x))}}{\sqrt {(2+2 i)-(2-2 i) \sinh (x)}}\right ) \sqrt {(1+i)-(1-i) \sinh (x)}+i \sqrt {1+i} \arcsin \left (\frac {1}{2} \sqrt {1+i} \sqrt {(-1-i) (i+\sinh (x))}\right ) \sqrt {1+i \sinh (x)}\right ) \sqrt {(-1-i) (i+\sinh (x))}+\text {arctanh}\left (\frac {\sqrt {(-1-i) (i+\sinh (x))}}{\sqrt {(1+i)-(1-i) \sinh (x)}}\right ) (-3+\cosh (2 x)) \sqrt {(1+i)-(1-i) \sinh (x)} \sqrt {(-1-i) (i+\sinh (x))}+(1+i) \sqrt {2} \left (\arctan \left (\frac {(1+i) \sqrt {(-1-i) (i+\sinh (x))}}{\sqrt {(2+2 i)-(2-2 i) \sinh (x)}}\right ) \sqrt {(1+i)-(1-i) \sinh (x)}+i \sqrt {1+i} \arcsin \left (\frac {1}{2} \sqrt {1+i} \sqrt {(-1-i) (i+\sinh (x))}\right ) \sqrt {1+i \sinh (x)}\right ) \sinh ^2(x) \sqrt {(-1-i) (i+\sinh (x))}+\frac {\text {arcsinh}\left (\frac {1}{2} \sqrt {-1+i} \sqrt {(1-i) (i+\sinh (x))}\right ) (-3+\cosh (2 x)) \sqrt {2+2 i \sinh (x)} \sqrt {(1-i) (i+\sinh (x))}}{\sqrt {-1+i}}-\text {arctanh}\left (\frac {\sqrt {(1-i) (i+\sinh (x))}}{\sqrt {(1+i) (-i+\sinh (x))}}\right ) (-3+\cosh (2 x)) \sqrt {(1+i) (-i+\sinh (x))} \sqrt {(1-i) (i+\sinh (x))}+\frac {(1+i) \text {arctanh}\left (\frac {(1+i) \sqrt {(1-i) (i+\sinh (x))}}{\sqrt {2} \sqrt {(1+i) (-i+\sinh (x))}}\right ) (-3+\cosh (2 x)) \sqrt {(1+i) (-i+\sinh (x))} \sqrt {(1-i) (i+\sinh (x))}}{\sqrt {2}}\right )}{2 (-3+\cosh (2 x))} \]

[In]

Integrate[(Sech[x]^2 - Tanh[x]^2)^(-2),x]

[Out]

(Sech[x]*(-4*Sinh[x] - 4*Sinh[x]^3 - (1 + I)*Sqrt[2]*(ArcTan[((1 + I)*Sqrt[(-1 - I)*(I + Sinh[x])])/Sqrt[(2 +
2*I) - (2 - 2*I)*Sinh[x]]]*Sqrt[(1 + I) - (1 - I)*Sinh[x]] + I*Sqrt[1 + I]*ArcSin[(Sqrt[1 + I]*Sqrt[(-1 - I)*(
I + Sinh[x])])/2]*Sqrt[1 + I*Sinh[x]])*Sqrt[(-1 - I)*(I + Sinh[x])] + ArcTanh[Sqrt[(-1 - I)*(I + Sinh[x])]/Sqr
t[(1 + I) - (1 - I)*Sinh[x]]]*(-3 + Cosh[2*x])*Sqrt[(1 + I) - (1 - I)*Sinh[x]]*Sqrt[(-1 - I)*(I + Sinh[x])] +
(1 + I)*Sqrt[2]*(ArcTan[((1 + I)*Sqrt[(-1 - I)*(I + Sinh[x])])/Sqrt[(2 + 2*I) - (2 - 2*I)*Sinh[x]]]*Sqrt[(1 +
I) - (1 - I)*Sinh[x]] + I*Sqrt[1 + I]*ArcSin[(Sqrt[1 + I]*Sqrt[(-1 - I)*(I + Sinh[x])])/2]*Sqrt[1 + I*Sinh[x]]
)*Sinh[x]^2*Sqrt[(-1 - I)*(I + Sinh[x])] + (ArcSinh[(Sqrt[-1 + I]*Sqrt[(1 - I)*(I + Sinh[x])])/2]*(-3 + Cosh[2
*x])*Sqrt[2 + (2*I)*Sinh[x]]*Sqrt[(1 - I)*(I + Sinh[x])])/Sqrt[-1 + I] - ArcTanh[Sqrt[(1 - I)*(I + Sinh[x])]/S
qrt[(1 + I)*(-I + Sinh[x])]]*(-3 + Cosh[2*x])*Sqrt[(1 + I)*(-I + Sinh[x])]*Sqrt[(1 - I)*(I + Sinh[x])] + ((1 +
 I)*ArcTanh[((1 + I)*Sqrt[(1 - I)*(I + Sinh[x])])/(Sqrt[2]*Sqrt[(1 + I)*(-I + Sinh[x])])]*(-3 + Cosh[2*x])*Sqr
t[(1 + I)*(-I + Sinh[x])]*Sqrt[(1 - I)*(I + Sinh[x])])/Sqrt[2]))/(2*(-3 + Cosh[2*x]))

Maple [A] (verified)

Time = 16.12 (sec) , antiderivative size = 2, normalized size of antiderivative = 0.06

method result size
parallelrisch \(0\) \(2\)
risch \(x -\frac {2 \left (3 \,{\mathrm e}^{2 x}-1\right )}{{\mathrm e}^{4 x}-6 \,{\mathrm e}^{2 x}+1}+\frac {\sqrt {2}\, \ln \left ({\mathrm e}^{2 x}-3-2 \sqrt {2}\right )}{4}-\frac {\sqrt {2}\, \ln \left ({\mathrm e}^{2 x}+2 \sqrt {2}-3\right )}{4}\) \(61\)
default \(-\frac {-2 \tanh \left (\frac {x}{2}\right )+2}{2 \left (\tanh \left (\frac {x}{2}\right )^{2}+2 \tanh \left (\frac {x}{2}\right )-1\right )}-\frac {\sqrt {2}\, \operatorname {arctanh}\left (\frac {\left (2 \tanh \left (\frac {x}{2}\right )+2\right ) \sqrt {2}}{4}\right )}{2}+\ln \left (1+\tanh \left (\frac {x}{2}\right )\right )+\frac {2 \tanh \left (\frac {x}{2}\right )+2}{2 \tanh \left (\frac {x}{2}\right )^{2}-4 \tanh \left (\frac {x}{2}\right )-2}-\frac {\sqrt {2}\, \operatorname {arctanh}\left (\frac {\left (2 \tanh \left (\frac {x}{2}\right )-2\right ) \sqrt {2}}{4}\right )}{2}-\ln \left (\tanh \left (\frac {x}{2}\right )-1\right )\) \(108\)

[In]

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

[Out]

0

Fricas [B] (verification not implemented)

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

Time = 0.29 (sec) , antiderivative size = 266, normalized size of antiderivative = 8.58 \[ \int \frac {1}{\left (\text {sech}^2(x)-\tanh ^2(x)\right )^2} \, dx=\frac {4 \, x \cosh \left (x\right )^{4} + 16 \, x \cosh \left (x\right ) \sinh \left (x\right )^{3} + 4 \, x \sinh \left (x\right )^{4} - 24 \, {\left (x + 1\right )} \cosh \left (x\right )^{2} + 24 \, {\left (x \cosh \left (x\right )^{2} - x - 1\right )} \sinh \left (x\right )^{2} + {\left (\sqrt {2} \cosh \left (x\right )^{4} + 4 \, \sqrt {2} \cosh \left (x\right ) \sinh \left (x\right )^{3} + \sqrt {2} \sinh \left (x\right )^{4} + 6 \, {\left (\sqrt {2} \cosh \left (x\right )^{2} - \sqrt {2}\right )} \sinh \left (x\right )^{2} - 6 \, \sqrt {2} \cosh \left (x\right )^{2} + 4 \, {\left (\sqrt {2} \cosh \left (x\right )^{3} - 3 \, \sqrt {2} \cosh \left (x\right )\right )} \sinh \left (x\right ) + \sqrt {2}\right )} \log \left (\frac {3 \, {\left (2 \, \sqrt {2} + 3\right )} \cosh \left (x\right )^{2} - 4 \, {\left (3 \, \sqrt {2} + 4\right )} \cosh \left (x\right ) \sinh \left (x\right ) + 3 \, {\left (2 \, \sqrt {2} + 3\right )} \sinh \left (x\right )^{2} - 2 \, \sqrt {2} - 3}{\cosh \left (x\right )^{2} + \sinh \left (x\right )^{2} - 3}\right ) + 16 \, {\left (x \cosh \left (x\right )^{3} - 3 \, {\left (x + 1\right )} \cosh \left (x\right )\right )} \sinh \left (x\right ) + 4 \, x + 8}{4 \, {\left (\cosh \left (x\right )^{4} + 4 \, \cosh \left (x\right ) \sinh \left (x\right )^{3} + \sinh \left (x\right )^{4} + 6 \, {\left (\cosh \left (x\right )^{2} - 1\right )} \sinh \left (x\right )^{2} - 6 \, \cosh \left (x\right )^{2} + 4 \, {\left (\cosh \left (x\right )^{3} - 3 \, \cosh \left (x\right )\right )} \sinh \left (x\right ) + 1\right )}} \]

[In]

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

[Out]

1/4*(4*x*cosh(x)^4 + 16*x*cosh(x)*sinh(x)^3 + 4*x*sinh(x)^4 - 24*(x + 1)*cosh(x)^2 + 24*(x*cosh(x)^2 - x - 1)*
sinh(x)^2 + (sqrt(2)*cosh(x)^4 + 4*sqrt(2)*cosh(x)*sinh(x)^3 + sqrt(2)*sinh(x)^4 + 6*(sqrt(2)*cosh(x)^2 - sqrt
(2))*sinh(x)^2 - 6*sqrt(2)*cosh(x)^2 + 4*(sqrt(2)*cosh(x)^3 - 3*sqrt(2)*cosh(x))*sinh(x) + sqrt(2))*log((3*(2*
sqrt(2) + 3)*cosh(x)^2 - 4*(3*sqrt(2) + 4)*cosh(x)*sinh(x) + 3*(2*sqrt(2) + 3)*sinh(x)^2 - 2*sqrt(2) - 3)/(cos
h(x)^2 + sinh(x)^2 - 3)) + 16*(x*cosh(x)^3 - 3*(x + 1)*cosh(x))*sinh(x) + 4*x + 8)/(cosh(x)^4 + 4*cosh(x)*sinh
(x)^3 + sinh(x)^4 + 6*(cosh(x)^2 - 1)*sinh(x)^2 - 6*cosh(x)^2 + 4*(cosh(x)^3 - 3*cosh(x))*sinh(x) + 1)

Sympy [F]

\[ \int \frac {1}{\left (\text {sech}^2(x)-\tanh ^2(x)\right )^2} \, dx=\int \frac {1}{\left (- \tanh {\left (x \right )} + \operatorname {sech}{\left (x \right )}\right )^{2} \left (\tanh {\left (x \right )} + \operatorname {sech}{\left (x \right )}\right )^{2}}\, dx \]

[In]

integrate(1/(sech(x)**2-tanh(x)**2)**2,x)

[Out]

Integral(1/((-tanh(x) + sech(x))**2*(tanh(x) + sech(x))**2), x)

Maxima [B] (verification not implemented)

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

Time = 0.29 (sec) , antiderivative size = 88, normalized size of antiderivative = 2.84 \[ \int \frac {1}{\left (\text {sech}^2(x)-\tanh ^2(x)\right )^2} \, dx=-\frac {1}{4} \, \sqrt {2} \log \left (-\frac {\sqrt {2} - e^{\left (-x\right )} + 1}{\sqrt {2} + e^{\left (-x\right )} - 1}\right ) + \frac {1}{4} \, \sqrt {2} \log \left (-\frac {\sqrt {2} - e^{\left (-x\right )} - 1}{\sqrt {2} + e^{\left (-x\right )} + 1}\right ) + x - \frac {2 \, {\left (3 \, e^{\left (-2 \, x\right )} - 1\right )}}{6 \, e^{\left (-2 \, x\right )} - e^{\left (-4 \, x\right )} - 1} \]

[In]

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

[Out]

-1/4*sqrt(2)*log(-(sqrt(2) - e^(-x) + 1)/(sqrt(2) + e^(-x) - 1)) + 1/4*sqrt(2)*log(-(sqrt(2) - e^(-x) - 1)/(sq
rt(2) + e^(-x) + 1)) + x - 2*(3*e^(-2*x) - 1)/(6*e^(-2*x) - e^(-4*x) - 1)

Giac [B] (verification not implemented)

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

Time = 0.27 (sec) , antiderivative size = 63, normalized size of antiderivative = 2.03 \[ \int \frac {1}{\left (\text {sech}^2(x)-\tanh ^2(x)\right )^2} \, dx=\frac {1}{4} \, \sqrt {2} \log \left (\frac {{\left | -4 \, \sqrt {2} + 2 \, e^{\left (2 \, x\right )} - 6 \right |}}{{\left | 4 \, \sqrt {2} + 2 \, e^{\left (2 \, x\right )} - 6 \right |}}\right ) + x - \frac {2 \, {\left (3 \, e^{\left (2 \, x\right )} - 1\right )}}{e^{\left (4 \, x\right )} - 6 \, e^{\left (2 \, x\right )} + 1} \]

[In]

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

[Out]

1/4*sqrt(2)*log(abs(-4*sqrt(2) + 2*e^(2*x) - 6)/abs(4*sqrt(2) + 2*e^(2*x) - 6)) + x - 2*(3*e^(2*x) - 1)/(e^(4*
x) - 6*e^(2*x) + 1)

Mupad [B] (verification not implemented)

Time = 2.24 (sec) , antiderivative size = 78, normalized size of antiderivative = 2.52 \[ \int \frac {1}{\left (\text {sech}^2(x)-\tanh ^2(x)\right )^2} \, dx=x-\frac {\sqrt {2}\,\ln \left (-4\,{\mathrm {e}}^{2\,x}-\frac {\sqrt {2}\,\left (12\,{\mathrm {e}}^{2\,x}-4\right )}{4}\right )}{4}+\frac {\sqrt {2}\,\ln \left (\frac {\sqrt {2}\,\left (12\,{\mathrm {e}}^{2\,x}-4\right )}{4}-4\,{\mathrm {e}}^{2\,x}\right )}{4}-\frac {6\,{\mathrm {e}}^{2\,x}-2}{{\mathrm {e}}^{4\,x}-6\,{\mathrm {e}}^{2\,x}+1} \]

[In]

int(1/(1/cosh(x)^2 - tanh(x)^2)^2,x)

[Out]

x - (2^(1/2)*log(- 4*exp(2*x) - (2^(1/2)*(12*exp(2*x) - 4))/4))/4 + (2^(1/2)*log((2^(1/2)*(12*exp(2*x) - 4))/4
 - 4*exp(2*x)))/4 - (6*exp(2*x) - 2)/(exp(4*x) - 6*exp(2*x) + 1)