\(\int \log (\cos (x)) \sec ^2(x) \, dx\) [303]

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

Optimal result

Integrand size = 8, antiderivative size = 12 \[ \int \log (\cos (x)) \sec ^2(x) \, dx=-x+\tan (x)+\log (\cos (x)) \tan (x) \]

[Out]

-x+tan(x)+ln(cos(x))*tan(x)

Rubi [A] (verified)

Time = 0.03 (sec) , antiderivative size = 12, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.500, Rules used = {3852, 8, 2634, 3554} \[ \int \log (\cos (x)) \sec ^2(x) \, dx=-x+\tan (x)+\tan (x) \log (\cos (x)) \]

[In]

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

[Out]

-x + Tan[x] + Log[Cos[x]]*Tan[x]

Rule 8

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

Rule 2634

Int[Log[u_]*(v_), x_Symbol] :> With[{w = IntHide[v, x]}, Dist[Log[u], w, x] - Int[SimplifyIntegrand[w*(D[u, x]
/u), x], x] /; InverseFunctionFreeQ[w, x]] /; InverseFunctionFreeQ[u, x]

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 3852

Int[csc[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> Dist[-d^(-1), Subst[Int[ExpandIntegrand[(1 + x^2)^(n/2 - 1), x]
, x], x, Cot[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[n/2, 0]

Rubi steps \begin{align*} \text {integral}& = \log (\cos (x)) \tan (x)+\int \tan ^2(x) \, dx \\ & = \tan (x)+\log (\cos (x)) \tan (x)-\int 1 \, dx \\ & = -x+\tan (x)+\log (\cos (x)) \tan (x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.02 (sec) , antiderivative size = 12, normalized size of antiderivative = 1.00 \[ \int \log (\cos (x)) \sec ^2(x) \, dx=-x+\tan (x)+\log (\cos (x)) \tan (x) \]

[In]

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

[Out]

-x + Tan[x] + Log[Cos[x]]*Tan[x]

Maple [A] (verified)

Time = 0.45 (sec) , antiderivative size = 13, normalized size of antiderivative = 1.08

method result size
parallelrisch \(-x +\tan \left (x \right )+\ln \left (\cos \left (x \right )\right ) \tan \left (x \right )\) \(13\)
norman \(\frac {x -x \tan \left (\frac {x}{2}\right )^{2}-2 \tan \left (\frac {x}{2}\right ) \ln \left (\frac {1-\tan \left (\frac {x}{2}\right )^{2}}{1+\tan \left (\frac {x}{2}\right )^{2}}\right )-2 \tan \left (\frac {x}{2}\right )}{\tan \left (\frac {x}{2}\right )^{2}-1}\) \(57\)
default \(-4 i \left (\frac {\frac {{\mathrm e}^{2 i x} \ln \left (\left ({\mathrm e}^{2 i x}+1\right ) {\mathrm e}^{-i x}\right )}{2}-\frac {1}{2}}{{\mathrm e}^{2 i x}+1}-\frac {\ln \left ({\mathrm e}^{2 i x}+1\right )}{4}+\frac {\ln \left (2\right )}{2 \,{\mathrm e}^{2 i x}+2}\right )\) \(67\)
risch \(-\frac {2 i \ln \left ({\mathrm e}^{i x}\right )}{{\mathrm e}^{2 i x}+1}+\frac {-i \ln \left ({\mathrm e}^{2 i x}+1\right ) {\mathrm e}^{2 i x}+\pi \,\operatorname {csgn}\left (i {\mathrm e}^{-i x}\right ) \operatorname {csgn}\left (i \left ({\mathrm e}^{2 i x}+1\right )\right ) \operatorname {csgn}\left (i \cos \left (x \right )\right )-\pi \,\operatorname {csgn}\left (i {\mathrm e}^{-i x}\right ) \operatorname {csgn}\left (i \cos \left (x \right )\right )^{2}-\pi \,\operatorname {csgn}\left (i \left ({\mathrm e}^{2 i x}+1\right )\right ) \operatorname {csgn}\left (i \cos \left (x \right )\right )^{2}+\pi \operatorname {csgn}\left (i \cos \left (x \right )\right )^{3}-2 \,{\mathrm e}^{2 i x} x -2 i \ln \left (2\right )+i \ln \left ({\mathrm e}^{2 i x}+1\right )+2 i-2 x}{{\mathrm e}^{2 i x}+1}\) \(156\)

[In]

int(ln(cos(x))/cos(x)^2,x,method=_RETURNVERBOSE)

[Out]

-x+tan(x)+ln(cos(x))*tan(x)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 22, normalized size of antiderivative = 1.83 \[ \int \log (\cos (x)) \sec ^2(x) \, dx=-\frac {x \cos \left (x\right ) - \log \left (\cos \left (x\right )\right ) \sin \left (x\right ) - \sin \left (x\right )}{\cos \left (x\right )} \]

[In]

integrate(log(cos(x))/cos(x)^2,x, algorithm="fricas")

[Out]

-(x*cos(x) - log(cos(x))*sin(x) - sin(x))/cos(x)

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 83 vs. \(2 (12) = 24\).

Time = 1.47 (sec) , antiderivative size = 83, normalized size of antiderivative = 6.92 \[ \int \log (\cos (x)) \sec ^2(x) \, dx=- \frac {x \tan ^{2}{\left (\frac {x}{2} \right )}}{\tan ^{2}{\left (\frac {x}{2} \right )} - 1} + \frac {x}{\tan ^{2}{\left (\frac {x}{2} \right )} - 1} - \frac {2 \log {\left (- \frac {\tan ^{2}{\left (\frac {x}{2} \right )}}{\tan ^{2}{\left (\frac {x}{2} \right )} + 1} + \frac {1}{\tan ^{2}{\left (\frac {x}{2} \right )} + 1} \right )} \tan {\left (\frac {x}{2} \right )}}{\tan ^{2}{\left (\frac {x}{2} \right )} - 1} - \frac {2 \tan {\left (\frac {x}{2} \right )}}{\tan ^{2}{\left (\frac {x}{2} \right )} - 1} \]

[In]

integrate(ln(cos(x))/cos(x)**2,x)

[Out]

-x*tan(x/2)**2/(tan(x/2)**2 - 1) + x/(tan(x/2)**2 - 1) - 2*log(-tan(x/2)**2/(tan(x/2)**2 + 1) + 1/(tan(x/2)**2
 + 1))*tan(x/2)/(tan(x/2)**2 - 1) - 2*tan(x/2)/(tan(x/2)**2 - 1)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 94 vs. \(2 (12) = 24\).

Time = 0.29 (sec) , antiderivative size = 94, normalized size of antiderivative = 7.83 \[ \int \log (\cos (x)) \sec ^2(x) \, dx=-\frac {2 \, \log \left (-\frac {\frac {\sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}} - 1}{\frac {\sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}} + 1}\right ) \sin \left (x\right )}{{\left (\frac {\sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}} - 1\right )} {\left (\cos \left (x\right ) + 1\right )}} - \frac {2 \, \sin \left (x\right )}{{\left (\frac {\sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}} - 1\right )} {\left (\cos \left (x\right ) + 1\right )}} - 2 \, \arctan \left (\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1}\right ) \]

[In]

integrate(log(cos(x))/cos(x)^2,x, algorithm="maxima")

[Out]

-2*log(-(sin(x)^2/(cos(x) + 1)^2 - 1)/(sin(x)^2/(cos(x) + 1)^2 + 1))*sin(x)/((sin(x)^2/(cos(x) + 1)^2 - 1)*(co
s(x) + 1)) - 2*sin(x)/((sin(x)^2/(cos(x) + 1)^2 - 1)*(cos(x) + 1)) - 2*arctan(sin(x)/(cos(x) + 1))

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 12, normalized size of antiderivative = 1.00 \[ \int \log (\cos (x)) \sec ^2(x) \, dx=\log \left (\cos \left (x\right )\right ) \tan \left (x\right ) - x + \tan \left (x\right ) \]

[In]

integrate(log(cos(x))/cos(x)^2,x, algorithm="giac")

[Out]

log(cos(x))*tan(x) - x + tan(x)

Mupad [B] (verification not implemented)

Time = 16.94 (sec) , antiderivative size = 35, normalized size of antiderivative = 2.92 \[ \int \log (\cos (x)) \sec ^2(x) \, dx=\mathrm {tan}\left (x\right )-2\,x+\ln \left (\cos \left (x\right )\right )\,\mathrm {tan}\left (x\right )+\ln \left (\cos \left (x\right )\right )\,1{}\mathrm {i}-\ln \left (\cos \left (2\,x\right )+1+\sin \left (2\,x\right )\,1{}\mathrm {i}\right )\,1{}\mathrm {i} \]

[In]

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

[Out]

log(cos(x))*1i - 2*x - log(cos(2*x) + sin(2*x)*1i + 1)*1i + tan(x) + log(cos(x))*tan(x)