3.1.8 \(\int (1+x \tan (x)+\tan ^2(x)) \, dx\) [8]

Optimal. Leaf size=42 \[ \frac {i x^2}{2}-x \log \left (1+e^{2 i x}\right )+\frac {1}{2} i \text {Li}_2\left (-e^{2 i x}\right )+\tan (x) \]

[Out]

1/2*I*x^2-x*ln(1+exp(2*I*x))+1/2*I*polylog(2,-exp(2*I*x))+tan(x)

________________________________________________________________________________________

Rubi [A]
time = 0.03, antiderivative size = 42, normalized size of antiderivative = 1.00, number of steps used = 7, number of rules used = 6, integrand size = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.600, Rules used = {3800, 2221, 2317, 2438, 3554, 8} \begin {gather*} \frac {1}{2} i \text {Li}_2\left (-e^{2 i x}\right )+\frac {i x^2}{2}-x \log \left (1+e^{2 i x}\right )+\tan (x) \end {gather*}

Antiderivative was successfully verified.

[In]

Int[1 + x*Tan[x] + Tan[x]^2,x]

[Out]

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

Rule 8

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

Rule 2221

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]
 - 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 2317

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 2438

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 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]

Rule 3800

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]

Rubi steps

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

________________________________________________________________________________________

Mathematica [A]
time = 0.01, size = 42, normalized size = 1.00 \begin {gather*} \frac {i x^2}{2}-x \log \left (1+e^{2 i x}\right )+\frac {1}{2} i \text {Li}_2\left (-e^{2 i x}\right )+\tan (x) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[1 + x*Tan[x] + Tan[x]^2,x]

[Out]

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

________________________________________________________________________________________

Mathics [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {cought exception: maximum recursion depth exceeded} \end {gather*}

Warning: Unable to verify antiderivative.

[In]

mathics('Integrate[1 + x*Tan[x] + Tan[x]^2,x]')

[Out]

cought exception: maximum recursion depth exceeded

________________________________________________________________________________________

Maple [A]
time = 0.02, size = 43, normalized size = 1.02

method result size
risch \(\frac {i x^{2}}{2}-x \ln \left ({\mathrm e}^{2 i x}+1\right )+\frac {i \polylog \left (2, -{\mathrm e}^{2 i x}\right )}{2}+\frac {2 i}{{\mathrm e}^{2 i x}+1}\) \(43\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(1+x*tan(x)+tan(x)^2,x,method=_RETURNVERBOSE)

[Out]

1/2*I*x^2-x*ln(exp(2*I*x)+1)+1/2*I*polylog(2,-exp(2*I*x))+2*I/(exp(2*I*x)+1)

________________________________________________________________________________________

Maxima [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 142 vs. \(2 (27) = 54\).
time = 0.39, size = 142, normalized size = 3.38 \begin {gather*} x + \frac {x^{2} - 2 \, {\left (x \cos \left (2 \, x\right ) + i \, x \sin \left (2 \, x\right ) + x\right )} \arctan \left (\sin \left (2 \, x\right ), \cos \left (2 \, x\right ) + 1\right ) + {\left (x^{2} + 2 i \, x\right )} \cos \left (2 \, x\right ) + {\left (\cos \left (2 \, x\right ) + i \, \sin \left (2 \, x\right ) + 1\right )} {\rm Li}_2\left (-e^{\left (2 i \, x\right )}\right ) - {\left (-i \, x \cos \left (2 \, x\right ) + x \sin \left (2 \, x\right ) - i \, x\right )} \log \left (\cos \left (2 \, x\right )^{2} + \sin \left (2 \, x\right )^{2} + 2 \, \cos \left (2 \, x\right ) + 1\right ) - {\left (-i \, x^{2} + 2 \, x\right )} \sin \left (2 \, x\right ) + 2 i \, x + 4}{-2 i \, \cos \left (2 \, x\right ) + 2 \, \sin \left (2 \, x\right ) - 2 i} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

x + (x^2 - 2*(x*cos(2*x) + I*x*sin(2*x) + x)*arctan2(sin(2*x), cos(2*x) + 1) + (x^2 + 2*I*x)*cos(2*x) + (cos(2
*x) + I*sin(2*x) + 1)*dilog(-e^(2*I*x)) - (-I*x*cos(2*x) + x*sin(2*x) - I*x)*log(cos(2*x)^2 + sin(2*x)^2 + 2*c
os(2*x) + 1) - (-I*x^2 + 2*x)*sin(2*x) + 2*I*x + 4)/(-2*I*cos(2*x) + 2*sin(2*x) - 2*I)

________________________________________________________________________________________

Fricas [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 85 vs. \(2 (27) = 54\).
time = 0.36, size = 85, normalized size = 2.02 \begin {gather*} -\frac {1}{2} \, x \log \left (-\frac {2 \, {\left (i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1}\right ) - \frac {1}{2} \, x \log \left (-\frac {2 \, {\left (-i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1}\right ) - \frac {1}{4} i \, {\rm Li}_2\left (\frac {2 \, {\left (i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1} + 1\right ) + \frac {1}{4} i \, {\rm Li}_2\left (\frac {2 \, {\left (-i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1} + 1\right ) + \tan \left (x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-1/2*x*log(-2*(I*tan(x) - 1)/(tan(x)^2 + 1)) - 1/2*x*log(-2*(-I*tan(x) - 1)/(tan(x)^2 + 1)) - 1/4*I*dilog(2*(I
*tan(x) - 1)/(tan(x)^2 + 1) + 1) + 1/4*I*dilog(2*(-I*tan(x) - 1)/(tan(x)^2 + 1) + 1) + tan(x)

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \left (x \tan {\left (x \right )} + \tan ^{2}{\left (x \right )} + 1\right )\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1+x*tan(x)+tan(x)**2,x)

[Out]

Integral(x*tan(x) + tan(x)**2 + 1, x)

________________________________________________________________________________________

Giac [F] N/A
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Could not integrate} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1+x*tan(x)+tan(x)^2,x)

[Out]

Could not integrate

________________________________________________________________________________________

Mupad [B]
time = 0.22, size = 32, normalized size = 0.76 \begin {gather*} \mathrm {tan}\left (x\right )+\frac {\mathrm {polylog}\left (2,-{\mathrm {e}}^{x\,2{}\mathrm {i}}\right )\,1{}\mathrm {i}}{2}+\frac {x\,\left (x+\ln \left ({\mathrm {e}}^{x\,2{}\mathrm {i}}+1\right )\,2{}\mathrm {i}\right )\,1{}\mathrm {i}}{2} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tan(x)^2 + x*tan(x) + 1,x)

[Out]

tan(x) + (polylog(2, -exp(x*2i))*1i)/2 + (x*(x + log(exp(x*2i) + 1)*2i)*1i)/2

________________________________________________________________________________________