3.7.81 \(\int (-\cosh (x)+\text {sech}(x))^2 \, dx\) [681]

Optimal. Leaf size=22 \[ -\frac {3 x}{2}+\frac {3 \tanh (x)}{2}+\frac {1}{2} \sinh ^2(x) \tanh (x) \]

[Out]

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

________________________________________________________________________________________

Rubi [A]
time = 0.02, antiderivative size = 22, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, integrand size = 9, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {294, 327, 212} \begin {gather*} -\frac {3 x}{2}+\frac {3 \tanh (x)}{2}+\frac {1}{2} \sinh ^2(x) \tanh (x) \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(-Cosh[x] + Sech[x])^2,x]

[Out]

(-3*x)/2 + (3*Tanh[x])/2 + (Sinh[x]^2*Tanh[x])/2

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 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 327

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*(m + n*p + 1))), x] - Dist[a*c^n*((m - n + 1)/(b*(m + n*p + 1))), Int[(c*x)^(m - n)*(a + b*x^n)^p
, x], x] /; FreeQ[{a, b, c, p}, x] && IGtQ[n, 0] && GtQ[m, n - 1] && NeQ[m + n*p + 1, 0] && IntBinomialQ[a, b,
 c, n, m, p, x]

Rubi steps

\begin {align*} \int (-\cosh (x)+\text {sech}(x))^2 \, dx &=\text {Subst}\left (\int \frac {x^4}{\left (1-x^2\right )^2} \, dx,x,\tanh (x)\right )\\ &=\frac {1}{2} \sinh ^2(x) \tanh (x)-\frac {3}{2} \text {Subst}\left (\int \frac {x^2}{1-x^2} \, dx,x,\tanh (x)\right )\\ &=\frac {3 \tanh (x)}{2}+\frac {1}{2} \sinh ^2(x) \tanh (x)-\frac {3}{2} \text {Subst}\left (\int \frac {1}{1-x^2} \, dx,x,\tanh (x)\right )\\ &=-\frac {3 x}{2}+\frac {3 \tanh (x)}{2}+\frac {1}{2} \sinh ^2(x) \tanh (x)\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.02, size = 16, normalized size = 0.73 \begin {gather*} -\frac {3 x}{2}+\frac {1}{4} \sinh (2 x)+\tanh (x) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(-Cosh[x] + Sech[x])^2,x]

[Out]

(-3*x)/2 + Sinh[2*x]/4 + Tanh[x]

________________________________________________________________________________________

Maple [A]
time = 0.74, size = 27, normalized size = 1.23

method result size
risch \(-\frac {3 x}{2}+\frac {{\mathrm e}^{2 x}}{8}-\frac {{\mathrm e}^{-2 x}}{8}-\frac {2}{1+{\mathrm e}^{2 x}}\) \(27\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((-cosh(x)+sech(x))^2,x,method=_RETURNVERBOSE)

[Out]

-3/2*x+1/8*exp(2*x)-1/8*exp(-2*x)-2/(1+exp(2*x))

________________________________________________________________________________________

Maxima [A]
time = 0.25, size = 26, normalized size = 1.18 \begin {gather*} -\frac {3}{2} \, x + \frac {2}{e^{\left (-2 \, x\right )} + 1} + \frac {1}{8} \, e^{\left (2 \, x\right )} - \frac {1}{8} \, e^{\left (-2 \, x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-cosh(x)+sech(x))^2,x, algorithm="maxima")

[Out]

-3/2*x + 2/(e^(-2*x) + 1) + 1/8*e^(2*x) - 1/8*e^(-2*x)

________________________________________________________________________________________

Fricas [A]
time = 0.34, size = 30, normalized size = 1.36 \begin {gather*} \frac {\sinh \left (x\right )^{3} - 4 \, {\left (3 \, x + 2\right )} \cosh \left (x\right ) + 3 \, {\left (\cosh \left (x\right )^{2} + 3\right )} \sinh \left (x\right )}{8 \, \cosh \left (x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-cosh(x)+sech(x))^2,x, algorithm="fricas")

[Out]

1/8*(sinh(x)^3 - 4*(3*x + 2)*cosh(x) + 3*(cosh(x)^2 + 3)*sinh(x))/cosh(x)

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \left (- \cosh {\left (x \right )} + \operatorname {sech}{\left (x \right )}\right )^{2}\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-cosh(x)+sech(x))**2,x)

[Out]

Integral((-cosh(x) + sech(x))**2, x)

________________________________________________________________________________________

Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 37 vs. \(2 (16) = 32\).
time = 0.40, size = 37, normalized size = 1.68 \begin {gather*} -\frac {3}{2} \, x + \frac {3 \, e^{\left (4 \, x\right )} - 14 \, e^{\left (2 \, x\right )} - 1}{8 \, {\left (e^{\left (4 \, x\right )} + e^{\left (2 \, x\right )}\right )}} + \frac {1}{8} \, e^{\left (2 \, x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-cosh(x)+sech(x))^2,x, algorithm="giac")

[Out]

-3/2*x + 1/8*(3*e^(4*x) - 14*e^(2*x) - 1)/(e^(4*x) + e^(2*x)) + 1/8*e^(2*x)

________________________________________________________________________________________

Mupad [B]
time = 1.54, size = 26, normalized size = 1.18 \begin {gather*} \frac {{\mathrm {e}}^{2\,x}}{8}-\frac {{\mathrm {e}}^{-2\,x}}{8}-\frac {3\,x}{2}-\frac {2}{{\mathrm {e}}^{2\,x}+1} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

exp(2*x)/8 - exp(-2*x)/8 - (3*x)/2 - 2/(exp(2*x) + 1)

________________________________________________________________________________________