### 3.173 $$\int \frac{\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx$$

Optimal. Leaf size=46 $\frac{x}{a+b}-\frac{\sqrt{a} \tan ^{-1}\left (\frac{\sqrt{b} \tanh (c+d x)}{\sqrt{a}}\right )}{\sqrt{b} d (a+b)}$

[Out]

x/(a + b) - (Sqrt[a]*ArcTan[(Sqrt[b]*Tanh[c + d*x])/Sqrt[a]])/(Sqrt[b]*(a + b)*d)

________________________________________________________________________________________

Rubi [A]  time = 0.083218, antiderivative size = 46, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 4, integrand size = 23, $$\frac{\text{number of rules}}{\text{integrand size}}$$ = 0.174, Rules used = {3670, 481, 206, 205} $\frac{x}{a+b}-\frac{\sqrt{a} \tan ^{-1}\left (\frac{\sqrt{b} \tanh (c+d x)}{\sqrt{a}}\right )}{\sqrt{b} d (a+b)}$

Antiderivative was successfully veriﬁed.

[In]

Int[Tanh[c + d*x]^2/(a + b*Tanh[c + d*x]^2),x]

[Out]

x/(a + b) - (Sqrt[a]*ArcTan[(Sqrt[b]*Tanh[c + d*x])/Sqrt[a]])/(Sqrt[b]*(a + b)*d)

Rule 3670

Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol]
:> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[(c*ff)/f, Subst[Int[(((d*ff*x)/c)^m*(a + b*(ff*x)^n)^p)/(c^
2 + ff^2*x^2), x], x, (c*Tan[e + f*x])/ff], x]] /; FreeQ[{a, b, c, d, e, f, m, n, p}, x] && (IGtQ[p, 0] || EqQ
[n, 2] || EqQ[n, 4] || (IntegerQ[p] && RationalQ[n]))

Rule 481

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]

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])

Rule 205

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

Rubi steps

