\(\int (c+d x)^2 \tanh (e+f x) \, dx\) [2]

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

Optimal result

Integrand size = 14, antiderivative size = 84 \[ \int (c+d x)^2 \tanh (e+f x) \, dx=-\frac {(c+d x)^3}{3 d}+\frac {(c+d x)^2 \log \left (1+e^{2 (e+f x)}\right )}{f}+\frac {d (c+d x) \operatorname {PolyLog}\left (2,-e^{2 (e+f x)}\right )}{f^2}-\frac {d^2 \operatorname {PolyLog}\left (3,-e^{2 (e+f x)}\right )}{2 f^3} \] Output:

-1/3*(d*x+c)^3/d+(d*x+c)^2*ln(1+exp(2*f*x+2*e))/f+d*(d*x+c)*polylog(2,-exp 
(2*f*x+2*e))/f^2-1/2*d^2*polylog(3,-exp(2*f*x+2*e))/f^3
 

Mathematica [A] (verified)

Time = 0.25 (sec) , antiderivative size = 143, normalized size of antiderivative = 1.70 \[ \int (c+d x)^2 \tanh (e+f x) \, dx=\frac {e^{2 e} \left (\frac {4 e^{-2 e} (c+d x)^3}{d}+\frac {6 \left (1+e^{-2 e}\right ) (c+d x)^2 \log \left (1+e^{-2 (e+f x)}\right )}{f}-\frac {3 d \left (1+e^{-2 e}\right ) \left (2 f (c+d x) \operatorname {PolyLog}\left (2,-e^{-2 (e+f x)}\right )+d \operatorname {PolyLog}\left (3,-e^{-2 (e+f x)}\right )\right )}{f^3}\right )}{6 \left (1+e^{2 e}\right )}+\frac {1}{3} x \left (3 c^2+3 c d x+d^2 x^2\right ) \tanh (e) \] Input:

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

Output:

(E^(2*e)*((4*(c + d*x)^3)/(d*E^(2*e)) + (6*(1 + E^(-2*e))*(c + d*x)^2*Log[ 
1 + E^(-2*(e + f*x))])/f - (3*d*(1 + E^(-2*e))*(2*f*(c + d*x)*PolyLog[2, - 
E^(-2*(e + f*x))] + d*PolyLog[3, -E^(-2*(e + f*x))]))/f^3))/(6*(1 + E^(2*e 
))) + (x*(3*c^2 + 3*c*d*x + d^2*x^2)*Tanh[e])/3
 

Rubi [C] (verified)

Result contains complex when optimal does not.

Time = 0.56 (sec) , antiderivative size = 105, normalized size of antiderivative = 1.25, number of steps used = 8, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.500, Rules used = {3042, 26, 4201, 2620, 3011, 2720, 7143}

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 (c+d x)^2 \tanh (e+f x) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int -i (c+d x)^2 \tan (i e+i f x)dx\)

\(\Big \downarrow \) 26

\(\displaystyle -i \int (c+d x)^2 \tan (i e+i f x)dx\)

\(\Big \downarrow \) 4201

\(\displaystyle -i \left (2 i \int \frac {e^{2 (e+f x)} (c+d x)^2}{1+e^{2 (e+f x)}}dx-\frac {i (c+d x)^3}{3 d}\right )\)

\(\Big \downarrow \) 2620

\(\displaystyle -i \left (2 i \left (\frac {(c+d x)^2 \log \left (e^{2 (e+f x)}+1\right )}{2 f}-\frac {d \int (c+d x) \log \left (1+e^{2 (e+f x)}\right )dx}{f}\right )-\frac {i (c+d x)^3}{3 d}\right )\)

\(\Big \downarrow \) 3011

