3.7.17 \(\int (a \text {sech}(x)+b \tanh (x))^2 \, dx\) [617]

Optimal. Leaf size=29 \[ b^2 x-a b \cosh (x)-\text {sech}(x) (b-a \sinh (x)) (a+b \sinh (x)) \]

[Out]

b^2*x-a*b*cosh(x)-sech(x)*(b-a*sinh(x))*(a+b*sinh(x))

________________________________________________________________________________________

Rubi [A]
time = 0.04, antiderivative size = 29, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, integrand size = 11, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.273, Rules used = {4476, 2770, 2718} \begin {gather*} -a b \cosh (x)-\text {sech}(x) (b-a \sinh (x)) (a+b \sinh (x))+b^2 x \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(a*Sech[x] + b*Tanh[x])^2,x]

[Out]

b^2*x - a*b*Cosh[x] - Sech[x]*(b - a*Sinh[x])*(a + b*Sinh[x])

Rule 2718

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

Rule 2770

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> Simp[(-(g*C
os[e + f*x])^(p + 1))*(a + b*Sin[e + f*x])^(m - 1)*((b + a*Sin[e + f*x])/(f*g*(p + 1))), x] + Dist[1/(g^2*(p +
 1)), Int[(g*Cos[e + f*x])^(p + 2)*(a + b*Sin[e + f*x])^(m - 2)*(b^2*(m - 1) + a^2*(p + 2) + a*b*(m + p + 1)*S
in[e + f*x]), x], x] /; FreeQ[{a, b, e, f, g}, x] && NeQ[a^2 - b^2, 0] && GtQ[m, 1] && LtQ[p, -1] && (Integers
Q[2*m, 2*p] || IntegerQ[m])

Rule 4476

Int[(u_.)*((b_.)*sec[(c_.) + (d_.)*(x_)]^(n_.) + (a_.)*tan[(c_.) + (d_.)*(x_)]^(n_.))^(p_), x_Symbol] :> Int[A
ctivateTrig[u]*Sec[c + d*x]^(n*p)*(b + a*Sin[c + d*x]^n)^p, x] /; FreeQ[{a, b, c, d}, x] && IntegersQ[n, p]

Rubi steps

\begin {align*} \int (a \text {sech}(x)+b \tanh (x))^2 \, dx &=\int \text {sech}^2(x) (a+b \sinh (x))^2 \, dx\\ &=-\text {sech}(x) (b-a \sinh (x)) (a+b \sinh (x))-\int \left (-b^2+a b \sinh (x)\right ) \, dx\\ &=b^2 x-\text {sech}(x) (b-a \sinh (x)) (a+b \sinh (x))-(a b) \int \sinh (x) \, dx\\ &=b^2 x-a b \cosh (x)-\text {sech}(x) (b-a \sinh (x)) (a+b \sinh (x))\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.03, size = 26, normalized size = 0.90 \begin {gather*} b^2 \tanh ^{-1}(\tanh (x))-2 a b \text {sech}(x)+\left (a^2-b^2\right ) \tanh (x) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(a*Sech[x] + b*Tanh[x])^2,x]

[Out]

b^2*ArcTanh[Tanh[x]] - 2*a*b*Sech[x] + (a^2 - b^2)*Tanh[x]

________________________________________________________________________________________

Maple [A]
time = 0.62, size = 32, normalized size = 1.10

method result size
risch \(b^{2} x -\frac {2 \left (2 b \,{\mathrm e}^{x} a +a^{2}-b^{2}\right )}{1+{\mathrm e}^{2 x}}\) \(32\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

b^2*x-2*(2*b*exp(x)*a+a^2-b^2)/(1+exp(2*x))

________________________________________________________________________________________

Maxima [A]
time = 0.26, size = 43, normalized size = 1.48 \begin {gather*} b^{2} {\left (x - \frac {2}{e^{\left (-2 \, x\right )} + 1}\right )} - \frac {4 \, a b}{e^{\left (-x\right )} + e^{x}} + \frac {2 \, a^{2}}{e^{\left (-2 \, x\right )} + 1} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Fricas [A]
time = 0.42, size = 42, normalized size = 1.45 \begin {gather*} -\frac {2 \, a b - {\left (b^{2} x - a^{2} + b^{2}\right )} \cosh \left (x\right ) - {\left (a^{2} - b^{2}\right )} \sinh \left (x\right )}{\cosh \left (x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-(2*a*b - (b^2*x - a^2 + b^2)*cosh(x) - (a^2 - b^2)*sinh(x))/cosh(x)

________________________________________________________________________________________

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

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a*sech(x)+b*tanh(x))**2,x)

[Out]

Integral((a*sech(x) + b*tanh(x))**2, x)

________________________________________________________________________________________

Giac [A]
time = 0.40, size = 31, normalized size = 1.07 \begin {gather*} b^{2} x - \frac {2 \, {\left (2 \, a b e^{x} + a^{2} - b^{2}\right )}}{e^{\left (2 \, x\right )} + 1} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

b^2*x - 2*(2*a*b*e^x + a^2 - b^2)/(e^(2*x) + 1)

________________________________________________________________________________________

Mupad [B]
time = 1.57, size = 33, normalized size = 1.14 \begin {gather*} b^2\,x-\frac {2\,a^2+4\,{\mathrm {e}}^x\,a\,b-2\,b^2}{{\mathrm {e}}^{2\,x}+1} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((b*tanh(x) + a/cosh(x))^2,x)

[Out]

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

________________________________________________________________________________________