\(\int (a+b \tanh ^3(c+d x))^2 \, dx\) [257]

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [A] (verified)
Fricas [B] (verification not implemented)
Sympy [A] (verification not implemented)
Maxima [B] (verification not implemented)
Giac [A] (verification not implemented)
Mupad [B] (verification not implemented)
Reduce [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 89 \[ \int \left (a+b \tanh ^3(c+d x)\right )^2 \, dx=\left (a^2+b^2\right ) x+\frac {2 a b \log (\cosh (c+d x))}{d}-\frac {b^2 \tanh (c+d x)}{d}-\frac {a b \tanh ^2(c+d x)}{d}-\frac {b^2 \tanh ^3(c+d x)}{3 d}-\frac {b^2 \tanh ^5(c+d x)}{5 d} \] Output:

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

Mathematica [A] (verified)

Time = 0.49 (sec) , antiderivative size = 95, normalized size of antiderivative = 1.07 \[ \int \left (a+b \tanh ^3(c+d x)\right )^2 \, dx=-\frac {15 \left ((a+b)^2 \log (1-\tanh (c+d x))-(a-b)^2 \log (1+\tanh (c+d x))\right )+30 b^2 \tanh (c+d x)+30 a b \tanh ^2(c+d x)+10 b^2 \tanh ^3(c+d x)+6 b^2 \tanh ^5(c+d x)}{30 d} \] Input:

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

Output:

-1/30*(15*((a + b)^2*Log[1 - Tanh[c + d*x]] - (a - b)^2*Log[1 + Tanh[c + d 
*x]]) + 30*b^2*Tanh[c + d*x] + 30*a*b*Tanh[c + d*x]^2 + 10*b^2*Tanh[c + d* 
x]^3 + 6*b^2*Tanh[c + d*x]^5)/d
 

Rubi [A] (verified)

Time = 0.30 (sec) , antiderivative size = 90, normalized size of antiderivative = 1.01, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3042, 4144, 2341, 2009}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \left (a+b \tanh ^3(c+d x)\right )^2 \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \left (a+i b \tan (i c+i d x)^3\right )^2dx\)

\(\Big \downarrow \) 4144

\(\displaystyle \frac {\int \frac {\left (b \tanh ^3(c+d x)+a\right )^2}{1-\tanh ^2(c+d x)}d\tanh (c+d x)}{d}\)

\(\Big \downarrow \) 2341

\(\displaystyle \frac {\int \left (-b^2 \tanh ^4(c+d x)-b^2 \tanh ^2(c+d x)-2 a b \tanh (c+d x)-b^2+\frac {a^2+2 b \tanh (c+d x) a+b^2}{1-\tanh ^2(c+d x)}\right )d\tanh (c+d x)}{d}\)

\(\Big \downarrow \) 2009

\(\displaystyle \frac {\left (a^2+b^2\right ) \text {arctanh}(\tanh (c+d x))-a b \tanh ^2(c+d x)-a b \log \left (1-\tanh ^2(c+d x)\right )-\frac {1}{5} b^2 \tanh ^5(c+d x)-\frac {1}{3} b^2 \tanh ^3(c+d x)-b^2 \tanh (c+d x)}{d}\)

Input:

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

Output:

((a^2 + b^2)*ArcTanh[Tanh[c + d*x]] - a*b*Log[1 - Tanh[c + d*x]^2] - b^2*T 
anh[c + d*x] - a*b*Tanh[c + d*x]^2 - (b^2*Tanh[c + d*x]^3)/3 - (b^2*Tanh[c 
 + d*x]^5)/5)/d
 

Defintions of rubi rules used

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

