### 3.7 $$\int x^2 \tan ^2(a+b x) \, dx$$

Optimal. Leaf size=73 $-\frac{i \text{PolyLog}\left (2,-e^{2 i (a+b x)}\right )}{b^3}+\frac{2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac{x^2 \tan (a+b x)}{b}-\frac{i x^2}{b}-\frac{x^3}{3}$

[Out]

((-I)*x^2)/b - x^3/3 + (2*x*Log[1 + E^((2*I)*(a + b*x))])/b^2 - (I*PolyLog[2, -E^((2*I)*(a + b*x))])/b^3 + (x^
2*Tan[a + b*x])/b

________________________________________________________________________________________

Rubi [A]  time = 0.112149, antiderivative size = 73, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 12, $$\frac{\text{number of rules}}{\text{integrand size}}$$ = 0.5, Rules used = {3720, 3719, 2190, 2279, 2391, 30} $-\frac{i \text{Li}_2\left (-e^{2 i (a+b x)}\right )}{b^3}+\frac{2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac{x^2 \tan (a+b x)}{b}-\frac{i x^2}{b}-\frac{x^3}{3}$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

((-I)*x^2)/b - x^3/3 + (2*x*Log[1 + E^((2*I)*(a + b*x))])/b^2 - (I*PolyLog[2, -E^((2*I)*(a + b*x))])/b^3 + (x^
2*Tan[a + b*x])/b

Rule 3720

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[(b*(c + d*x)^m*(b*Tan[e
+ f*x])^(n - 1))/(f*(n - 1)), x] + (-Dist[(b*d*m)/(f*(n - 1)), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rule 3719

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

Rule 2190

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*Log[1 + (b*(F^(g*(e + f*x)))^n)/a])/(b*f*g*n*Log[F]), x]
- Dist[(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 2279

Int[Log[(a_) + (b_.)*((F_)^((e_.)*((c_.) + (d_.)*(x_))))^(n_.)], x_Symbol] :> Dist[1/(d*e*n*Log[F]), Subst[Int
[Log[a + b*x]/x, x], x, (F^(e*(c + d*x)))^n], x] /; FreeQ[{F, a, b, c, d, e, n}, x] && GtQ[a, 0]

Rule 2391

Int[Log[(c_.)*((d_) + (e_.)*(x_)^(n_.))]/(x_), x_Symbol] :> -Simp[PolyLog[2, -(c*e*x^n)]/n, x] /; FreeQ[{c, d,
e, n}, x] && EqQ[c*d, 1]

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rubi steps

\begin{align*} \int x^2 \tan ^2(a+b x) \, dx &=\frac{x^2 \tan (a+b x)}{b}-\frac{2 \int x \tan (a+b x) \, dx}{b}-\int x^2 \, dx\\ &=-\frac{i x^2}{b}-\frac{x^3}{3}+\frac{x^2 \tan (a+b x)}{b}+\frac{(4 i) \int \frac{e^{2 i (a+b x)} x}{1+e^{2 i (a+b x)}} \, dx}{b}\\ &=-\frac{i x^2}{b}-\frac{x^3}{3}+\frac{2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac{x^2 \tan (a+b x)}{b}-\frac{2 \int \log \left (1+e^{2 i (a+b x)}\right ) \, dx}{b^2}\\ &=-\frac{i x^2}{b}-\frac{x^3}{3}+\frac{2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}+\frac{x^2 \tan (a+b x)}{b}+\frac{i \operatorname{Subst}\left (\int \frac{\log (1+x)}{x} \, dx,x,e^{2 i (a+b x)}\right )}{b^3}\\ &=-\frac{i x^2}{b}-\frac{x^3}{3}+\frac{2 x \log \left (1+e^{2 i (a+b x)}\right )}{b^2}-\frac{i \text{Li}_2\left (-e^{2 i (a+b x)}\right )}{b^3}+\frac{x^2 \tan (a+b x)}{b}\\ \end{align*}

Mathematica [B]  time = 5.41029, size = 160, normalized size = 2.19 $\frac{-i \text{PolyLog}\left (2,e^{2 i \left (b x-\tan ^{-1}(\cot (a))\right )}\right )+b^2 x^2 \tan (a) \sqrt{\csc ^2(a)} e^{-i \tan ^{-1}(\cot (a))}+i b x \left (2 \tan ^{-1}(\cot (a))+\pi \right )+2 \left (b x-\tan ^{-1}(\cot (a))\right ) \log \left (1-e^{2 i \left (b x-\tan ^{-1}(\cot (a))\right )}\right )+2 \tan ^{-1}(\cot (a)) \log \left (\sin \left (b x-\tan ^{-1}(\cot (a))\right )\right )+\pi \log \left (1+e^{-2 i b x}\right )-\pi \log (\cos (b x))}{b^3}+\frac{x^2 \sec (a) \sin (b x) \sec (a+b x)}{b}-\frac{x^3}{3}$

Warning: Unable to verify antiderivative.

[In]

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

[Out]

-x^3/3 + (x^2*Sec[a]*Sec[a + b*x]*Sin[b*x])/b + (I*b*x*(Pi + 2*ArcTan[Cot[a]]) + Pi*Log[1 + E^((-2*I)*b*x)] +
2*(b*x - ArcTan[Cot[a]])*Log[1 - E^((2*I)*(b*x - ArcTan[Cot[a]]))] - Pi*Log[Cos[b*x]] + 2*ArcTan[Cot[a]]*Log[S
in[b*x - ArcTan[Cot[a]]]] - I*PolyLog[2, E^((2*I)*(b*x - ArcTan[Cot[a]]))] + (b^2*x^2*Sqrt[Csc[a]^2]*Tan[a])/E
^(I*ArcTan[Cot[a]]))/b^3

________________________________________________________________________________________

Maple [A]  time = 0.046, size = 108, normalized size = 1.5 \begin{align*} -{\frac{{x}^{3}}{3}}+{\frac{2\,i{x}^{2}}{b \left ( 1+{{\rm e}^{2\,i \left ( bx+a \right ) }} \right ) }}-{\frac{2\,i{x}^{2}}{b}}-{\frac{4\,iax}{{b}^{2}}}-{\frac{2\,i{a}^{2}}{{b}^{3}}}+2\,{\frac{x\ln \left ( 1+{{\rm e}^{2\,i \left ( bx+a \right ) }} \right ) }{{b}^{2}}}-{\frac{i{\it polylog} \left ( 2,-{{\rm e}^{2\,i \left ( bx+a \right ) }} \right ) }{{b}^{3}}}+4\,{\frac{a\ln \left ({{\rm e}^{i \left ( bx+a \right ) }} \right ) }{{b}^{3}}} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-1/3*x^3+2*I*x^2/b/(1+exp(2*I*(b*x+a)))-2*I/b*x^2-4*I/b^2*a*x-2*I/b^3*a^2+2*x*ln(1+exp(2*I*(b*x+a)))/b^2-I*pol
ylog(2,-exp(2*I*(b*x+a)))/b^3+4/b^3*a*ln(exp(I*(b*x+a)))

________________________________________________________________________________________

Maxima [B]  time = 1.78229, size = 348, normalized size = 4.77 \begin{align*} \frac{i \, b^{3} x^{3} + 6 \,{\left (b x \cos \left (2 \, b x + 2 \, a\right ) + i \, b x \sin \left (2 \, b x + 2 \, a\right ) + b x\right )} \arctan \left (\sin \left (2 \, b x + 2 \, a\right ), \cos \left (2 \, b x + 2 \, a\right ) + 1\right ) +{\left (i \, b^{3} x^{3} - 6 \, b^{2} x^{2}\right )} \cos \left (2 \, b x + 2 \, a\right ) -{\left (3 \, \cos \left (2 \, b x + 2 \, a\right ) + 3 i \, \sin \left (2 \, b x + 2 \, a\right ) + 3\right )}{\rm Li}_2\left (-e^{\left (2 i \, b x + 2 i \, a\right )}\right ) +{\left (-3 i \, b x \cos \left (2 \, b x + 2 \, a\right ) + 3 \, b x \sin \left (2 \, b x + 2 \, a\right ) - 3 i \, b x\right )} \log \left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right ) -{\left (b^{3} x^{3} + 6 i \, b^{2} x^{2}\right )} \sin \left (2 \, b x + 2 \, a\right )}{-3 i \, b^{3} \cos \left (2 \, b x + 2 \, a\right ) + 3 \, b^{3} \sin \left (2 \, b x + 2 \, a\right ) - 3 i \, b^{3}} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

(I*b^3*x^3 + 6*(b*x*cos(2*b*x + 2*a) + I*b*x*sin(2*b*x + 2*a) + b*x)*arctan2(sin(2*b*x + 2*a), cos(2*b*x + 2*a
) + 1) + (I*b^3*x^3 - 6*b^2*x^2)*cos(2*b*x + 2*a) - (3*cos(2*b*x + 2*a) + 3*I*sin(2*b*x + 2*a) + 3)*dilog(-e^(
2*I*b*x + 2*I*a)) + (-3*I*b*x*cos(2*b*x + 2*a) + 3*b*x*sin(2*b*x + 2*a) - 3*I*b*x)*log(cos(2*b*x + 2*a)^2 + si
n(2*b*x + 2*a)^2 + 2*cos(2*b*x + 2*a) + 1) - (b^3*x^3 + 6*I*b^2*x^2)*sin(2*b*x + 2*a))/(-3*I*b^3*cos(2*b*x + 2
*a) + 3*b^3*sin(2*b*x + 2*a) - 3*I*b^3)

________________________________________________________________________________________

Fricas [B]  time = 1.62947, size = 387, normalized size = 5.3 \begin{align*} -\frac{2 \, b^{3} x^{3} - 6 \, b^{2} x^{2} \tan \left (b x + a\right ) - 6 \, b x \log \left (-\frac{2 \,{\left (i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1}\right ) - 6 \, b x \log \left (-\frac{2 \,{\left (-i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1}\right ) - 3 i \,{\rm Li}_2\left (\frac{2 \,{\left (i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1} + 1\right ) + 3 i \,{\rm Li}_2\left (\frac{2 \,{\left (-i \, \tan \left (b x + a\right ) - 1\right )}}{\tan \left (b x + a\right )^{2} + 1} + 1\right )}{6 \, b^{3}} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-1/6*(2*b^3*x^3 - 6*b^2*x^2*tan(b*x + a) - 6*b*x*log(-2*(I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1)) - 6*b*x*log
(-2*(-I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1)) - 3*I*dilog(2*(I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1) + 1) +
3*I*dilog(2*(-I*tan(b*x + a) - 1)/(tan(b*x + a)^2 + 1) + 1))/b^3

________________________________________________________________________________________

Sympy [F]  time = 0., size = 0, normalized size = 0. \begin{align*} \int x^{2} \tan ^{2}{\left (a + b x \right )}\, dx \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Integral(x**2*tan(a + b*x)**2, x)

________________________________________________________________________________________

Giac [F]  time = 0., size = 0, normalized size = 0. \begin{align*} \int x^{2} \tan \left (b x + a\right )^{2}\,{d x} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

integrate(x^2*tan(b*x + a)^2, x)