\(\displaystyle -i \left (2 i \left (\frac {(c+d x)^2 \log \left (e^{2 (e+f x)}+1\right )}{2 f}-\frac {d \left (\frac {d \int \operatorname {PolyLog}\left (2,-e^{2 (e+f x)}\right )dx}{2 f}-\frac {(c+d x) \operatorname {PolyLog}\left (2,-e^{2 (e+f x)}\right )}{2 f}\right )}{f}\right )-\frac {i (c+d x)^3}{3 d}\right )\)

\(\Big \downarrow \) 2720

\(\displaystyle -i \left (2 i \left (\frac {(c+d x)^2 \log \left (e^{2 (e+f x)}+1\right )}{2 f}-\frac {d \left (\frac {d \int e^{-2 (e+f x)} \operatorname {PolyLog}\left (2,-e^{2 (e+f x)}\right )de^{2 (e+f x)}}{4 f^2}-\frac {(c+d x) \operatorname {PolyLog}\left (2,-e^{2 (e+f x)}\right )}{2 f}\right )}{f}\right )-\frac {i (c+d x)^3}{3 d}\right )\)

\(\Big \downarrow \) 7143

\(\displaystyle -i \left (2 i \left (\frac {(c+d x)^2 \log \left (e^{2 (e+f x)}+1\right )}{2 f}-\frac {d \left (\frac {d \operatorname {PolyLog}\left (3,-e^{2 (e+f x)}\right )}{4 f^2}-\frac {(c+d x) \operatorname {PolyLog}\left (2,-e^{2 (e+f x)}\right )}{2 f}\right )}{f}\right )-\frac {i (c+d x)^3}{3 d}\right )\)

Input:

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

Output:

(-I)*(((-1/3*I)*(c + d*x)^3)/d + (2*I)*(((c + d*x)^2*Log[1 + E^(2*(e + f*x 
))])/(2*f) - (d*(-1/2*((c + d*x)*PolyLog[2, -E^(2*(e + f*x))])/f + (d*Poly 
Log[3, -E^(2*(e + f*x))])/(4*f^2)))/f))
 

Defintions of rubi rules used

rule 26
Int[(Complex[0, a_])*(Fx_), x_Symbol] :> Simp[(Complex[Identity[0], a])   I 
nt[Fx, x], x] /; FreeQ[a, x] && EqQ[a^2, 1]
 

rule 2620
Int[(((F_)^((g_.)*((e_.) + (f_.)*(x_))))^(n_.)*((c_.) + (d_.)*(x_))^(m_.))/ 
((a_) + (b_.)*((F_)^((g_.)*((e_.) + (f_.)*(x_))))^(n_.)), x_Symbol] :> Simp 
[((c + d*x)^m/(b*f*g*n*Log[F]))*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x] - Si 
mp[d*(m/(b*f*g*n*Log[F]))   Int[(c + d*x)^(m - 1)*Log[1 + b*((F^(g*(e + f*x 
)))^n/a)], x], x] /; FreeQ[{F, a, b, c, d, e, f, g, n}, x] && IGtQ[m, 0]
 

rule 2720
Int[u_, x_Symbol] :> With[{v = FunctionOfExponential[u, x]}, Simp[v/D[v, x] 
   Subst[Int[FunctionOfExponentialFunction[u, x]/x, x], x, v], x]] /; Funct 
ionOfExponentialQ[u, x] &&  !MatchQ[u, (w_)*((a_.)*(v_)^(n_))^(m_) /; FreeQ 
[{a, m, n}, x] && IntegerQ[m*n]] &&  !MatchQ[u, E^((c_.)*((a_.) + (b_.)*x)) 
*(F_)[v_] /; FreeQ[{a, b, c}, x] && InverseFunctionQ[F[x]]]
 

