3.991 \(\int \frac {\text {sech}^2(x) (a+b \tanh (x))^2}{c+d \tanh (x)} \, dx\)

Optimal. Leaf size=53 \[ \frac {(b c-a d)^2 \log (c+d \tanh (x))}{d^3}-\frac {b \tanh (x) (b c-a d)}{d^2}+\frac {(a+b \tanh (x))^2}{2 d} \]

[Out]

(-a*d+b*c)^2*ln(c+d*tanh(x))/d^3-b*(-a*d+b*c)*tanh(x)/d^2+1/2*(a+b*tanh(x))^2/d

________________________________________________________________________________________

Rubi [A]  time = 0.16, antiderivative size = 53, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.095, Rules used = {4342, 43} \[ -\frac {b \tanh (x) (b c-a d)}{d^2}+\frac {(b c-a d)^2 \log (c+d \tanh (x))}{d^3}+\frac {(a+b \tanh (x))^2}{2 d} \]

Antiderivative was successfully verified.

[In]

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

[Out]

((b*c - a*d)^2*Log[c + d*Tanh[x]])/d^3 - (b*(b*c - a*d)*Tanh[x])/d^2 + (a + b*Tanh[x])^2/(2*d)

Rule 43

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_.), x_Symbol] :> Int[ExpandIntegrand[(a + b*x)^m*(c + d
*x)^n, x], x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0] && IGtQ[m, 0] && ( !IntegerQ[n] || (EqQ[c, 0]
&& LeQ[7*m + 4*n + 4, 0]) || LtQ[9*m + 5*(n + 1), 0] || GtQ[m + n + 2, 0])

Rule 4342

Int[(u_)*(F_)[(c_.)*((a_.) + (b_.)*(x_))]^2, x_Symbol] :> With[{d = FreeFactors[Tan[c*(a + b*x)], x]}, Dist[d/
(b*c), Subst[Int[SubstFor[1, Tan[c*(a + b*x)]/d, u, x], x], x, Tan[c*(a + b*x)]/d], x] /; FunctionOfQ[Tan[c*(a
 + b*x)]/d, u, x, True]] /; FreeQ[{a, b, c}, x] && NonsumQ[u] && (EqQ[F, Sec] || EqQ[F, sec])

Rubi steps

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

________________________________________________________________________________________

Mathematica [A]  time = 0.62, size = 61, normalized size = 1.15 \[ -\frac {2 b d \tanh (x) (b c-2 a d)+2 (b c-a d)^2 (\log (\cosh (x))-\log (c \cosh (x)+d \sinh (x)))+b^2 d^2 \text {sech}^2(x)}{2 d^3} \]

Antiderivative was successfully verified.

[In]

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

[Out]

-1/2*(2*(b*c - a*d)^2*(Log[Cosh[x]] - Log[c*Cosh[x] + d*Sinh[x]]) + b^2*d^2*Sech[x]^2 + 2*b*d*(b*c - 2*a*d)*Ta
nh[x])/d^3

________________________________________________________________________________________

fricas [B]  time = 0.47, size = 688, normalized size = 12.98 \[ \frac {2 \, b^{2} c d - 4 \, a b d^{2} + 2 \, {\left (b^{2} c d - {\left (2 \, a b + b^{2}\right )} d^{2}\right )} \cosh \relax (x)^{2} + 4 \, {\left (b^{2} c d - {\left (2 \, a b + b^{2}\right )} d^{2}\right )} \cosh \relax (x) \sinh \relax (x) + 2 \, {\left (b^{2} c d - {\left (2 \, a b + b^{2}\right )} d^{2}\right )} \sinh \relax (x)^{2} + {\left ({\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)^{4} + 4 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x) \sinh \relax (x)^{3} + {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \sinh \relax (x)^{4} + b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2} + 2 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)^{2} + 2 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2} + 3 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)^{2}\right )} \sinh \relax (x)^{2} + 4 \, {\left ({\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)^{3} + {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)\right )} \sinh \relax (x)\right )} \log \left (\frac {2 \, {\left (c \cosh \relax (x) + d \sinh \relax (x)\right )}}{\cosh \relax (x) - \sinh \relax (x)}\right ) - {\left ({\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)^{4} + 4 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x) \sinh \relax (x)^{3} + {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \sinh \relax (x)^{4} + b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2} + 2 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)^{2} + 2 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2} + 3 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)^{2}\right )} \sinh \relax (x)^{2} + 4 \, {\left ({\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)^{3} + {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \cosh \relax (x)\right )} \sinh \relax (x)\right )} \log \left (\frac {2 \, \cosh \relax (x)}{\cosh \relax (x) - \sinh \relax (x)}\right )}{d^{3} \cosh \relax (x)^{4} + 4 \, d^{3} \cosh \relax (x) \sinh \relax (x)^{3} + d^{3} \sinh \relax (x)^{4} + 2 \, d^{3} \cosh \relax (x)^{2} + d^{3} + 2 \, {\left (3 \, d^{3} \cosh \relax (x)^{2} + d^{3}\right )} \sinh \relax (x)^{2} + 4 \, {\left (d^{3} \cosh \relax (x)^{3} + d^{3} \cosh \relax (x)\right )} \sinh \relax (x)} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