\begin{align*} \int \frac{\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx &=\frac{\operatorname{Subst}\left (\int \frac{x^2}{\left (1-x^2\right ) \left (a+b x^2\right )} \, dx,x,\tanh (c+d x)\right )}{d}\\ &=\frac{\operatorname{Subst}\left (\int \frac{1}{1-x^2} \, dx,x,\tanh (c+d x)\right )}{(a+b) d}-\frac{a \operatorname{Subst}\left (\int \frac{1}{a+b x^2} \, dx,x,\tanh (c+d x)\right )}{(a+b) d}\\ &=\frac{x}{a+b}-\frac{\sqrt{a} \tan ^{-1}\left (\frac{\sqrt{b} \tanh (c+d x)}{\sqrt{a}}\right )}{\sqrt{b} (a+b) d}\\ \end{align*}

Mathematica [A]  time = 0.0286573, size = 47, normalized size = 1.02 $\frac{\tanh ^{-1}(\tanh (c+d x))-\frac{\sqrt{a} \tan ^{-1}\left (\frac{\sqrt{b} \tanh (c+d x)}{\sqrt{a}}\right )}{\sqrt{b}}}{d (a+b)}$

Antiderivative was successfully veriﬁed.

[In]

Integrate[Tanh[c + d*x]^2/(a + b*Tanh[c + d*x]^2),x]

[Out]

(-((Sqrt[a]*ArcTan[(Sqrt[b]*Tanh[c + d*x])/Sqrt[a]])/Sqrt[b]) + ArcTanh[Tanh[c + d*x]])/((a + b)*d)

________________________________________________________________________________________

Maple [A]  time = 0.016, size = 77, normalized size = 1.7 \begin{align*}{\frac{\ln \left ( \tanh \left ( dx+c \right ) +1 \right ) }{d \left ( 2\,b+2\,a \right ) }}-{\frac{a}{d \left ( a+b \right ) }\arctan \left ({b\tanh \left ( dx+c \right ){\frac{1}{\sqrt{ab}}}} \right ){\frac{1}{\sqrt{ab}}}}-{\frac{\ln \left ( \tanh \left ( dx+c \right ) -1 \right ) }{d \left ( 2\,b+2\,a \right ) }} \end{align*}

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

[In]

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

[Out]

1/d/(2*b+2*a)*ln(tanh(d*x+c)+1)-1/d/(a+b)*a/(a*b)^(1/2)*arctan(tanh(d*x+c)*b/(a*b)^(1/2))-1/d/(2*b+2*a)*ln(tan
h(d*x+c)-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(tanh(d*x+c)^2/(a+b*tanh(d*x+c)^2),x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [B]  time = 1.91305, size = 1249, normalized size = 27.15 \begin{align*} \left [\frac{2 \, d x + \sqrt{-\frac{a}{b}} \log \left (\frac{{\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (d x + c\right )^{4} + 4 \,{\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{3} +{\left (a^{2} + 2 \, a b + b^{2}\right )} \sinh \left (d x + c\right )^{4} + 2 \,{\left (a^{2} - b^{2}\right )} \cosh \left (d x + c\right )^{2} + 2 \,{\left (3 \,{\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (d x + c\right )^{2} + a^{2} - b^{2}\right )} \sinh \left (d x + c\right )^{2} + a^{2} - 6 \, a b + b^{2} + 4 \,{\left ({\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (d x + c\right )^{3} +{\left (a^{2} - b^{2}\right )} \cosh \left (d x + c\right )\right )} \sinh \left (d x + c\right ) - 4 \,{\left ({\left (a b + b^{2}\right )} \cosh \left (d x + c\right )^{2} + 2 \,{\left (a b + b^{2}\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right ) +{\left (a b + b^{2}\right )} \sinh \left (d x + c\right )^{2} + a b - b^{2}\right )} \sqrt{-\frac{a}{b}}}{{\left (a + b\right )} \cosh \left (d x + c\right )^{4} + 4 \,{\left (a + b\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{3} +{\left (a + b\right )} \sinh \left (d x + c\right )^{4} + 2 \,{\left (a - b\right )} \cosh \left (d x + c\right )^{2} + 2 \,{\left (3 \,{\left (a + b\right )} \cosh \left (d x + c\right )^{2} + a - b\right )} \sinh \left (d x + c\right )^{2} + 4 \,{\left ({\left (a + b\right )} \cosh \left (d x + c\right )^{3} +{\left (a - b\right )} \cosh \left (d x + c\right )\right )} \sinh \left (d x + c\right ) + a + b}\right )}{2 \,{\left (a + b\right )} d}, \frac{d x - \sqrt{\frac{a}{b}} \arctan \left (\frac{{\left ({\left (a + b\right )} \cosh \left (d x + c\right )^{2} + 2 \,{\left (a + b\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right ) +{\left (a + b\right )} \sinh \left (d x + c\right )^{2} + a - b\right )} \sqrt{\frac{a}{b}}}{2 \, a}\right )}{{\left (a + b\right )} d}\right ] \end{align*}

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

[In]

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

[Out]

[1/2*(2*d*x + sqrt(-a/b)*log(((a^2 + 2*a*b + b^2)*cosh(d*x + c)^4 + 4*(a^2 + 2*a*b + b^2)*cosh(d*x + c)*sinh(d
*x + c)^3 + (a^2 + 2*a*b + b^2)*sinh(d*x + c)^4 + 2*(a^2 - b^2)*cosh(d*x + c)^2 + 2*(3*(a^2 + 2*a*b + b^2)*cos
h(d*x + c)^2 + a^2 - b^2)*sinh(d*x + c)^2 + a^2 - 6*a*b + b^2 + 4*((a^2 + 2*a*b + b^2)*cosh(d*x + c)^3 + (a^2
- b^2)*cosh(d*x + c))*sinh(d*x + c) - 4*((a*b + b^2)*cosh(d*x + c)^2 + 2*(a*b + b^2)*cosh(d*x + c)*sinh(d*x +
c) + (a*b + b^2)*sinh(d*x + c)^2 + a*b - b^2)*sqrt(-a/b))/((a + b)*cosh(d*x + c)^4 + 4*(a + b)*cosh(d*x + c)*s
inh(d*x + c)^3 + (a + b)*sinh(d*x + c)^4 + 2*(a - b)*cosh(d*x + c)^2 + 2*(3*(a + b)*cosh(d*x + c)^2 + a - b)*s
inh(d*x + c)^2 + 4*((a + b)*cosh(d*x + c)^3 + (a - b)*cosh(d*x + c))*sinh(d*x + c) + a + b)))/((a + b)*d), (d*
x - sqrt(a/b)*arctan(1/2*((a + b)*cosh(d*x + c)^2 + 2*(a + b)*cosh(d*x + c)*sinh(d*x + c) + (a + b)*sinh(d*x +
c)^2 + a - b)*sqrt(a/b)/a))/((a + b)*d)]

________________________________________________________________________________________

Sympy [A]  time = 11.6277, size = 294, normalized size = 6.39 \begin{align*} \begin{cases} \tilde{\infty } x & \text{for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac{x - \frac{\tanh{\left (c + d x \right )}}{d}}{a} & \text{for}\: b = 0 \\\frac{x}{b} & \text{for}\: a = 0 \\\frac{d x \tanh ^{2}{\left (c + d x \right )}}{2 b d \tanh ^{2}{\left (c + d x \right )} - 2 b d} - \frac{d x}{2 b d \tanh ^{2}{\left (c + d x \right )} - 2 b d} + \frac{\tanh{\left (c + d x \right )}}{2 b d \tanh ^{2}{\left (c + d x \right )} - 2 b d} & \text{for}\: a = - b \\\frac{x \tanh ^{2}{\left (c \right )}}{a + b \tanh ^{2}{\left (c \right )}} & \text{for}\: d = 0 \\\frac{2 i \sqrt{a} b d x \sqrt{\frac{1}{b}}}{2 i a^{\frac{3}{2}} b d \sqrt{\frac{1}{b}} + 2 i \sqrt{a} b^{2} d \sqrt{\frac{1}{b}}} - \frac{a \log{\left (- i \sqrt{a} \sqrt{\frac{1}{b}} + \tanh{\left (c + d x \right )} \right )}}{2 i a^{\frac{3}{2}} b d \sqrt{\frac{1}{b}} + 2 i \sqrt{a} b^{2} d \sqrt{\frac{1}{b}}} + \frac{a \log{\left (i \sqrt{a} \sqrt{\frac{1}{b}} + \tanh{\left (c + d x \right )} \right )}}{2 i a^{\frac{3}{2}} b d \sqrt{\frac{1}{b}} + 2 i \sqrt{a} b^{2} d \sqrt{\frac{1}{b}}} & \text{otherwise} \end{cases} \end{align*}

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

[In]

integrate(tanh(d*x+c)**2/(a+b*tanh(d*x+c)**2),x)

[Out]

Piecewise((zoo*x, Eq(a, 0) & Eq(b, 0) & Eq(d, 0)), ((x - tanh(c + d*x)/d)/a, Eq(b, 0)), (x/b, Eq(a, 0)), (d*x*
tanh(c + d*x)**2/(2*b*d*tanh(c + d*x)**2 - 2*b*d) - d*x/(2*b*d*tanh(c + d*x)**2 - 2*b*d) + tanh(c + d*x)/(2*b*
d*tanh(c + d*x)**2 - 2*b*d), Eq(a, -b)), (x*tanh(c)**2/(a + b*tanh(c)**2), Eq(d, 0)), (2*I*sqrt(a)*b*d*x*sqrt(
1/b)/(2*I*a**(3/2)*b*d*sqrt(1/b) + 2*I*sqrt(a)*b**2*d*sqrt(1/b)) - a*log(-I*sqrt(a)*sqrt(1/b) + tanh(c + d*x))
/(2*I*a**(3/2)*b*d*sqrt(1/b) + 2*I*sqrt(a)*b**2*d*sqrt(1/b)) + a*log(I*sqrt(a)*sqrt(1/b) + tanh(c + d*x))/(2*I
*a**(3/2)*b*d*sqrt(1/b) + 2*I*sqrt(a)*b**2*d*sqrt(1/b)), True))

________________________________________________________________________________________

Giac [A]  time = 1.17616, size = 92, normalized size = 2. \begin{align*} -\frac{a \arctan \left (\frac{a e^{\left (2 \, d x + 2 \, c\right )} + b e^{\left (2 \, d x + 2 \, c\right )} + a - b}{2 \, \sqrt{a b}}\right )}{\sqrt{a b}{\left (a d + b d\right )}} + \frac{d x + c}{a d + b d} \end{align*}

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

[In]

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

[Out]

-a*arctan(1/2*(a*e^(2*d*x + 2*c) + b*e^(2*d*x + 2*c) + a - b)/sqrt(a*b))/(sqrt(a*b)*(a*d + b*d)) + (d*x + c)/(
a*d + b*d)