### 3.620 $$\int \frac{1}{(a \text{sech}(x)+b \tanh (x))^2} \, dx$$

Optimal. Leaf size=62 $\frac{2 a \tanh ^{-1}\left (\frac{b-a \tanh \left (\frac{x}{2}\right )}{\sqrt{a^2+b^2}}\right )}{b^2 \sqrt{a^2+b^2}}-\frac{\cosh (x)}{b (a+b \sinh (x))}+\frac{x}{b^2}$

[Out]

x/b^2 + (2*a*ArcTanh[(b - a*Tanh[x/2])/Sqrt[a^2 + b^2]])/(b^2*Sqrt[a^2 + b^2]) - Cosh[x]/(b*(a + b*Sinh[x]))

________________________________________________________________________________________

Rubi [A]  time = 0.126822, antiderivative size = 62, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 11, $$\frac{\text{number of rules}}{\text{integrand size}}$$ = 0.546, Rules used = {4391, 2693, 2735, 2660, 618, 206} $\frac{2 a \tanh ^{-1}\left (\frac{b-a \tanh \left (\frac{x}{2}\right )}{\sqrt{a^2+b^2}}\right )}{b^2 \sqrt{a^2+b^2}}-\frac{\cosh (x)}{b (a+b \sinh (x))}+\frac{x}{b^2}$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

x/b^2 + (2*a*ArcTanh[(b - a*Tanh[x/2])/Sqrt[a^2 + b^2]])/(b^2*Sqrt[a^2 + b^2]) - Cosh[x]/(b*(a + b*Sinh[x]))

Rule 4391

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]

Rule 2693

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

Rule 2735

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*x)/d
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
NeQ[a^2 - b^2, 0]

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 206

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

Rubi steps

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

Mathematica [C]  time = 3.68398, size = 659, normalized size = 10.63 $\frac{\cosh (x) \left (\sqrt{a+i b} \left (\sqrt{b^2} \sqrt{-\frac{b (\sinh (x)-i)}{a+i b}} \left (2 \sqrt [4]{-1} a \sqrt{b} (b+i a) \sin ^{-1}\left (\frac{\left (\frac{1}{2}+\frac{i}{2}\right ) \sqrt{a-i b} \sqrt{-\frac{b (\sinh (x)+i)}{a-i b}}}{\sqrt{b}}\right )-\sqrt{a-i b} \left (a^2+b^2\right ) \sqrt{1+i \sinh (x)} \sqrt{-\frac{b (\sinh (x)+i)}{a-i b}}\right )+2 i a^2 b \sqrt{a-i b} \sqrt{1+i \sinh (x)} \tan ^{-1}\left (\frac{\sqrt{-i b} \sqrt{-\frac{b (\sinh (x)+i)}{a-i b}}}{\sqrt{i b} \sqrt{-\frac{b (\sinh (x)-i)}{a+i b}}}\right )+2 \sinh (x) \left (\sqrt [4]{-1} \sqrt{b^2} b^{3/2} (b+i a) \sqrt{-\frac{b (\sinh (x)-i)}{a+i b}} \sin ^{-1}\left (\frac{\left (\frac{1}{2}+\frac{i}{2}\right ) \sqrt{a-i b} \sqrt{-\frac{b (\sinh (x)+i)}{a-i b}}}{\sqrt{b}}\right )+i a b^2 \sqrt{a-i b} \sqrt{1+i \sinh (x)} \tan ^{-1}\left (\frac{\sqrt{-i b} \sqrt{-\frac{b (\sinh (x)+i)}{a-i b}}}{\sqrt{i b} \sqrt{-\frac{b (\sinh (x)-i)}{a+i b}}}\right )\right )\right )+2 i a \sqrt{b^2} (b+i a) \sqrt{1+i \sinh (x)} (a+b \sinh (x)) \tanh ^{-1}\left (\frac{\sqrt{a-i b} \sqrt{-\frac{b (\sinh (x)+i)}{a-i b}}}{\sqrt{a+i b} \sqrt{-\frac{b (\sinh (x)-i)}{a+i b}}}\right )\right )}{b \sqrt{b^2} (a-i b)^{3/2} (a+i b)^{3/2} \sqrt{1+i \sinh (x)} \sqrt{-\frac{b (\sinh (x)-i)}{a+i b}} \sqrt{-\frac{b (\sinh (x)+i)}{a-i b}} (a+b \sinh (x))}$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

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

________________________________________________________________________________________

