\(\int \log (a \sec ^2(x)) \, dx\) [174]

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

Optimal result

Integrand size = 7, antiderivative size = 45 \[ \int \log \left (a \sec ^2(x)\right ) \, dx=-i x^2+2 x \log \left (1+e^{2 i x}\right )+x \log \left (a \sec ^2(x)\right )-i \operatorname {PolyLog}\left (2,-e^{2 i x}\right ) \]

[Out]

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

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 45, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.857, Rules used = {2628, 12, 3800, 2221, 2317, 2438} \[ \int \log \left (a \sec ^2(x)\right ) \, dx=x \log \left (a \sec ^2(x)\right )-i \operatorname {PolyLog}\left (2,-e^{2 i x}\right )-i x^2+2 x \log \left (1+e^{2 i x}\right ) \]

[In]

Int[Log[a*Sec[x]^2],x]

[Out]

(-I)*x^2 + 2*x*Log[1 + E^((2*I)*x)] + x*Log[a*Sec[x]^2] - I*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 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 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 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*} \text {integral}& = x \log \left (a \sec ^2(x)\right )-\int 2 x \tan (x) \, dx \\ & = x \log \left (a \sec ^2(x)\right )-2 \int x \tan (x) \, dx \\ & = -i x^2+x \log \left (a \sec ^2(x)\right )+4 i \int \frac {e^{2 i x} x}{1+e^{2 i x}} \, dx \\ & = -i x^2+2 x \log \left (1+e^{2 i x}\right )+x \log \left (a \sec ^2(x)\right )-2 \int \log \left (1+e^{2 i x}\right ) \, dx \\ & = -i x^2+2 x \log \left (1+e^{2 i x}\right )+x \log \left (a \sec ^2(x)\right )+i \text {Subst}\left (\int \frac {\log (1+x)}{x} \, dx,x,e^{2 i x}\right ) \\ & = -i x^2+2 x \log \left (1+e^{2 i x}\right )+x \log \left (a \sec ^2(x)\right )-i \text {Li}_2\left (-e^{2 i x}\right ) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.02 (sec) , antiderivative size = 43, normalized size of antiderivative = 0.96 \[ \int \log \left (a \sec ^2(x)\right ) \, dx=x \left (-i x+2 \log \left (1+e^{2 i x}\right )+\log \left (a \sec ^2(x)\right )\right )-i \operatorname {PolyLog}\left (2,-e^{2 i x}\right ) \]

[In]

Integrate[Log[a*Sec[x]^2],x]

[Out]

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

Maple [B] (verified)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 116 vs. \(2 (39 ) = 78\).

Time = 1.31 (sec) , antiderivative size = 117, normalized size of antiderivative = 2.60

