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

Optimal. Leaf size=34 \[ \sqrt {2} x-\sqrt {2} \tan ^{-1}\left (\frac {\cos (x) \sin (x)}{1+\sqrt {2}+\cos ^2(x)}\right ) \]

[Out]

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

________________________________________________________________________________________

Rubi [A]
time = 0.01, antiderivative size = 34, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, integrand size = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.300, Rules used = {12, 3260, 209} \begin {gather*} \sqrt {2} x-\sqrt {2} \tan ^{-1}\left (\frac {\sin (x) \cos (x)}{\cos ^2(x)+\sqrt {2}+1}\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

Sqrt[2]*x - Sqrt[2]*ArcTan[(Cos[x]*Sin[x])/(1 + Sqrt[2] + Cos[x]^2)]

Rule 12

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

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 3260

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]^2)^(-1), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist
[ff/f, Subst[Int[1/(a + (a + b)*ff^2*x^2), x], x, Tan[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f}, x]

Rubi steps

\begin {align*} \int \frac {2}{1+\cos ^2(x)} \, dx &=2 \int \frac {1}{1+\cos ^2(x)} \, dx\\ &=-\left (2 \text {Subst}\left (\int \frac {1}{1+2 x^2} \, dx,x,\cot (x)\right )\right )\\ &=\sqrt {2} x-\sqrt {2} \tan ^{-1}\left (\frac {\cos (x) \sin (x)}{1+\sqrt {2}+\cos ^2(x)}\right )\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.01, size = 15, normalized size = 0.44 \begin {gather*} \sqrt {2} \tan ^{-1}\left (\frac {\tan (x)}{\sqrt {2}}\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

Sqrt[2]*ArcTan[Tan[x]/Sqrt[2]]

________________________________________________________________________________________

Mathics [C] Result contains higher order function than in optimal. Order 9 vs. order 3 in optimal.
time = 2.82, size = 39, normalized size = 1.15 \begin {gather*} \sqrt {2} \left (2 \text {Pi} \text {Floor}\left [-\frac {1}{2}+\frac {x}{2 \text {Pi}}\right ]+\text {ArcTan}\left [-1+\sqrt {2} \text {Tan}\left [\frac {x}{2}\right ]\right ]+\text {ArcTan}\left [1+\sqrt {2} \text {Tan}\left [\frac {x}{2}\right ]\right ]\right ) \end {gather*}

Warning: Unable to verify antiderivative.

[In]

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

[Out]

Sqrt[2] (2 Pi Floor[-1 / 2 + x / (2 Pi)] + ArcTan[-1 + Sqrt[2] Tan[x / 2]] + ArcTan[1 + Sqrt[2] Tan[x / 2]])

________________________________________________________________________________________

Maple [A]
time = 0.04, size = 13, normalized size = 0.38

method result size
default \(\sqrt {2}\, \arctan \left (\frac {\tan \left (x \right ) \sqrt {2}}{2}\right )\) \(13\)
risch \(\frac {i \sqrt {2}\, \ln \left ({\mathrm e}^{2 i x}+2 \sqrt {2}+3\right )}{2}-\frac {i \sqrt {2}\, \ln \left ({\mathrm e}^{2 i x}-2 \sqrt {2}+3\right )}{2}\) \(40\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

2^(1/2)*arctan(1/2*tan(x)*2^(1/2))

________________________________________________________________________________________

Maxima [A]
time = 0.35, size = 12, normalized size = 0.35 \begin {gather*} \sqrt {2} \arctan \left (\frac {1}{2} \, \sqrt {2} \tan \left (x\right )\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

sqrt(2)*arctan(1/2*sqrt(2)*tan(x))

________________________________________________________________________________________

Fricas [A]
time = 0.31, size = 31, normalized size = 0.91 \begin {gather*} -\frac {1}{2} \, \sqrt {2} \arctan \left (\frac {3 \, \sqrt {2} \cos \left (x\right )^{2} - \sqrt {2}}{4 \, \cos \left (x\right ) \sin \left (x\right )}\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-1/2*sqrt(2)*arctan(1/4*(3*sqrt(2)*cos(x)^2 - sqrt(2))/(cos(x)*sin(x)))

________________________________________________________________________________________

Sympy [A]
time = 0.26, size = 60, normalized size = 1.76 \begin {gather*} \sqrt {2} \left (\operatorname {atan}{\left (\sqrt {2} \tan {\left (\frac {x}{2} \right )} - 1 \right )} + \pi \left \lfloor {\frac {\frac {x}{2} - \frac {\pi }{2}}{\pi }}\right \rfloor \right ) + \sqrt {2} \left (\operatorname {atan}{\left (\sqrt {2} \tan {\left (\frac {x}{2} \right )} + 1 \right )} + \pi \left \lfloor {\frac {\frac {x}{2} - \frac {\pi }{2}}{\pi }}\right \rfloor \right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

sqrt(2)*(atan(sqrt(2)*tan(x/2) - 1) + pi*floor((x/2 - pi/2)/pi)) + sqrt(2)*(atan(sqrt(2)*tan(x/2) + 1) + pi*fl
oor((x/2 - pi/2)/pi))

________________________________________________________________________________________

Giac [A]
time = 0.00, size = 54, normalized size = 1.59 \begin {gather*} \frac {2\cdot 2 \left (\arctan \left (\frac {-\sqrt {2} \sin \left (2 x\right )+\sin \left (2 x\right )}{\sqrt {2} \cos \left (2 x\right )+\sqrt {2}-\cos \left (2 x\right )+1}\right )+x\right )}{2 \sqrt {2}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

sqrt(2)*(x + arctan(-(sqrt(2)*sin(2*x) - sin(2*x))/(sqrt(2)*cos(2*x) + sqrt(2) - cos(2*x) + 1)))

________________________________________________________________________________________

Mupad [B]
time = 0.21, size = 24, normalized size = 0.71 \begin {gather*} \sqrt {2}\,\left (x-\mathrm {atan}\left (\mathrm {tan}\left (x\right )\right )\right )+\sqrt {2}\,\mathrm {atan}\left (\frac {\sqrt {2}\,\mathrm {tan}\left (x\right )}{2}\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________