rule 3011
Int[Log[1 + (e_.)*((F_)^((c_.)*((a_.) + (b_.)*(x_))))^(n_.)]*((f_.) + (g_.) 
*(x_))^(m_.), x_Symbol] :> Simp[(-(f + g*x)^m)*(PolyLog[2, (-e)*(F^(c*(a + 
b*x)))^n]/(b*c*n*Log[F])), x] + Simp[g*(m/(b*c*n*Log[F]))   Int[(f + g*x)^( 
m - 1)*PolyLog[2, (-e)*(F^(c*(a + b*x)))^n], x], x] /; FreeQ[{F, a, b, c, e 
, f, g, n}, x] && GtQ[m, 0]
 

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

rule 4201
Int[((c_.) + (d_.)*(x_))^(m_.)*tan[(e_.) + (Complex[0, fz_])*(f_.)*(x_)], x 
_Symbol] :> Simp[(-I)*((c + d*x)^(m + 1)/(d*(m + 1))), x] + Simp[2*I   Int[ 
(c + d*x)^m*(E^(2*((-I)*e + f*fz*x))/(1 + E^(2*((-I)*e + f*fz*x)))), x], x] 
 /; FreeQ[{c, d, e, f, fz}, x] && IGtQ[m, 0]
 

rule 7143
Int[PolyLog[n_, (c_.)*((a_.) + (b_.)*(x_))^(p_.)]/((d_.) + (e_.)*(x_)), x_S 
ymbol] :> Simp[PolyLog[n + 1, c*(a + b*x)^p]/(e*p), x] /; FreeQ[{a, b, c, d 
, e, n, p}, x] && EqQ[b*d, a*e]
 
Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(241\) vs. \(2(80)=160\).

Time = 0.75 (sec) , antiderivative size = 242, normalized size of antiderivative = 2.88

method result size
risch \(-\frac {d^{2} x^{3}}{3}-d c \,x^{2}+c^{2} x +\frac {c^{3}}{3 d}-\frac {2 d c \,e^{2}}{f^{2}}+\frac {2 d c \ln \left (1+{\mathrm e}^{2 f x +2 e}\right ) x}{f}+\frac {d c \operatorname {polylog}\left (2, -{\mathrm e}^{2 f x +2 e}\right )}{f^{2}}-\frac {2 e^{2} d^{2} \ln \left ({\mathrm e}^{f x +e}\right )}{f^{3}}+\frac {2 d^{2} e^{2} x}{f^{2}}+\frac {d^{2} \operatorname {polylog}\left (2, -{\mathrm e}^{2 f x +2 e}\right ) x}{f^{2}}-\frac {d^{2} \operatorname {polylog}\left (3, -{\mathrm e}^{2 f x +2 e}\right )}{2 f^{3}}+\frac {4 c d e \ln \left ({\mathrm e}^{f x +e}\right )}{f^{2}}-\frac {4 d c e x}{f}+\frac {4 d^{2} e^{3}}{3 f^{3}}-\frac {2 c^{2} \ln \left ({\mathrm e}^{f x +e}\right )}{f}+\frac {c^{2} \ln \left (1+{\mathrm e}^{2 f x +2 e}\right )}{f}+\frac {d^{2} \ln \left (1+{\mathrm e}^{2 f x +2 e}\right ) x^{2}}{f}\) \(242\)

Input:

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

Output:

-1/3*d^2*x^3-d*c*x^2+c^2*x+1/3/d*c^3-2/f^2*d*c*e^2+2/f*d*c*ln(1+exp(2*f*x+ 
2*e))*x+1/f^2*d*c*polylog(2,-exp(2*f*x+2*e))-2/f^3*e^2*d^2*ln(exp(f*x+e))+ 
2/f^2*d^2*e^2*x+1/f^2*d^2*polylog(2,-exp(2*f*x+2*e))*x-1/2*d^2*polylog(3,- 
exp(2*f*x+2*e))/f^3+4/f^2*c*d*e*ln(exp(f*x+e))-4/f*d*c*e*x+4/3/f^3*d^2*e^3 
-2/f*c^2*ln(exp(f*x+e))+1/f*c^2*ln(1+exp(2*f*x+2*e))+1/f*d^2*ln(1+exp(2*f* 
x+2*e))*x^2
 