(2*b^2*c*d - 4*a*b*d^2 + 2*(b^2*c*d - (2*a*b + b^2)*d^2)*cosh(x)^2 + 4*(b^2*c*d - (2*a*b + b^2)*d^2)*cosh(x)*s
inh(x) + 2*(b^2*c*d - (2*a*b + b^2)*d^2)*sinh(x)^2 + ((b^2*c^2 - 2*a*b*c*d + a^2*d^2)*cosh(x)^4 + 4*(b^2*c^2 -
 2*a*b*c*d + a^2*d^2)*cosh(x)*sinh(x)^3 + (b^2*c^2 - 2*a*b*c*d + a^2*d^2)*sinh(x)^4 + b^2*c^2 - 2*a*b*c*d + a^
2*d^2 + 2*(b^2*c^2 - 2*a*b*c*d + a^2*d^2)*cosh(x)^2 + 2*(b^2*c^2 - 2*a*b*c*d + a^2*d^2 + 3*(b^2*c^2 - 2*a*b*c*
d + a^2*d^2)*cosh(x)^2)*sinh(x)^2 + 4*((b^2*c^2 - 2*a*b*c*d + a^2*d^2)*cosh(x)^3 + (b^2*c^2 - 2*a*b*c*d + a^2*
d^2)*cosh(x))*sinh(x))*log(2*(c*cosh(x) + d*sinh(x))/(cosh(x) - sinh(x))) - ((b^2*c^2 - 2*a*b*c*d + a^2*d^2)*c
osh(x)^4 + 4*(b^2*c^2 - 2*a*b*c*d + a^2*d^2)*cosh(x)*sinh(x)^3 + (b^2*c^2 - 2*a*b*c*d + a^2*d^2)*sinh(x)^4 + b
^2*c^2 - 2*a*b*c*d + a^2*d^2 + 2*(b^2*c^2 - 2*a*b*c*d + a^2*d^2)*cosh(x)^2 + 2*(b^2*c^2 - 2*a*b*c*d + a^2*d^2
+ 3*(b^2*c^2 - 2*a*b*c*d + a^2*d^2)*cosh(x)^2)*sinh(x)^2 + 4*((b^2*c^2 - 2*a*b*c*d + a^2*d^2)*cosh(x)^3 + (b^2
*c^2 - 2*a*b*c*d + a^2*d^2)*cosh(x))*sinh(x))*log(2*cosh(x)/(cosh(x) - sinh(x))))/(d^3*cosh(x)^4 + 4*d^3*cosh(
x)*sinh(x)^3 + d^3*sinh(x)^4 + 2*d^3*cosh(x)^2 + d^3 + 2*(3*d^3*cosh(x)^2 + d^3)*sinh(x)^2 + 4*(d^3*cosh(x)^3
+ d^3*cosh(x))*sinh(x))

________________________________________________________________________________________

