3.2.69 \(\int \log (a \tan ^n(x)) \, dx\) [169]

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

[Out]

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

________________________________________________________________________________________

Rubi [A]
time = 0.03, antiderivative size = 56, normalized size of antiderivative = 1.00, number of steps used = 8, number of rules used = 6, integrand size = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.857, Rules used = {2628, 12, 4504, 4268, 2317, 2438} \begin {gather*} -\frac {1}{2} i n \text {PolyLog}\left (2,-e^{2 i x}\right )+\frac {1}{2} i n \text {PolyLog}\left (2,e^{2 i x}\right )+x \log \left (a \tan ^n(x)\right )+2 n x \tanh ^{-1}\left (e^{2 i x}\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Log[a*Tan[x]^n],x]

[Out]

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

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

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 2628

Int[Log[u_], x_Symbol] :> Simp[x*Log[u], x] - Int[SimplifyIntegrand[x*(D[u, x]/u), x], x] /; InverseFunctionFr
eeQ[u, x]

Rule 4268

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

Rule 4504

Int[Csc[(a_.) + (b_.)*(x_)]^(n_.)*((c_.) + (d_.)*(x_))^(m_.)*Sec[(a_.) + (b_.)*(x_)]^(n_.), x_Symbol] :> Dist[
2^n, Int[(c + d*x)^m*Csc[2*a + 2*b*x]^n, x], x] /; FreeQ[{a, b, c, d, m}, x] && IntegerQ[n] && RationalQ[m]

Rubi steps

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

________________________________________________________________________________________

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

Antiderivative was successfully verified.

[In]

Integrate[Log[a*Tan[x]^n],x]

[Out]

(-1/2*I)*Log[(-I)*(I - Tan[x])]*Log[a*Tan[x]^n] + (I/2)*Log[a*Tan[x]^n]*Log[(-I)*(I + Tan[x])] - (I/2)*n*PolyL
og[2, (-I)*Tan[x]] + (I/2)*n*PolyLog[2, I*Tan[x]]

________________________________________________________________________________________

Maple [C] Result contains higher order function than in optimal. Order 9 vs. order 4.
time = 1.84, size = 2356, normalized size = 42.07

method result size
risch \(\text {Expression too large to display}\) \(2356\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(ln(a*tan(x)^n),x,method=_RETURNVERBOSE)

[Out]

x*ln(exp(-1/2*n*(I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))^3*Pi-I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))^2*csgn(I
*(exp(2*I*x)-1))*Pi-I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))^2*csgn(I/(1+exp(2*I*x)))*Pi+I*csgn(I*(exp(2*I*x)-1
)/(1+exp(2*I*x)))*csgn(I*(exp(2*I*x)-1))*csgn(I/(1+exp(2*I*x)))*Pi-I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))*csg
n((exp(2*I*x)-1)/(1+exp(2*I*x)))^2*Pi+I*csgn((exp(2*I*x)-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exp(2*I*x)-1)/(1+exp(2*I*x)))*csgn((exp(2*I*x
)-1)/(1+exp(2*I*x)))^2*Pi+I*csgn((exp(2*I*x)-1)/(1+exp(2*I*x)))^3*Pi+I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))*c
sgn((exp(2*I*x)-1)/(1+exp(2*I*x)))*Pi-I*csgn((exp(2*I*x)-1)/(1+exp(2*I*x)))^2*Pi+I*Pi-2*ln(exp(2*I*x)-1)+2*ln(
1+exp(2*I*x)))))*csgn(I*a*exp(-1/2*n*(I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))^3*Pi-I*csgn(I*(exp(2*I*x)-1)/(1+
exp(2*I*x)))^2*csgn(I*(exp(2*I*x)-1))*Pi-I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))^2*csgn(I/(1+exp(2*I*x)))*Pi+I
*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))*csgn(I*(exp(2*I*x)-1))*csgn(I/(1+exp(2*I*x)))*Pi-I*csgn(I*(exp(2*I*x)-1
)/(1+exp(2*I*x)))*csgn((exp(2*I*x)-1)/(1+exp(2*I*x)))^2*Pi+I*csgn((exp(2*I*x)-1)/(1+exp(2*I*x)))^3*Pi+I*csgn(I
*(exp(2*I*x)-1)/(1+exp(2*I*x)))*csgn((exp(2*I*x)-1)/(1+exp(2*I*x)))*Pi-I*csgn((exp(2*I*x)-1)/(1+exp(2*I*x)))^2
*Pi+I*Pi-2*ln(exp(2*I*x)-1)+2*ln(1+exp(2*I*x)))))^2+x*ln(a)-I*n*dilog(exp(I*x))+I*n*dilog(exp(I*x)+1)-n*x*ln(e
xp(I*x)+1)+n*x*ln(1+I*exp(I*x))+n*x*ln(1-I*exp(I*x))-I*n*dilog(1+I*exp(I*x))-I*n*dilog(1-I*exp(I*x))-1/2*I*x*P
i*csgn(I*a*exp(-1/2*n*(I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))^3*Pi-I*csgn(I*(exp(2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a*exp(-1/2*n*(
I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))^3*Pi-I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))^2*csgn(I*(exp(2*I*x)-1))*
Pi-I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))^2*csgn(I/(1+exp(2*I*x)))*Pi+I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))
*csgn(I*(exp(2*I*x)-1))*csgn(I/(1+exp(2*I*x)))*Pi-I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))*csgn((exp(2*I*x)-1)/
(1+exp(2*I*x)))^2*Pi+I*csgn((exp(2*I*x)-1)/(1+exp(2*I*x)))^3*Pi+I*csgn(I*(exp(2*I*x)-1)/(1+exp(2*I*x)))*csgn((
exp(2*I*x)-1)/(1+exp(2*I*x)))*Pi-I*csgn((exp(2*I*x)-1)/(1+exp(2*I*x)))^2*Pi+I*Pi-2*ln(exp(2*I*x)-1)+2*ln(1+exp
(2*I*x)))))

