\(\int \cos ^2(\frac {x}{2}) \tan (\frac {\pi }{4}+\frac {x}{2}) \, dx\) [915]

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

Optimal result

Integrand size = 21, antiderivative size = 27 \[ \int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx=\frac {x}{2}-\frac {\cos (x)}{2}-\log \left (\cos \left (\frac {\pi }{4}+\frac {x}{2}\right )\right ) \]

[Out]

1/2*x-1/2*cos(x)-ln(cos(1/4*Pi+1/2*x))

Rubi [F]

\[ \int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx=\int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx \]

[In]

Int[Cos[x/2]^2*Tan[Pi/4 + x/2],x]

[Out]

Defer[Int][Cos[x/2]^2*Tan[Pi/4 + x/2], x]

Rubi steps \begin{align*} \text {integral}& = \int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx \\ \end{align*}

Mathematica [A] (verified)

Time = 0.17 (sec) , antiderivative size = 24, normalized size of antiderivative = 0.89 \[ \int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx=\frac {1}{2} \left (x+2 \text {arctanh}\left (\cot \left (\frac {x}{2}\right )\right )-\cos (x)-\log (\cos (x))\right ) \]

[In]

Integrate[Cos[x/2]^2*Tan[Pi/4 + x/2],x]

[Out]

(x + 2*ArcTanh[Cot[x/2]] - Cos[x] - Log[Cos[x]])/2

Maple [A] (verified)

Time = 3.52 (sec) , antiderivative size = 22, normalized size of antiderivative = 0.81

method result size
default \(\frac {x}{2}+\frac {\ln \left (\sec \left (x \right )+\tan \left (x \right )\right )}{2}-\frac {\cos \left (x \right )}{2}-\frac {\ln \left (\cos \left (x \right )\right )}{2}\) \(22\)
risch \(\frac {x}{2}+\frac {i x}{2}-\frac {{\mathrm e}^{i x}}{4}-\frac {{\mathrm e}^{-i x}}{4}-\ln \left ({\mathrm e}^{i x}-i\right )\) \(34\)

[In]

int(cos(1/2*x)^2*tan(1/4*Pi+1/2*x),x,method=_RETURNVERBOSE)

[Out]

1/2*x+1/2*ln(sec(x)+tan(x))-1/2*cos(x)-1/2*ln(cos(x))

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 27, normalized size of antiderivative = 1.00 \[ \int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx=-\cos \left (\frac {1}{2} \, x\right )^{2} + \frac {1}{2} \, x - \frac {1}{2} \, \log \left (-2 \, \cos \left (\frac {1}{2} \, x\right ) \sin \left (\frac {1}{2} \, x\right ) + 1\right ) \]

[In]

integrate(cos(1/2*x)^2*tan(1/4*pi+1/2*x),x, algorithm="fricas")

[Out]

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

Sympy [F]

\[ \int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx=\int \cos ^{2}{\left (\frac {x}{2} \right )} \tan {\left (\frac {x}{2} + \frac {\pi }{4} \right )}\, dx \]

[In]

integrate(cos(1/2*x)**2*tan(1/4*pi+1/2*x),x)

[Out]

Integral(cos(x/2)**2*tan(x/2 + pi/4), x)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 74 vs. \(2 (19) = 38\).

Time = 0.28 (sec) , antiderivative size = 74, normalized size of antiderivative = 2.74 \[ \int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx=\frac {2 \, x \cos \left (x\right )^{2} + 2 \, x \sin \left (x\right )^{2} - \cos \left (2 \, x\right ) \cos \left (x\right ) - 2 \, {\left (\cos \left (x\right )^{2} + \sin \left (x\right )^{2}\right )} \log \left (\cos \left (x\right )^{2} + \sin \left (x\right )^{2} - 2 \, \sin \left (x\right ) + 1\right ) - \sin \left (2 \, x\right ) \sin \left (x\right ) - \cos \left (x\right )}{4 \, {\left (\cos \left (x\right )^{2} + \sin \left (x\right )^{2}\right )}} \]

[In]

integrate(cos(1/2*x)^2*tan(1/4*pi+1/2*x),x, algorithm="maxima")

[Out]

1/4*(2*x*cos(x)^2 + 2*x*sin(x)^2 - cos(2*x)*cos(x) - 2*(cos(x)^2 + sin(x)^2)*log(cos(x)^2 + sin(x)^2 - 2*sin(x
) + 1) - sin(2*x)*sin(x) - cos(x))/(cos(x)^2 + sin(x)^2)

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 93 vs. \(2 (19) = 38\).

Time = 0.28 (sec) , antiderivative size = 93, normalized size of antiderivative = 3.44 \[ \int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx=\frac {x \tan \left (\frac {1}{2} \, x\right )^{2} - \log \left (\frac {2 \, {\left (\tan \left (\frac {1}{2} \, x\right )^{2} - 2 \, \tan \left (\frac {1}{2} \, x\right ) + 1\right )}}{\tan \left (\frac {1}{2} \, x\right )^{2} + 1}\right ) \tan \left (\frac {1}{2} \, x\right )^{2} + \tan \left (\frac {1}{2} \, x\right )^{2} + x - \log \left (\frac {2 \, {\left (\tan \left (\frac {1}{2} \, x\right )^{2} - 2 \, \tan \left (\frac {1}{2} \, x\right ) + 1\right )}}{\tan \left (\frac {1}{2} \, x\right )^{2} + 1}\right ) - 1}{2 \, {\left (\tan \left (\frac {1}{2} \, x\right )^{2} + 1\right )}} \]

[In]

integrate(cos(1/2*x)^2*tan(1/4*pi+1/2*x),x, algorithm="giac")

[Out]

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

Mupad [B] (verification not implemented)

Time = 0.63 (sec) , antiderivative size = 38, normalized size of antiderivative = 1.41 \[ \int \cos ^2\left (\frac {x}{2}\right ) \tan \left (\frac {\pi }{4}+\frac {x}{2}\right ) \, dx=-2\,\ln \left ({\mathrm {e}}^{\frac {\Pi \,1{}\mathrm {i}}{2}}\,{\mathrm {e}}^{x\,1{}\mathrm {i}}+1\right )\,{\sin \left (\frac {\Pi }{4}\right )}^2+x\,{\mathrm {e}}^{\frac {\Pi \,1{}\mathrm {i}}{4}}\,\sin \left (\frac {\Pi }{4}\right )-\frac {\cos \left (x\right )}{2} \]

[In]

int(cos(x/2)^2*tan(Pi/4 + x/2),x)

[Out]

x*sin(Pi/4)*exp((Pi*1i)/4) - 2*sin(Pi/4)^2*log(exp((Pi*1i)/2)*exp(x*1i) + 1) - cos(x)/2