Fricas [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 0.10 (sec) , antiderivative size = 329, normalized size of antiderivative = 3.92 \[ \int (c+d x)^2 \tanh (e+f x) \, dx=-\frac {d^{2} f^{3} x^{3} + 3 \, c d f^{3} x^{2} + 3 \, c^{2} f^{3} x + 6 \, d^{2} {\rm polylog}\left (3, i \, \cosh \left (f x + e\right ) + i \, \sinh \left (f x + e\right )\right ) + 6 \, d^{2} {\rm polylog}\left (3, -i \, \cosh \left (f x + e\right ) - i \, \sinh \left (f x + e\right )\right ) - 6 \, {\left (d^{2} f x + c d f\right )} {\rm Li}_2\left (i \, \cosh \left (f x + e\right ) + i \, \sinh \left (f x + e\right )\right ) - 6 \, {\left (d^{2} f x + c d f\right )} {\rm Li}_2\left (-i \, \cosh \left (f x + e\right ) - i \, \sinh \left (f x + e\right )\right ) - 3 \, {\left (d^{2} e^{2} - 2 \, c d e f + c^{2} f^{2}\right )} \log \left (\cosh \left (f x + e\right ) + \sinh \left (f x + e\right ) + i\right ) - 3 \, {\left (d^{2} e^{2} - 2 \, c d e f + c^{2} f^{2}\right )} \log \left (\cosh \left (f x + e\right ) + \sinh \left (f x + e\right ) - i\right ) - 3 \, {\left (d^{2} f^{2} x^{2} + 2 \, c d f^{2} x - d^{2} e^{2} + 2 \, c d e f\right )} \log \left (i \, \cosh \left (f x + e\right ) + i \, \sinh \left (f x + e\right ) + 1\right ) - 3 \, {\left (d^{2} f^{2} x^{2} + 2 \, c d f^{2} x - d^{2} e^{2} + 2 \, c d e f\right )} \log \left (-i \, \cosh \left (f x + e\right ) - i \, \sinh \left (f x + e\right ) + 1\right )}{3 \, f^{3}} \] Input:

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

Output:

-1/3*(d^2*f^3*x^3 + 3*c*d*f^3*x^2 + 3*c^2*f^3*x + 6*d^2*polylog(3, I*cosh( 
f*x + e) + I*sinh(f*x + e)) + 6*d^2*polylog(3, -I*cosh(f*x + e) - I*sinh(f 
*x + e)) - 6*(d^2*f*x + c*d*f)*dilog(I*cosh(f*x + e) + I*sinh(f*x + e)) - 
6*(d^2*f*x + c*d*f)*dilog(-I*cosh(f*x + e) - I*sinh(f*x + e)) - 3*(d^2*e^2 
 - 2*c*d*e*f + c^2*f^2)*log(cosh(f*x + e) + sinh(f*x + e) + I) - 3*(d^2*e^ 
2 - 2*c*d*e*f + c^2*f^2)*log(cosh(f*x + e) + sinh(f*x + e) - I) - 3*(d^2*f 
^2*x^2 + 2*c*d*f^2*x - d^2*e^2 + 2*c*d*e*f)*log(I*cosh(f*x + e) + I*sinh(f 
*x + e) + 1) - 3*(d^2*f^2*x^2 + 2*c*d*f^2*x - d^2*e^2 + 2*c*d*e*f)*log(-I* 
cosh(f*x + e) - I*sinh(f*x + e) + 1))/f^3
 

Sympy [F]

\[ \int (c+d x)^2 \tanh (e+f x) \, dx=\int \left (c + d x\right )^{2} \tanh {\left (e + f x \right )}\, dx \] Input:

integrate((d*x+c)**2*tanh(f*x+e),x)
 

Output:

Integral((c + d*x)**2*tanh(e + f*x), x)
 

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 176 vs. \(2 (79) = 158\).

Time = 0.16 (sec) , antiderivative size = 176, normalized size of antiderivative = 2.10 \[ \int (c+d x)^2 \tanh (e+f x) \, dx=\frac {1}{3} \, d^{2} x^{3} + c d x^{2} + \frac {c^{2} \log \left (e^{\left (2 \, f x + 2 \, e\right )} + 1\right )}{2 \, f} + \frac {c^{2} \log \left (e^{\left (-2 \, f x - 2 \, e\right )} + 1\right )}{2 \, f} + \frac {{\left (2 \, f x \log \left (e^{\left (2 \, f x + 2 \, e\right )} + 1\right ) + {\rm Li}_2\left (-e^{\left (2 \, f x + 2 \, e\right )}\right )\right )} c d}{f^{2}} + \frac {{\left (2 \, f^{2} x^{2} \log \left (e^{\left (2 \, f x + 2 \, e\right )} + 1\right ) + 2 \, f x {\rm Li}_2\left (-e^{\left (2 \, f x + 2 \, e\right )}\right ) - {\rm Li}_{3}(-e^{\left (2 \, f x + 2 \, e\right )})\right )} d^{2}}{2 \, f^{3}} - \frac {2 \, {\left (d^{2} f^{3} x^{3} + 3 \, c d f^{3} x^{2}\right )}}{3 \, f^{3}} \] Input:

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

Output:

1/3*d^2*x^3 + c*d*x^2 + 1/2*c^2*log(e^(2*f*x + 2*e) + 1)/f + 1/2*c^2*log(e 
^(-2*f*x - 2*e) + 1)/f + (2*f*x*log(e^(2*f*x + 2*e) + 1) + dilog(-e^(2*f*x 
 + 2*e)))*c*d/f^2 + 1/2*(2*f^2*x^2*log(e^(2*f*x + 2*e) + 1) + 2*f*x*dilog( 
-e^(2*f*x + 2*e)) - polylog(3, -e^(2*f*x + 2*e)))*d^2/f^3 - 2/3*(d^2*f^3*x 
^3 + 3*c*d*f^3*x^2)/f^3
 

Giac [F]

\[ \int (c+d x)^2 \tanh (e+f x) \, dx=\int { {\left (d x + c\right )}^{2} \tanh \left (f x + e\right ) \,d x } \] Input:

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

Output:

integrate((d*x + c)^2*tanh(f*x + e), x)
 

Mupad [F(-1)]

Timed out. \[ \int (c+d x)^2 \tanh (e+f x) \, dx=\int \mathrm {tanh}\left (e+f\,x\right )\,{\left (c+d\,x\right )}^2 \,d x \] Input:

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

Output:

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

Reduce [F]

\[ \int (c+d x)^2 \tanh (e+f x) \, dx=\frac {6 e^{2 e} \left (\int \frac {e^{2 f x} x^{2}}{e^{2 f x +2 e}+1}d x \right ) d^{2} f +12 e^{2 e} \left (\int \frac {e^{2 f x} x}{e^{2 f x +2 e}+1}d x \right ) c d f +3 \,\mathrm {log}\left (e^{2 f x +2 e}+1\right ) c^{2}-3 c^{2} f x -3 c d f \,x^{2}-d^{2} f \,x^{3}}{3 f} \] Input:

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

Output:

(6*e**(2*e)*int((e**(2*f*x)*x**2)/(e**(2*e + 2*f*x) + 1),x)*d**2*f + 12*e* 
*(2*e)*int((e**(2*f*x)*x)/(e**(2*e + 2*f*x) + 1),x)*c*d*f + 3*log(e**(2*e 
+ 2*f*x) + 1)*c**2 - 3*c**2*f*x - 3*c*d*f*x**2 - d**2*f*x**3)/(3*f)