rule 2341
Int[(Pq_)*((a_) + (b_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIntegrand[Pq* 
(a + b*x^2)^p, x], x] /; FreeQ[{a, b}, x] && PolyQ[Pq, x] && IGtQ[p, -2]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4144
Int[((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_), x_Symbol] :> 
With[{ff = FreeFactors[Tan[e + f*x], x]}, Simp[c*(ff/f)   Subst[Int[(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, e, f, n, p}, x] && (IntegersQ[n, p] || IGtQ[p, 0] || EqQ[n^2, 4] || 
EqQ[n^2, 16])
 
Maple [A] (verified)

Time = 0.09 (sec) , antiderivative size = 91, normalized size of antiderivative = 1.02

method result size
parallelrisch \(-\frac {3 b^{2} \tanh \left (d x +c \right )^{5}+5 b^{2} \tanh \left (d x +c \right )^{3}-15 a^{2} d x +30 a b d x -15 b^{2} d x +15 \tanh \left (d x +c \right )^{2} a b +30 \ln \left (1-\tanh \left (d x +c \right )\right ) a b +15 b^{2} \tanh \left (d x +c \right )}{15 d}\) \(91\)
derivativedivides \(\frac {-\frac {b^{2} \tanh \left (d x +c \right )^{5}}{5}-\frac {b^{2} \tanh \left (d x +c \right )^{3}}{3}-\tanh \left (d x +c \right )^{2} a b -b^{2} \tanh \left (d x +c \right )-\frac {\left (a^{2}+2 a b +b^{2}\right ) \ln \left (-1+\tanh \left (d x +c \right )\right )}{2}+\frac {\left (a^{2}-2 a b +b^{2}\right ) \ln \left (1+\tanh \left (d x +c \right )\right )}{2}}{d}\) \(99\)
default \(\frac {-\frac {b^{2} \tanh \left (d x +c \right )^{5}}{5}-\frac {b^{2} \tanh \left (d x +c \right )^{3}}{3}-\tanh \left (d x +c \right )^{2} a b -b^{2} \tanh \left (d x +c \right )-\frac {\left (a^{2}+2 a b +b^{2}\right ) \ln \left (-1+\tanh \left (d x +c \right )\right )}{2}+\frac {\left (a^{2}-2 a b +b^{2}\right ) \ln \left (1+\tanh \left (d x +c \right )\right )}{2}}{d}\) \(99\)
parts \(a^{2} x +\frac {b^{2} \left (-\frac {\tanh \left (d x +c \right )^{5}}{5}-\frac {\tanh \left (d x +c \right )^{3}}{3}-\tanh \left (d x +c \right )-\frac {\ln \left (-1+\tanh \left (d x +c \right )\right )}{2}+\frac {\ln \left (1+\tanh \left (d x +c \right )\right )}{2}\right )}{d}+\frac {2 a b \left (-\frac {\tanh \left (d x +c \right )^{2}}{2}-\frac {\ln \left (-1+\tanh \left (d x +c \right )\right )}{2}-\frac {\ln \left (1+\tanh \left (d x +c \right )\right )}{2}\right )}{d}\) \(105\)
risch \(a^{2} x -2 a b x +b^{2} x -\frac {4 a b c}{d}+\frac {2 b \left (30 a \,{\mathrm e}^{8 d x +8 c}+45 b \,{\mathrm e}^{8 d x +8 c}+90 a \,{\mathrm e}^{6 d x +6 c}+90 b \,{\mathrm e}^{6 d x +6 c}+90 a \,{\mathrm e}^{4 d x +4 c}+140 b \,{\mathrm e}^{4 d x +4 c}+30 a \,{\mathrm e}^{2 d x +2 c}+70 b \,{\mathrm e}^{2 d x +2 c}+23 b \right )}{15 d \left ({\mathrm e}^{2 d x +2 c}+1\right )^{5}}+\frac {2 \ln \left ({\mathrm e}^{2 d x +2 c}+1\right ) a b}{d}\) \(163\)

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 2074 vs. \(2 (85) = 170\).

Time = 0.12 (sec) , antiderivative size = 2074, normalized size of antiderivative = 23.30 \[ \int \left (a+b \tanh ^3(c+d x)\right )^2 \, dx=\text {Too large to display} \] Input:

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

Output:

1/15*(15*(a^2 - 2*a*b + b^2)*d*x*cosh(d*x + c)^10 + 150*(a^2 - 2*a*b + b^2 
)*d*x*cosh(d*x + c)*sinh(d*x + c)^9 + 15*(a^2 - 2*a*b + b^2)*d*x*sinh(d*x 
+ c)^10 + 15*(5*(a^2 - 2*a*b + b^2)*d*x + 4*a*b + 6*b^2)*cosh(d*x + c)^8 + 
 15*(45*(a^2 - 2*a*b + b^2)*d*x*cosh(d*x + c)^2 + 5*(a^2 - 2*a*b + b^2)*d* 
x + 4*a*b + 6*b^2)*sinh(d*x + c)^8 + 120*(15*(a^2 - 2*a*b + b^2)*d*x*cosh( 
d*x + c)^3 + (5*(a^2 - 2*a*b + b^2)*d*x + 4*a*b + 6*b^2)*cosh(d*x + c))*si 
nh(d*x + c)^7 + 30*(5*(a^2 - 2*a*b + b^2)*d*x + 6*a*b + 6*b^2)*cosh(d*x + 
c)^6 + 30*(105*(a^2 - 2*a*b + b^2)*d*x*cosh(d*x + c)^4 + 5*(a^2 - 2*a*b + 
b^2)*d*x + 14*(5*(a^2 - 2*a*b + b^2)*d*x + 4*a*b + 6*b^2)*cosh(d*x + c)^2 
+ 6*a*b + 6*b^2)*sinh(d*x + c)^6 + 60*(63*(a^2 - 2*a*b + b^2)*d*x*cosh(d*x 
 + c)^5 + 14*(5*(a^2 - 2*a*b + b^2)*d*x + 4*a*b + 6*b^2)*cosh(d*x + c)^3 + 
 3*(5*(a^2 - 2*a*b + b^2)*d*x + 6*a*b + 6*b^2)*cosh(d*x + c))*sinh(d*x + c 
)^5 + 10*(15*(a^2 - 2*a*b + b^2)*d*x + 18*a*b + 28*b^2)*cosh(d*x + c)^4 + 
10*(315*(a^2 - 2*a*b + b^2)*d*x*cosh(d*x + c)^6 + 105*(5*(a^2 - 2*a*b + b^ 
2)*d*x + 4*a*b + 6*b^2)*cosh(d*x + c)^4 + 15*(a^2 - 2*a*b + b^2)*d*x + 45* 
(5*(a^2 - 2*a*b + b^2)*d*x + 6*a*b + 6*b^2)*cosh(d*x + c)^2 + 18*a*b + 28* 
b^2)*sinh(d*x + c)^4 + 40*(45*(a^2 - 2*a*b + b^2)*d*x*cosh(d*x + c)^7 + 21 
*(5*(a^2 - 2*a*b + b^2)*d*x + 4*a*b + 6*b^2)*cosh(d*x + c)^5 + 15*(5*(a^2 
- 2*a*b + b^2)*d*x + 6*a*b + 6*b^2)*cosh(d*x + c)^3 + (15*(a^2 - 2*a*b + b 
^2)*d*x + 18*a*b + 28*b^2)*cosh(d*x + c))*sinh(d*x + c)^3 + 15*(a^2 - 2...
 

Sympy [A] (verification not implemented)

Time = 0.14 (sec) , antiderivative size = 100, normalized size of antiderivative = 1.12 \[ \int \left (a+b \tanh ^3(c+d x)\right )^2 \, dx=\begin {cases} a^{2} x + 2 a b x - \frac {2 a b \log {\left (\tanh {\left (c + d x \right )} + 1 \right )}}{d} - \frac {a b \tanh ^{2}{\left (c + d x \right )}}{d} + b^{2} x - \frac {b^{2} \tanh ^{5}{\left (c + d x \right )}}{5 d} - \frac {b^{2} \tanh ^{3}{\left (c + d x \right )}}{3 d} - \frac {b^{2} \tanh {\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \left (a + b \tanh ^{3}{\left (c \right )}\right )^{2} & \text {otherwise} \end {cases} \] Input:

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

Output:

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

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 194 vs. \(2 (85) = 170\).

Time = 0.12 (sec) , antiderivative size = 194, normalized size of antiderivative = 2.18 \[ \int \left (a+b \tanh ^3(c+d x)\right )^2 \, dx=\frac {1}{15} \, b^{2} {\left (15 \, x + \frac {15 \, c}{d} - \frac {2 \, {\left (70 \, e^{\left (-2 \, d x - 2 \, c\right )} + 140 \, e^{\left (-4 \, d x - 4 \, c\right )} + 90 \, e^{\left (-6 \, d x - 6 \, c\right )} + 45 \, e^{\left (-8 \, d x - 8 \, c\right )} + 23\right )}}{d {\left (5 \, e^{\left (-2 \, d x - 2 \, c\right )} + 10 \, e^{\left (-4 \, d x - 4 \, c\right )} + 10 \, e^{\left (-6 \, d x - 6 \, c\right )} + 5 \, e^{\left (-8 \, d x - 8 \, c\right )} + e^{\left (-10 \, d x - 10 \, c\right )} + 1\right )}}\right )} + 2 \, a b {\left (x + \frac {c}{d} + \frac {\log \left (e^{\left (-2 \, d x - 2 \, c\right )} + 1\right )}{d} + \frac {2 \, e^{\left (-2 \, d x - 2 \, c\right )}}{d {\left (2 \, e^{\left (-2 \, d x - 2 \, c\right )} + e^{\left (-4 \, d x - 4 \, c\right )} + 1\right )}}\right )} + a^{2} x \] Input:

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

Output:

1/15*b^2*(15*x + 15*c/d - 2*(70*e^(-2*d*x - 2*c) + 140*e^(-4*d*x - 4*c) + 
90*e^(-6*d*x - 6*c) + 45*e^(-8*d*x - 8*c) + 23)/(d*(5*e^(-2*d*x - 2*c) + 1 
0*e^(-4*d*x - 4*c) + 10*e^(-6*d*x - 6*c) + 5*e^(-8*d*x - 8*c) + e^(-10*d*x 
 - 10*c) + 1))) + 2*a*b*(x + c/d + log(e^(-2*d*x - 2*c) + 1)/d + 2*e^(-2*d 
*x - 2*c)/(d*(2*e^(-2*d*x - 2*c) + e^(-4*d*x - 4*c) + 1))) + a^2*x
 

Giac [A] (verification not implemented)

Time = 0.13 (sec) , antiderivative size = 142, normalized size of antiderivative = 1.60 \[ \int \left (a+b \tanh ^3(c+d x)\right )^2 \, dx=\frac {30 \, a b \log \left (e^{\left (2 \, d x + 2 \, c\right )} + 1\right ) + 15 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} {\left (d x + c\right )} + \frac {2 \, {\left (23 \, b^{2} + 15 \, {\left (2 \, a b + 3 \, b^{2}\right )} e^{\left (8 \, d x + 8 \, c\right )} + 90 \, {\left (a b + b^{2}\right )} e^{\left (6 \, d x + 6 \, c\right )} + 10 \, {\left (9 \, a b + 14 \, b^{2}\right )} e^{\left (4 \, d x + 4 \, c\right )} + 10 \, {\left (3 \, a b + 7 \, b^{2}\right )} e^{\left (2 \, d x + 2 \, c\right )}\right )}}{{\left (e^{\left (2 \, d x + 2 \, c\right )} + 1\right )}^{5}}}{15 \, d} \] Input:

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

Output:

1/15*(30*a*b*log(e^(2*d*x + 2*c) + 1) + 15*(a^2 - 2*a*b + b^2)*(d*x + c) + 
 2*(23*b^2 + 15*(2*a*b + 3*b^2)*e^(8*d*x + 8*c) + 90*(a*b + b^2)*e^(6*d*x 
+ 6*c) + 10*(9*a*b + 14*b^2)*e^(4*d*x + 4*c) + 10*(3*a*b + 7*b^2)*e^(2*d*x 
 + 2*c))/(e^(2*d*x + 2*c) + 1)^5)/d
 

Mupad [B] (verification not implemented)

Time = 2.62 (sec) , antiderivative size = 91, normalized size of antiderivative = 1.02 \[ \int \left (a+b \tanh ^3(c+d x)\right )^2 \, dx=x\,\left (a^2+2\,a\,b+b^2\right )-\frac {b^2\,\mathrm {tanh}\left (c+d\,x\right )}{d}-\frac {b^2\,{\mathrm {tanh}\left (c+d\,x\right )}^3}{3\,d}-\frac {b^2\,{\mathrm {tanh}\left (c+d\,x\right )}^5}{5\,d}-\frac {2\,a\,b\,\ln \left (\mathrm {tanh}\left (c+d\,x\right )+1\right )}{d}-\frac {a\,b\,{\mathrm {tanh}\left (c+d\,x\right )}^2}{d} \] Input:

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

Output:

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

Reduce [B] (verification not implemented)

Time = 0.60 (sec) , antiderivative size = 586, normalized size of antiderivative = 6.58 \[ \int \left (a+b \tanh ^3(c+d x)\right )^2 \, dx=\frac {-18 e^{10 d x +10 c} b^{2}+75 e^{2 d x +2 c} a^{2} d x +15 e^{10 d x +10 c} a^{2} d x +15 e^{10 d x +10 c} b^{2} d x +75 e^{8 d x +8 c} a^{2} d x +75 e^{8 d x +8 c} b^{2} d x +150 e^{6 d x +6 c} a^{2} d x +150 e^{6 d x +6 c} b^{2} d x +150 e^{4 d x +4 c} a^{2} d x +150 e^{4 d x +4 c} b^{2} d x +30 e^{10 d x +10 c} \mathrm {log}\left (e^{2 d x +2 c}+1\right ) a b +150 e^{8 d x +8 c} \mathrm {log}\left (e^{2 d x +2 c}+1\right ) a b +300 e^{6 d x +6 c} \mathrm {log}\left (e^{2 d x +2 c}+1\right ) a b +300 e^{4 d x +4 c} \mathrm {log}\left (e^{2 d x +2 c}+1\right ) a b -150 e^{2 d x +2 c} a b d x -30 e^{10 d x +10 c} a b d x -150 e^{8 d x +8 c} a b d x -300 e^{6 d x +6 c} a b d x -300 e^{4 d x +4 c} a b d x +50 e^{2 d x +2 c} b^{2}-30 a b d x +150 e^{2 d x +2 c} \mathrm {log}\left (e^{2 d x +2 c}+1\right ) a b +15 a^{2} d x +15 b^{2} d x +30 \,\mathrm {log}\left (e^{2 d x +2 c}+1\right ) a b +75 e^{2 d x +2 c} b^{2} d x +28 b^{2}-12 e^{10 d x +10 c} a b +60 e^{6 d x +6 c} a b +60 e^{4 d x +4 c} a b -12 a b +100 e^{4 d x +4 c} b^{2}}{15 d \left (e^{10 d x +10 c}+5 e^{8 d x +8 c}+10 e^{6 d x +6 c}+10 e^{4 d x +4 c}+5 e^{2 d x +2 c}+1\right )} \] Input:

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

Output:

(30*e**(10*c + 10*d*x)*log(e**(2*c + 2*d*x) + 1)*a*b + 15*e**(10*c + 10*d* 
x)*a**2*d*x - 30*e**(10*c + 10*d*x)*a*b*d*x - 12*e**(10*c + 10*d*x)*a*b + 
15*e**(10*c + 10*d*x)*b**2*d*x - 18*e**(10*c + 10*d*x)*b**2 + 150*e**(8*c 
+ 8*d*x)*log(e**(2*c + 2*d*x) + 1)*a*b + 75*e**(8*c + 8*d*x)*a**2*d*x - 15 
0*e**(8*c + 8*d*x)*a*b*d*x + 75*e**(8*c + 8*d*x)*b**2*d*x + 300*e**(6*c + 
6*d*x)*log(e**(2*c + 2*d*x) + 1)*a*b + 150*e**(6*c + 6*d*x)*a**2*d*x - 300 
*e**(6*c + 6*d*x)*a*b*d*x + 60*e**(6*c + 6*d*x)*a*b + 150*e**(6*c + 6*d*x) 
*b**2*d*x + 300*e**(4*c + 4*d*x)*log(e**(2*c + 2*d*x) + 1)*a*b + 150*e**(4 
*c + 4*d*x)*a**2*d*x - 300*e**(4*c + 4*d*x)*a*b*d*x + 60*e**(4*c + 4*d*x)* 
a*b + 150*e**(4*c + 4*d*x)*b**2*d*x + 100*e**(4*c + 4*d*x)*b**2 + 150*e**( 
2*c + 2*d*x)*log(e**(2*c + 2*d*x) + 1)*a*b + 75*e**(2*c + 2*d*x)*a**2*d*x 
- 150*e**(2*c + 2*d*x)*a*b*d*x + 75*e**(2*c + 2*d*x)*b**2*d*x + 50*e**(2*c 
 + 2*d*x)*b**2 + 30*log(e**(2*c + 2*d*x) + 1)*a*b + 15*a**2*d*x - 30*a*b*d 
*x - 12*a*b + 15*b**2*d*x + 28*b**2)/(15*d*(e**(10*c + 10*d*x) + 5*e**(8*c 
 + 8*d*x) + 10*e**(6*c + 6*d*x) + 10*e**(4*c + 4*d*x) + 5*e**(2*c + 2*d*x) 
 + 1))