3.1.5 \(\int \tanh ^2(a+b x) \, dx\) [5]

Optimal. Leaf size=13 \[ x-\frac {\tanh (a+b x)}{b} \]

[Out]

x-tanh(b*x+a)/b

________________________________________________________________________________________

Rubi [A]
time = 0.01, antiderivative size = 13, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, integrand size = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3554, 8} \begin {gather*} x-\frac {\tanh (a+b x)}{b} \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

x - Tanh[a + b*x]/b

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3554

Int[((b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((b*Tan[c + d*x])^(n - 1)/(d*(n - 1))), x] - Dis
t[b^2, Int[(b*Tan[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1]

Rubi steps

\begin {align*} \int \tanh ^2(a+b x) \, dx &=-\frac {\tanh (a+b x)}{b}+\int 1 \, dx\\ &=x-\frac {\tanh (a+b x)}{b}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.01, size = 23, normalized size = 1.77 \begin {gather*} \frac {\tanh ^{-1}(\tanh (a+b x))}{b}-\frac {\tanh (a+b x)}{b} \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

ArcTanh[Tanh[a + b*x]]/b - Tanh[a + b*x]/b

________________________________________________________________________________________

Maple [B] Leaf count of result is larger than twice the leaf count of optimal. \(35\) vs. \(2(13)=26\).
time = 0.25, size = 36, normalized size = 2.77

method result size
risch \(x +\frac {2}{b \left ({\mathrm e}^{2 b x +2 a}+1\right )}\) \(21\)
derivativedivides \(\frac {-\tanh \left (b x +a \right )-\frac {\ln \left (-1+\tanh \left (b x +a \right )\right )}{2}+\frac {\ln \left (\tanh \left (b x +a \right )+1\right )}{2}}{b}\) \(36\)
default \(\frac {-\tanh \left (b x +a \right )-\frac {\ln \left (-1+\tanh \left (b x +a \right )\right )}{2}+\frac {\ln \left (\tanh \left (b x +a \right )+1\right )}{2}}{b}\) \(36\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

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

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 33 vs. \(2 (13) = 26\).
time = 0.50, size = 33, normalized size = 2.54 \begin {gather*} \frac {{\left (b x + 1\right )} \cosh \left (b x + a\right ) - \sinh \left (b x + a\right )}{b \cosh \left (b x + a\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

((b*x + 1)*cosh(b*x + a) - sinh(b*x + a))/(b*cosh(b*x + a))

________________________________________________________________________________________

Sympy [A]
time = 0.06, size = 15, normalized size = 1.15 \begin {gather*} \begin {cases} x - \frac {\tanh {\left (a + b x \right )}}{b} & \text {for}\: b \neq 0 \\x \tanh ^{2}{\left (a \right )} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Piecewise((x - tanh(a + b*x)/b, Ne(b, 0)), (x*tanh(a)**2, True))

________________________________________________________________________________________

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

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Mupad [B]
time = 0.06, size = 13, normalized size = 1.00 \begin {gather*} x-\frac {\mathrm {tanh}\left (a+b\,x\right )}{b} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

x - tanh(a + b*x)/b

________________________________________________________________________________________