method result size
default \(-i \left (\ln \left ({\mathrm e}^{i x}\right ) \ln \left (\frac {a \,{\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right )-\ln \left ({\mathrm e}^{i x}\right )^{2}+2 \ln \left ({\mathrm e}^{i x}\right ) \ln \left (1+i {\mathrm e}^{i x}\right )+2 \ln \left ({\mathrm e}^{i x}\right ) \ln \left (1-i {\mathrm e}^{i x}\right )+2 \operatorname {dilog}\left (1+i {\mathrm e}^{i x}\right )+2 \operatorname {dilog}\left (1-i {\mathrm e}^{i x}\right )+2 \ln \left (2\right ) \ln \left ({\mathrm e}^{i x}\right )\right )\) \(117\)
risch \(2 x \ln \left ({\mathrm e}^{i x}\right )-i x^{2}-\frac {i \pi \,\operatorname {csgn}\left (i {\mathrm e}^{2 i x}\right ) \operatorname {csgn}\left (\frac {i}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right ) \operatorname {csgn}\left (\frac {i {\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right ) x}{2}-i \pi \,\operatorname {csgn}\left (i \left (1+{\mathrm e}^{2 i x}\right )\right ) {\operatorname {csgn}\left (i \left (1+{\mathrm e}^{2 i x}\right )^{2}\right )}^{2} x -2 i \ln \left ({\mathrm e}^{i x}\right ) \ln \left (1-i {\mathrm e}^{i x}\right )+\frac {i \pi {\operatorname {csgn}\left (i \left (1+{\mathrm e}^{2 i x}\right )\right )}^{2} \operatorname {csgn}\left (i \left (1+{\mathrm e}^{2 i x}\right )^{2}\right ) x}{2}-\frac {i \pi \operatorname {csgn}\left (i {\mathrm e}^{2 i x}\right )^{3} x}{2}+\frac {i \pi \,\operatorname {csgn}\left (i {\mathrm e}^{2 i x}\right ) \operatorname {csgn}\left (\frac {i {\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right )^{2} x}{2}+\frac {i \pi \,\operatorname {csgn}\left (\frac {i {\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right ) \operatorname {csgn}\left (\frac {i a \,{\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right )^{2} x}{2}+2 x \ln \left (2\right )+\ln \left (a \right ) x +2 i \ln \left ({\mathrm e}^{i x}\right ) \ln \left (1+{\mathrm e}^{2 i x}\right )-\frac {i \pi \operatorname {csgn}\left (\frac {i {\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right )^{3} x}{2}-\frac {i \pi \,\operatorname {csgn}\left (\frac {i {\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right ) \operatorname {csgn}\left (\frac {i a \,{\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right ) \operatorname {csgn}\left (i a \right ) x}{2}-2 i \operatorname {dilog}\left (1+i {\mathrm e}^{i x}\right )+\frac {i \pi \,\operatorname {csgn}\left (\frac {i}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right ) \operatorname {csgn}\left (\frac {i {\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right )^{2} x}{2}+i \pi \,\operatorname {csgn}\left (i {\mathrm e}^{i x}\right ) \operatorname {csgn}\left (i {\mathrm e}^{2 i x}\right )^{2} x +\frac {i \pi {\operatorname {csgn}\left (i \left (1+{\mathrm e}^{2 i x}\right )^{2}\right )}^{3} x}{2}-\frac {i \pi \operatorname {csgn}\left (i {\mathrm e}^{i x}\right )^{2} \operatorname {csgn}\left (i {\mathrm e}^{2 i x}\right ) x}{2}-2 i \ln \left ({\mathrm e}^{i x}\right ) \ln \left (1+i {\mathrm e}^{i x}\right )-2 i \operatorname {dilog}\left (1-i {\mathrm e}^{i x}\right )-\frac {i \pi \operatorname {csgn}\left (\frac {i a \,{\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right )^{3} x}{2}+\frac {i \pi \operatorname {csgn}\left (\frac {i a \,{\mathrm e}^{2 i x}}{\left (1+{\mathrm e}^{2 i x}\right )^{2}}\right )^{2} \operatorname {csgn}\left (i a \right ) x}{2}\) \(549\)

[In]

int(ln(a*sec(x)^2),x,method=_RETURNVERBOSE)

[Out]

-I*(ln(exp(I*x))*ln(a*exp(I*x)^2/(exp(I*x)^2+1)^2)-ln(exp(I*x))^2+2*ln(exp(I*x))*ln(1+I*exp(I*x))+2*ln(exp(I*x
))*ln(1-I*exp(I*x))+2*dilog(1+I*exp(I*x))+2*dilog(1-I*exp(I*x))+2*ln(2)*ln(exp(I*x)))

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 102 vs. \(2 (34) = 68\).

Time = 0.36 (sec) , antiderivative size = 102, normalized size of antiderivative = 2.27 \[ \int \log \left (a \sec ^2(x)\right ) \, dx=x \log \left (\frac {a}{\cos \left (x\right )^{2}}\right ) + x \log \left (i \, \cos \left (x\right ) + \sin \left (x\right ) + 1\right ) + x \log \left (i \, \cos \left (x\right ) - \sin \left (x\right ) + 1\right ) + x \log \left (-i \, \cos \left (x\right ) + \sin \left (x\right ) + 1\right ) + x \log \left (-i \, \cos \left (x\right ) - \sin \left (x\right ) + 1\right ) + i \, {\rm Li}_2\left (i \, \cos \left (x\right ) + \sin \left (x\right )\right ) - i \, {\rm Li}_2\left (i \, \cos \left (x\right ) - \sin \left (x\right )\right ) - i \, {\rm Li}_2\left (-i \, \cos \left (x\right ) + \sin \left (x\right )\right ) + i \, {\rm Li}_2\left (-i \, \cos \left (x\right ) - \sin \left (x\right )\right ) \]

[In]

integrate(log(a*sec(x)^2),x, algorithm="fricas")

[Out]

x*log(a/cos(x)^2) + x*log(I*cos(x) + sin(x) + 1) + x*log(I*cos(x) - sin(x) + 1) + x*log(-I*cos(x) + sin(x) + 1
) + x*log(-I*cos(x) - sin(x) + 1) + I*dilog(I*cos(x) + sin(x)) - I*dilog(I*cos(x) - sin(x)) - I*dilog(-I*cos(x
) + sin(x)) + I*dilog(-I*cos(x) - sin(x))

Sympy [F]

\[ \int \log \left (a \sec ^2(x)\right ) \, dx=\int \log {\left (a \sec ^{2}{\left (x \right )} \right )}\, dx \]

[In]

integrate(ln(a*sec(x)**2),x)

[Out]

Integral(log(a*sec(x)**2), x)

Maxima [A] (verification not implemented)

none

Time = 0.37 (sec) , antiderivative size = 61, normalized size of antiderivative = 1.36 \[ \int \log \left (a \sec ^2(x)\right ) \, dx=-i \, x^{2} + 2 i \, x \arctan \left (\sin \left (2 \, x\right ), \cos \left (2 \, x\right ) + 1\right ) + x \log \left (a \sec \left (x\right )^{2}\right ) + x \log \left (\cos \left (2 \, x\right )^{2} + \sin \left (2 \, x\right )^{2} + 2 \, \cos \left (2 \, x\right ) + 1\right ) - i \, {\rm Li}_2\left (-e^{\left (2 i \, x\right )}\right ) \]

[In]

integrate(log(a*sec(x)^2),x, algorithm="maxima")

[Out]

-I*x^2 + 2*I*x*arctan2(sin(2*x), cos(2*x) + 1) + x*log(a*sec(x)^2) + x*log(cos(2*x)^2 + sin(2*x)^2 + 2*cos(2*x
) + 1) - I*dilog(-e^(2*I*x))

Giac [F]

\[ \int \log \left (a \sec ^2(x)\right ) \, dx=\int { \log \left (a \sec \left (x\right )^{2}\right ) \,d x } \]

[In]

integrate(log(a*sec(x)^2),x, algorithm="giac")

[Out]

integrate(log(a*sec(x)^2), x)

Mupad [B] (verification not implemented)

Time = 1.49 (sec) , antiderivative size = 39, normalized size of antiderivative = 0.87 \[ \int \log \left (a \sec ^2(x)\right ) \, dx=x\,\ln \left (\frac {a}{{\cos \left (x\right )}^2}\right )-\mathrm {polylog}\left (2,-{\mathrm {e}}^{x\,2{}\mathrm {i}}\right )\,1{}\mathrm {i}-x\,\left (x+\ln \left ({\mathrm {e}}^{x\,2{}\mathrm {i}}+1\right )\,2{}\mathrm {i}\right )\,1{}\mathrm {i} \]

[In]

int(log(a/cos(x)^2),x)

[Out]

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