\(\int \frac {1+\cos ^2(x)}{1+\cos (2 x)} \, dx\) [887]

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

Optimal result

Integrand size = 15, antiderivative size = 12 \[ \int \frac {1+\cos ^2(x)}{1+\cos (2 x)} \, dx=\frac {x}{2}+\frac {\tan (x)}{2} \]

[Out]

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

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 12, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.133, Rules used = {396, 209} \[ \int \frac {1+\cos ^2(x)}{1+\cos (2 x)} \, dx=\frac {x}{2}+\frac {\tan (x)}{2} \]

[In]

Int[(1 + Cos[x]^2)/(1 + Cos[2*x]),x]

[Out]

x/2 + Tan[x]/2

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 396

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Simp[d*x*((a + b*x^n)^(p + 1)/(b*(n*(
p + 1) + 1))), x] - Dist[(a*d - b*c*(n*(p + 1) + 1))/(b*(n*(p + 1) + 1)), Int[(a + b*x^n)^p, x], x] /; FreeQ[{
a, b, c, d, n}, x] && NeQ[b*c - a*d, 0] && NeQ[n*(p + 1) + 1, 0]

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

Mathematica [A] (verified)

Time = 0.05 (sec) , antiderivative size = 12, normalized size of antiderivative = 1.00 \[ \int \frac {1+\cos ^2(x)}{1+\cos (2 x)} \, dx=\frac {x}{2}+\frac {\tan (x)}{2} \]

[In]

Integrate[(1 + Cos[x]^2)/(1 + Cos[2*x]),x]

[Out]

x/2 + Tan[x]/2

Maple [A] (verified)

Time = 4.72 (sec) , antiderivative size = 9, normalized size of antiderivative = 0.75

method result size
default \(\frac {x}{2}+\frac {\tan \left (x \right )}{2}\) \(9\)
parts \(\frac {x}{2}+\frac {\tan \left (x \right )}{2}\) \(9\)
risch \(\frac {x}{2}+\frac {i}{{\mathrm e}^{2 i x}+1}\) \(17\)

[In]

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

[Out]

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

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 13, normalized size of antiderivative = 1.08 \[ \int \frac {1+\cos ^2(x)}{1+\cos (2 x)} \, dx=\frac {x \cos \left (x\right ) + \sin \left (x\right )}{2 \, \cos \left (x\right )} \]

[In]

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

[Out]

1/2*(x*cos(x) + sin(x))/cos(x)

Sympy [A] (verification not implemented)

Time = 0.59 (sec) , antiderivative size = 7, normalized size of antiderivative = 0.58 \[ \int \frac {1+\cos ^2(x)}{1+\cos (2 x)} \, dx=\frac {x}{2} + \frac {\tan {\left (x \right )}}{2} \]

[In]

integrate((1+cos(x)**2)/(1+cos(2*x)),x)

[Out]

x/2 + tan(x)/2

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 18 vs. \(2 (8) = 16\).

Time = 0.22 (sec) , antiderivative size = 18, normalized size of antiderivative = 1.50 \[ \int \frac {1+\cos ^2(x)}{1+\cos (2 x)} \, dx=\frac {1}{2} \, x + \frac {\sin \left (2 \, x\right )}{2 \, {\left (\cos \left (2 \, x\right ) + 1\right )}} \]

[In]

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

[Out]

1/2*x + 1/2*sin(2*x)/(cos(2*x) + 1)

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 8, normalized size of antiderivative = 0.67 \[ \int \frac {1+\cos ^2(x)}{1+\cos (2 x)} \, dx=\frac {1}{2} \, x + \frac {1}{2} \, \tan \left (x\right ) \]

[In]

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

[Out]

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

Mupad [B] (verification not implemented)

Time = 26.59 (sec) , antiderivative size = 8, normalized size of antiderivative = 0.67 \[ \int \frac {1+\cos ^2(x)}{1+\cos (2 x)} \, dx=\frac {x}{2}+\frac {\mathrm {tan}\left (x\right )}{2} \]

[In]

int((cos(x)^2 + 1)/(cos(2*x) + 1),x)

[Out]

x/2 + tan(x)/2