Maple [B]  time = 0.072, size = 119, normalized size = 1.9 \begin{align*}{\frac{1}{{b}^{2}}\ln \left ( \tanh \left ({\frac{x}{2}} \right ) +1 \right ) }+2\,{\frac{\tanh \left ( x/2 \right ) }{ \left ( a \left ( \tanh \left ( x/2 \right ) \right ) ^{2}-2\,\tanh \left ( x/2 \right ) b-a \right ) a}}+2\,{\frac{1}{b \left ( a \left ( \tanh \left ( x/2 \right ) \right ) ^{2}-2\,\tanh \left ( x/2 \right ) b-a \right ) }}-2\,{\frac{a}{{b}^{2}\sqrt{{a}^{2}+{b}^{2}}}{\it Artanh} \left ( 1/2\,{\frac{2\,a\tanh \left ( x/2 \right ) -2\,b}{\sqrt{{a}^{2}+{b}^{2}}}} \right ) }-{\frac{1}{{b}^{2}}\ln \left ( \tanh \left ({\frac{x}{2}} \right ) -1 \right ) } \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [B]  time = 2.40107, size = 933, normalized size = 15.05 \begin{align*} -\frac{{\left (a^{2} b + b^{3}\right )} x \cosh \left (x\right )^{2} +{\left (a^{2} b + b^{3}\right )} x \sinh \left (x\right )^{2} - 2 \, a^{2} b - 2 \, b^{3} +{\left (a b \cosh \left (x\right )^{2} + a b \sinh \left (x\right )^{2} + 2 \, a^{2} \cosh \left (x\right ) - a b + 2 \,{\left (a b \cosh \left (x\right ) + a^{2}\right )} \sinh \left (x\right )\right )} \sqrt{a^{2} + b^{2}} \log \left (\frac{b^{2} \cosh \left (x\right )^{2} + b^{2} \sinh \left (x\right )^{2} + 2 \, a b \cosh \left (x\right ) + 2 \, a^{2} + b^{2} + 2 \,{\left (b^{2} \cosh \left (x\right ) + a b\right )} \sinh \left (x\right ) + 2 \, \sqrt{a^{2} + b^{2}}{\left (b \cosh \left (x\right ) + b \sinh \left (x\right ) + a\right )}}{b \cosh \left (x\right )^{2} + b \sinh \left (x\right )^{2} + 2 \, a \cosh \left (x\right ) + 2 \,{\left (b \cosh \left (x\right ) + a\right )} \sinh \left (x\right ) - b}\right ) -{\left (a^{2} b + b^{3}\right )} x + 2 \,{\left (a^{3} + a b^{2} +{\left (a^{3} + a b^{2}\right )} x\right )} \cosh \left (x\right ) + 2 \,{\left (a^{3} + a b^{2} +{\left (a^{2} b + b^{3}\right )} x \cosh \left (x\right ) +{\left (a^{3} + a b^{2}\right )} x\right )} \sinh \left (x\right )}{a^{2} b^{3} + b^{5} -{\left (a^{2} b^{3} + b^{5}\right )} \cosh \left (x\right )^{2} -{\left (a^{2} b^{3} + b^{5}\right )} \sinh \left (x\right )^{2} - 2 \,{\left (a^{3} b^{2} + a b^{4}\right )} \cosh \left (x\right ) - 2 \,{\left (a^{3} b^{2} + a b^{4} +{\left (a^{2} b^{3} + b^{5}\right )} \cosh \left (x\right )\right )} \sinh \left (x\right )} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-((a^2*b + b^3)*x*cosh(x)^2 + (a^2*b + b^3)*x*sinh(x)^2 - 2*a^2*b - 2*b^3 + (a*b*cosh(x)^2 + a*b*sinh(x)^2 + 2
*a^2*cosh(x) - a*b + 2*(a*b*cosh(x) + a^2)*sinh(x))*sqrt(a^2 + b^2)*log((b^2*cosh(x)^2 + b^2*sinh(x)^2 + 2*a*b
*cosh(x) + 2*a^2 + b^2 + 2*(b^2*cosh(x) + a*b)*sinh(x) + 2*sqrt(a^2 + b^2)*(b*cosh(x) + b*sinh(x) + a))/(b*cos
h(x)^2 + b*sinh(x)^2 + 2*a*cosh(x) + 2*(b*cosh(x) + a)*sinh(x) - b)) - (a^2*b + b^3)*x + 2*(a^3 + a*b^2 + (a^3
+ a*b^2)*x)*cosh(x) + 2*(a^3 + a*b^2 + (a^2*b + b^3)*x*cosh(x) + (a^3 + a*b^2)*x)*sinh(x))/(a^2*b^3 + b^5 - (
a^2*b^3 + b^5)*cosh(x)^2 - (a^2*b^3 + b^5)*sinh(x)^2 - 2*(a^3*b^2 + a*b^4)*cosh(x) - 2*(a^3*b^2 + a*b^4 + (a^2
*b^3 + b^5)*cosh(x))*sinh(x))

________________________________________________________________________________________

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

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Giac [A]  time = 1.19518, size = 131, normalized size = 2.11 \begin{align*} -\frac{a \log \left (\frac{{\left | 2 \, b e^{x} + 2 \, a - 2 \, \sqrt{a^{2} + b^{2}} \right |}}{{\left | 2 \, b e^{x} + 2 \, a + 2 \, \sqrt{a^{2} + b^{2}} \right |}}\right )}{\sqrt{a^{2} + b^{2}} b^{2}} + \frac{x}{b^{2}} + \frac{2 \,{\left (a e^{x} - b\right )}}{{\left (b e^{\left (2 \, x\right )} + 2 \, a e^{x} - b\right )} b^{2}} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-a*log(abs(2*b*e^x + 2*a - 2*sqrt(a^2 + b^2))/abs(2*b*e^x + 2*a + 2*sqrt(a^2 + b^2)))/(sqrt(a^2 + b^2)*b^2) +
x/b^2 + 2*(a*e^x - b)/((b*e^(2*x) + 2*a*e^x - b)*b^2)