\(\int \frac {\cos (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}} \, dx\) [673]

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

Optimal result

Integrand size = 16, antiderivative size = 19 \[ \int \frac {\cos (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}} \, dx=2 \text {arctanh}\left (\frac {\sin (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}}\right ) \]

[Out]

2*arctanh(sin(x)/(2*sin(x)+sin(x)^2)^(1/2))

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 19, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.188, Rules used = {3339, 634, 212} \[ \int \frac {\cos (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}} \, dx=2 \text {arctanh}\left (\frac {\sin (x)}{\sqrt {\sin ^2(x)+2 \sin (x)}}\right ) \]

[In]

Int[Cos[x]/Sqrt[2*Sin[x] + Sin[x]^2],x]

[Out]

2*ArcTanh[Sin[x]/Sqrt[2*Sin[x] + Sin[x]^2]]

Rule 212

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

Rule 634

Int[1/Sqrt[(b_.)*(x_) + (c_.)*(x_)^2], x_Symbol] :> Dist[2, Subst[Int[1/(1 - c*x^2), x], x, x/Sqrt[b*x + c*x^2
]], x] /; FreeQ[{b, c}, x]

Rule 3339

Int[cos[(d_.) + (e_.)*(x_)]^(m_.)*((a_.) + (b_.)*((f_.)*sin[(d_.) + (e_.)*(x_)])^(n_.) + (c_.)*((f_.)*sin[(d_.
) + (e_.)*(x_)])^(n2_.))^(p_.), x_Symbol] :> Module[{g = FreeFactors[Sin[d + e*x], x]}, Dist[g/e, Subst[Int[(1
 - g^2*x^2)^((m - 1)/2)*(a + b*(f*g*x)^n + c*(f*g*x)^(2*n))^p, x], x, Sin[d + e*x]/g], x]] /; FreeQ[{a, b, c,
d, e, f, n, p}, x] && EqQ[n2, 2*n] && IntegerQ[(m - 1)/2]

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

Mathematica [B] (verified)

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

Time = 0.02 (sec) , antiderivative size = 40, normalized size of antiderivative = 2.11 \[ \int \frac {\cos (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}} \, dx=\frac {2 \text {arcsinh}\left (\frac {\sqrt {\sin (x)}}{\sqrt {2}}\right ) \sqrt {\sin (x)} \sqrt {2+\sin (x)}}{\sqrt {\sin (x) (2+\sin (x))}} \]

[In]

Integrate[Cos[x]/Sqrt[2*Sin[x] + Sin[x]^2],x]

[Out]

(2*ArcSinh[Sqrt[Sin[x]]/Sqrt[2]]*Sqrt[Sin[x]]*Sqrt[2 + Sin[x]])/Sqrt[Sin[x]*(2 + Sin[x])]

Maple [A] (verified)

Time = 1.22 (sec) , antiderivative size = 17, normalized size of antiderivative = 0.89

method result size
derivativedivides \(\ln \left (1+\sin \left (x \right )+\sqrt {2 \sin \left (x \right )+\sin \left (x \right )^{2}}\right )\) \(17\)
default \(\ln \left (1+\sin \left (x \right )+\sqrt {2 \sin \left (x \right )+\sin \left (x \right )^{2}}\right )\) \(17\)

[In]

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

[Out]

ln(1+sin(x)+(2*sin(x)+sin(x)^2)^(1/2))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 35 vs. \(2 (17) = 34\).

Time = 0.35 (sec) , antiderivative size = 35, normalized size of antiderivative = 1.84 \[ \int \frac {\cos (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}} \, dx=\frac {1}{2} \, \log \left (-2 \, \cos \left (x\right )^{2} + 2 \, \sqrt {-\cos \left (x\right )^{2} + 2 \, \sin \left (x\right ) + 1} {\left (\sin \left (x\right ) + 1\right )} + 4 \, \sin \left (x\right ) + 3\right ) \]

[In]

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

[Out]

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

Sympy [F]

\[ \int \frac {\cos (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}} \, dx=\int \frac {\cos {\left (x \right )}}{\sqrt {\left (\sin {\left (x \right )} + 2\right ) \sin {\left (x \right )}}}\, dx \]

[In]

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

[Out]

Integral(cos(x)/sqrt((sin(x) + 2)*sin(x)), x)

Maxima [A] (verification not implemented)

none

Time = 0.20 (sec) , antiderivative size = 20, normalized size of antiderivative = 1.05 \[ \int \frac {\cos (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}} \, dx=\log \left (2 \, \sqrt {\sin \left (x\right )^{2} + 2 \, \sin \left (x\right )} + 2 \, \sin \left (x\right ) + 2\right ) \]

[In]

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

[Out]

log(2*sqrt(sin(x)^2 + 2*sin(x)) + 2*sin(x) + 2)

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 20, normalized size of antiderivative = 1.05 \[ \int \frac {\cos (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}} \, dx=-\log \left (-\sqrt {\sin \left (x\right )^{2} + 2 \, \sin \left (x\right )} + \sin \left (x\right ) + 1\right ) \]

[In]

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

[Out]

-log(-sqrt(sin(x)^2 + 2*sin(x)) + sin(x) + 1)

Mupad [B] (verification not implemented)

Time = 26.44 (sec) , antiderivative size = 14, normalized size of antiderivative = 0.74 \[ \int \frac {\cos (x)}{\sqrt {2 \sin (x)+\sin ^2(x)}} \, dx=\ln \left (\sin \left (x\right )+\sqrt {\sin \left (x\right )\,\left (\sin \left (x\right )+2\right )}+1\right ) \]

[In]

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

[Out]

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