3.1.44 \(\int (a+a \tanh (c+d x))^2 \, dx\) [44]

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

[Out]

2*a^2*x+2*a^2*ln(cosh(d*x+c))/d-a^2*tanh(d*x+c)/d

________________________________________________________________________________________

Rubi [A]
time = 0.02, antiderivative size = 36, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, integrand size = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.167, Rules used = {3558, 3556} \begin {gather*} -\frac {a^2 \tanh (c+d x)}{d}+\frac {2 a^2 \log (\cosh (c+d x))}{d}+2 a^2 x \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

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

Rule 3556

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

Rule 3558

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2)*x, x] + (Dist[2*a*b, Int[Tan[c + d
*x], x], x] + Simp[b^2*(Tan[c + d*x]/d), x]) /; FreeQ[{a, b, c, d}, x]

Rubi steps

\begin {align*} \int (a+a \tanh (c+d x))^2 \, dx &=2 a^2 x-\frac {a^2 \tanh (c+d x)}{d}+\left (2 a^2\right ) \int \tanh (c+d x) \, dx\\ &=2 a^2 x+\frac {2 a^2 \log (\cosh (c+d x))}{d}-\frac {a^2 \tanh (c+d x)}{d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.24, size = 58, normalized size = 1.61 \begin {gather*} \frac {a^2 \text {sech}(c) \text {sech}(c+d x) (\cosh (d x) (d x+\log (\cosh (c+d x)))+\cosh (2 c+d x) (d x+\log (\cosh (c+d x)))-\sinh (d x))}{d} \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

(a^2*Sech[c]*Sech[c + d*x]*(Cosh[d*x]*(d*x + Log[Cosh[c + d*x]]) + Cosh[2*c + d*x]*(d*x + Log[Cosh[c + d*x]])
- Sinh[d*x]))/d

________________________________________________________________________________________

Maple [A]
time = 0.26, size = 28, normalized size = 0.78

method result size
derivativedivides \(\frac {a^{2} \left (-\tanh \left (d x +c \right )-2 \ln \left (\tanh \left (d x +c \right )-1\right )\right )}{d}\) \(28\)
default \(\frac {a^{2} \left (-\tanh \left (d x +c \right )-2 \ln \left (\tanh \left (d x +c \right )-1\right )\right )}{d}\) \(28\)
risch \(-\frac {4 a^{2} c}{d}+\frac {2 a^{2}}{d \left (1+{\mathrm e}^{2 d x +2 c}\right )}+\frac {2 a^{2} \ln \left (1+{\mathrm e}^{2 d x +2 c}\right )}{d}\) \(52\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Maxima [A]
time = 0.26, size = 50, normalized size = 1.39 \begin {gather*} a^{2} {\left (x + \frac {c}{d} - \frac {2}{d {\left (e^{\left (-2 \, d x - 2 \, c\right )} + 1\right )}}\right )} + a^{2} x + \frac {2 \, a^{2} \log \left (\cosh \left (d x + c\right )\right )}{d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

a^2*(x + c/d - 2/(d*(e^(-2*d*x - 2*c) + 1))) + a^2*x + 2*a^2*log(cosh(d*x + c))/d

________________________________________________________________________________________

Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 117 vs. \(2 (36) = 72\).
time = 0.39, size = 117, normalized size = 3.25 \begin {gather*} \frac {2 \, {\left (a^{2} + {\left (a^{2} \cosh \left (d x + c\right )^{2} + 2 \, a^{2} \cosh \left (d x + c\right ) \sinh \left (d x + c\right ) + a^{2} \sinh \left (d x + c\right )^{2} + a^{2}\right )} \log \left (\frac {2 \, \cosh \left (d x + c\right )}{\cosh \left (d x + c\right ) - \sinh \left (d x + c\right )}\right )\right )}}{d \cosh \left (d x + c\right )^{2} + 2 \, d \cosh \left (d x + c\right ) \sinh \left (d x + c\right ) + d \sinh \left (d x + c\right )^{2} + d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

2*(a^2 + (a^2*cosh(d*x + c)^2 + 2*a^2*cosh(d*x + c)*sinh(d*x + c) + a^2*sinh(d*x + c)^2 + a^2)*log(2*cosh(d*x
+ c)/(cosh(d*x + c) - sinh(d*x + c))))/(d*cosh(d*x + c)^2 + 2*d*cosh(d*x + c)*sinh(d*x + c) + d*sinh(d*x + c)^
2 + d)

________________________________________________________________________________________

Sympy [A]
time = 0.08, size = 44, normalized size = 1.22 \begin {gather*} \begin {cases} 4 a^{2} x - \frac {2 a^{2} \log {\left (\tanh {\left (c + d x \right )} + 1 \right )}}{d} - \frac {a^{2} \tanh {\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \left (a \tanh {\left (c \right )} + a\right )^{2} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Piecewise((4*a**2*x - 2*a**2*log(tanh(c + d*x) + 1)/d - a**2*tanh(c + d*x)/d, Ne(d, 0)), (x*(a*tanh(c) + a)**2
, True))

________________________________________________________________________________________

Giac [A]
time = 0.43, size = 39, normalized size = 1.08 \begin {gather*} \frac {2 \, {\left (a^{2} \log \left (e^{\left (2 \, d x + 2 \, c\right )} + 1\right ) + \frac {a^{2}}{e^{\left (2 \, d x + 2 \, c\right )} + 1}\right )}}{d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

2*(a^2*log(e^(2*d*x + 2*c) + 1) + a^2/(e^(2*d*x + 2*c) + 1))/d

________________________________________________________________________________________

Mupad [B]
time = 1.07, size = 33, normalized size = 0.92 \begin {gather*} 4\,a^2\,x-\frac {a^2\,\left (2\,\ln \left (\mathrm {tanh}\left (c+d\,x\right )+1\right )+\mathrm {tanh}\left (c+d\,x\right )\right )}{d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________