________________________________________________________________________________________

Maxima [A]
time = 0.50, size = 48, normalized size = 0.86 \begin {gather*} -n x \log \left (\tan \left (x\right )\right ) + \frac {1}{4} \, {\left (\pi \log \left (\tan \left (x\right )^{2} + 1\right ) + 2 i \, {\rm Li}_2\left (i \, \tan \left (x\right ) + 1\right ) - 2 i \, {\rm Li}_2\left (-i \, \tan \left (x\right ) + 1\right )\right )} n + x \log \left (a \tan \left (x\right )^{n}\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(log(a*tan(x)^n),x, algorithm="maxima")

[Out]

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

________________________________________________________________________________________

Fricas [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 195 vs. \(2 (37) = 74\).
time = 0.41, size = 195, normalized size = 3.48 \begin {gather*} -\frac {1}{2} \, n x \log \left (\frac {2 \, {\left (\tan \left (x\right )^{2} + i \, \tan \left (x\right )\right )}}{\tan \left (x\right )^{2} + 1}\right ) - \frac {1}{2} \, n x \log \left (\frac {2 \, {\left (\tan \left (x\right )^{2} - i \, \tan \left (x\right )\right )}}{\tan \left (x\right )^{2} + 1}\right ) + \frac {1}{2} \, n x \log \left (-\frac {2 \, {\left (i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1}\right ) + \frac {1}{2} \, n x \log \left (-\frac {2 \, {\left (-i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1}\right ) + n x \log \left (\tan \left (x\right )\right ) - \frac {1}{4} i \, n {\rm Li}_2\left (-\frac {2 \, {\left (\tan \left (x\right )^{2} + i \, \tan \left (x\right )\right )}}{\tan \left (x\right )^{2} + 1} + 1\right ) + \frac {1}{4} i \, n {\rm Li}_2\left (-\frac {2 \, {\left (\tan \left (x\right )^{2} - i \, \tan \left (x\right )\right )}}{\tan \left (x\right )^{2} + 1} + 1\right ) + \frac {1}{4} i \, n {\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 \, n {\rm Li}_2\left (\frac {2 \, {\left (-i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1} + 1\right ) + x \log \left (a\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(log(a*tan(x)^n),x, algorithm="fricas")

[Out]

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

________________________________________________________________________________________

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

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(ln(a*tan(x)**n),x)

[Out]

Integral(log(a*tan(x)**n), x)

________________________________________________________________________________________

Giac [F]
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(log(a*tan(x)^n),x, algorithm="giac")

[Out]

integrate(log(a*tan(x)^n), x)

________________________________________________________________________________________

Mupad [B]
time = 0.07, size = 44, normalized size = 0.79 \begin {gather*} \frac {n\,\mathrm {polylog}\left (2,{\mathrm {e}}^{x\,2{}\mathrm {i}}\right )\,1{}\mathrm {i}}{2}+x\,\ln \left (a\,{\mathrm {tan}\left (x\right )}^n\right )-\frac {n\,\mathrm {polylog}\left (2,-{\mathrm {e}}^{x\,2{}\mathrm {i}}\right )\,1{}\mathrm {i}}{2}+2\,n\,x\,\mathrm {atanh}\left ({\mathrm {e}}^{x\,2{}\mathrm {i}}\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(log(a*tan(x)^n),x)

[Out]

(n*polylog(2, exp(x*2i))*1i)/2 + x*log(a*tan(x)^n) - (n*polylog(2, -exp(x*2i))*1i)/2 + 2*n*x*atanh(exp(x*2i))

________________________________________________________________________________________