giac [B]  time = 0.13, size = 264, normalized size = 4.98 \[ \frac {{\left (b^{2} c^{3} - 2 \, a b c^{2} d + b^{2} c^{2} d + a^{2} c d^{2} - 2 \, a b c d^{2} + a^{2} d^{3}\right )} \log \left ({\left | c e^{\left (2 \, x\right )} + d e^{\left (2 \, x\right )} + c - d \right |}\right )}{c d^{3} + d^{4}} - \frac {{\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \log \left (e^{\left (2 \, x\right )} + 1\right )}{d^{3}} + \frac {3 \, b^{2} c^{2} e^{\left (4 \, x\right )} - 6 \, a b c d e^{\left (4 \, x\right )} + 3 \, a^{2} d^{2} e^{\left (4 \, x\right )} + 6 \, b^{2} c^{2} e^{\left (2 \, x\right )} - 12 \, a b c d e^{\left (2 \, x\right )} + 4 \, b^{2} c d e^{\left (2 \, x\right )} + 6 \, a^{2} d^{2} e^{\left (2 \, x\right )} - 8 \, a b d^{2} e^{\left (2 \, x\right )} - 4 \, b^{2} d^{2} e^{\left (2 \, x\right )} + 3 \, b^{2} c^{2} - 6 \, a b c d + 4 \, b^{2} c d + 3 \, a^{2} d^{2} - 8 \, a b d^{2}}{2 \, d^{3} {\left (e^{\left (2 \, x\right )} + 1\right )}^{2}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

(b^2*c^3 - 2*a*b*c^2*d + b^2*c^2*d + a^2*c*d^2 - 2*a*b*c*d^2 + a^2*d^3)*log(abs(c*e^(2*x) + d*e^(2*x) + c - d)
)/(c*d^3 + d^4) - (b^2*c^2 - 2*a*b*c*d + a^2*d^2)*log(e^(2*x) + 1)/d^3 + 1/2*(3*b^2*c^2*e^(4*x) - 6*a*b*c*d*e^
(4*x) + 3*a^2*d^2*e^(4*x) + 6*b^2*c^2*e^(2*x) - 12*a*b*c*d*e^(2*x) + 4*b^2*c*d*e^(2*x) + 6*a^2*d^2*e^(2*x) - 8
*a*b*d^2*e^(2*x) - 4*b^2*d^2*e^(2*x) + 3*b^2*c^2 - 6*a*b*c*d + 4*b^2*c*d + 3*a^2*d^2 - 8*a*b*d^2)/(d^3*(e^(2*x
) + 1)^2)

________________________________________________________________________________________

maple [B]  time = 0.23, size = 251, normalized size = 4.74 \[ \frac {\ln \left (\left (\tanh ^{2}\left (\frac {x}{2}\right )\right ) c +2 \tanh \left (\frac {x}{2}\right ) d +c \right ) a^{2}}{d}-\frac {2 \ln \left (\left (\tanh ^{2}\left (\frac {x}{2}\right )\right ) c +2 \tanh \left (\frac {x}{2}\right ) d +c \right ) c b a}{d^{2}}+\frac {\ln \left (\left (\tanh ^{2}\left (\frac {x}{2}\right )\right ) c +2 \tanh \left (\frac {x}{2}\right ) d +c \right ) c^{2} b^{2}}{d^{3}}+\frac {4 \left (\tanh ^{3}\left (\frac {x}{2}\right )\right ) a b}{d \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right )^{2}}-\frac {2 \left (\tanh ^{3}\left (\frac {x}{2}\right )\right ) b^{2} c}{d^{2} \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right )^{2}}+\frac {2 b^{2} \left (\tanh ^{2}\left (\frac {x}{2}\right )\right )}{d \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right )^{2}}+\frac {4 \tanh \left (\frac {x}{2}\right ) a b}{d \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right )^{2}}-\frac {2 \tanh \left (\frac {x}{2}\right ) b^{2} c}{d^{2} \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right )^{2}}-\frac {\ln \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right ) a^{2}}{d}+\frac {2 \ln \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right ) c b a}{d^{2}}-\frac {\ln \left (\tanh ^{2}\left (\frac {x}{2}\right )+1\right ) c^{2} b^{2}}{d^{3}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

1/d*ln(tanh(1/2*x)^2*c+2*tanh(1/2*x)*d+c)*a^2-2/d^2*ln(tanh(1/2*x)^2*c+2*tanh(1/2*x)*d+c)*c*b*a+1/d^3*ln(tanh(
1/2*x)^2*c+2*tanh(1/2*x)*d+c)*c^2*b^2+4/d/(tanh(1/2*x)^2+1)^2*tanh(1/2*x)^3*a*b-2/d^2/(tanh(1/2*x)^2+1)^2*tanh
(1/2*x)^3*b^2*c+2/d/(tanh(1/2*x)^2+1)^2*b^2*tanh(1/2*x)^2+4/d/(tanh(1/2*x)^2+1)^2*tanh(1/2*x)*a*b-2/d^2/(tanh(
1/2*x)^2+1)^2*tanh(1/2*x)*b^2*c-1/d*ln(tanh(1/2*x)^2+1)*a^2+2/d^2*ln(tanh(1/2*x)^2+1)*c*b*a-1/d^3*ln(tanh(1/2*
x)^2+1)*c^2*b^2

________________________________________________________________________________________

maxima [B]  time = 0.42, size = 151, normalized size = 2.85 \[ -b^{2} {\left (\frac {2 \, {\left ({\left (c + d\right )} e^{\left (-2 \, x\right )} + c\right )}}{2 \, d^{2} e^{\left (-2 \, x\right )} + d^{2} e^{\left (-4 \, x\right )} + d^{2}} - \frac {c^{2} \log \left (-{\left (c - d\right )} e^{\left (-2 \, x\right )} - c - d\right )}{d^{3}} + \frac {c^{2} \log \left (e^{\left (-2 \, x\right )} + 1\right )}{d^{3}}\right )} - 2 \, a b {\left (\frac {c \log \left (-{\left (c - d\right )} e^{\left (-2 \, x\right )} - c - d\right )}{d^{2}} - \frac {c \log \left (e^{\left (-2 \, x\right )} + 1\right )}{d^{2}} - \frac {2}{d e^{\left (-2 \, x\right )} + d}\right )} + \frac {a^{2} \log \left (d \tanh \relax (x) + c\right )}{d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-b^2*(2*((c + d)*e^(-2*x) + c)/(2*d^2*e^(-2*x) + d^2*e^(-4*x) + d^2) - c^2*log(-(c - d)*e^(-2*x) - c - d)/d^3
+ c^2*log(e^(-2*x) + 1)/d^3) - 2*a*b*(c*log(-(c - d)*e^(-2*x) - c - d)/d^2 - c*log(e^(-2*x) + 1)/d^2 - 2/(d*e^
(-2*x) + d)) + a^2*log(d*tanh(x) + c)/d

________________________________________________________________________________________

mupad [B]  time = 2.13, size = 107, normalized size = 2.02 \[ \frac {\ln \left (c-d+d\,{\mathrm {e}}^{2\,x}+c\,{\mathrm {e}}^{2\,x}\right )\,{\left (a\,d-b\,c\right )}^2}{d^3}-\frac {2\,\left (b^2\,d-b^2\,c+2\,a\,b\,d\right )}{d^2\,\left ({\mathrm {e}}^{2\,x}+1\right )}-\frac {\ln \left ({\mathrm {e}}^{2\,x}+1\right )\,{\left (a\,d-b\,c\right )}^2}{d^3}+\frac {2\,b^2}{d\,\left (2\,{\mathrm {e}}^{2\,x}+{\mathrm {e}}^{4\,x}+1\right )} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

(log(c - d + d*exp(2*x) + c*exp(2*x))*(a*d - b*c)^2)/d^3 - (2*(b^2*d - b^2*c + 2*a*b*d))/(d^2*(exp(2*x) + 1))
- (log(exp(2*x) + 1)*(a*d - b*c)^2)/d^3 + (2*b^2)/(d*(2*exp(2*x) + exp(4*x) + 1))

________________________________________________________________________________________

sympy [F]  time = 0.00, size = 0, normalized size = 0.00 \[ \int \frac {\left (a + b \tanh {\relax (x )}\right )^{2} \operatorname {sech}^{2}{\relax (x )}}{c + d \tanh {\relax (x )}}\, dx \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________