3.1.42 \(\int \csc (x) \sqrt {A^2+B^2 \sin ^2(x)} \, dx\) [42]

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

[Out]

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

________________________________________________________________________________________

Rubi [A]
time = 0.05, antiderivative size = 57, normalized size of antiderivative = 1.16, number of steps used = 6, number of rules used = 6, integrand size = 19, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.316, Rules used = {3265, 399, 223, 209, 385, 212} \begin {gather*} -B \tan ^{-1}\left (\frac {B \cos (x)}{\sqrt {A^2-B^2 \cos ^2(x)+B^2}}\right )-A \tanh ^{-1}\left (\frac {A \cos (x)}{\sqrt {A^2-B^2 \cos ^2(x)+B^2}}\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Csc[x]*Sqrt[A^2 + B^2*Sin[x]^2],x]

[Out]

-(B*ArcTan[(B*Cos[x])/Sqrt[A^2 + B^2 - B^2*Cos[x]^2]]) - A*ArcTanh[(A*Cos[x])/Sqrt[A^2 + B^2 - B^2*Cos[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 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 223

Int[1/Sqrt[(a_) + (b_.)*(x_)^2], x_Symbol] :> Subst[Int[1/(1 - b*x^2), x], x, x/Sqrt[a + b*x^2]] /; FreeQ[{a,
b}, x] &&  !GtQ[a, 0]

Rule 385

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

Rule 399

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

Rule 3265

Int[sin[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]^2)^(p_.), x_Symbol] :> With[{ff = Free
Factors[Cos[e + f*x], x]}, Dist[-ff/f, Subst[Int[(1 - ff^2*x^2)^((m - 1)/2)*(a + b - b*ff^2*x^2)^p, x], x, Cos
[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f, p}, x] && IntegerQ[(m - 1)/2]

Rubi steps

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

________________________________________________________________________________________

Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(99\) vs. \(2(49)=98\).
time = 0.07, size = 99, normalized size = 2.02 \begin {gather*} -\sqrt {A^2} \tanh ^{-1}\left (\frac {\sqrt {2} \sqrt {A^2} \cos (x)}{\sqrt {2 A^2+B^2-B^2 \cos (2 x)}}\right )+\sqrt {-B^2} \log \left (\sqrt {2} \sqrt {-B^2} \cos (x)+\sqrt {2 A^2+B^2-B^2 \cos (2 x)}\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Csc[x]*Sqrt[A^2 + B^2*Sin[x]^2],x]

[Out]

-(Sqrt[A^2]*ArcTanh[(Sqrt[2]*Sqrt[A^2]*Cos[x])/Sqrt[2*A^2 + B^2 - B^2*Cos[2*x]]]) + Sqrt[-B^2]*Log[Sqrt[2]*Sqr
t[-B^2]*Cos[x] + Sqrt[2*A^2 + B^2 - B^2*Cos[2*x]]]

________________________________________________________________________________________

Mathics [F(-1)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Timed out} \end {gather*}

Warning: Unable to verify antiderivative.

[In]

mathics('Integrate[Sqrt[A^2 + B^2*Sin[x]^2]/Sin[x],x]')

[Out]

Timed out

________________________________________________________________________________________

Maple [C] Result contains higher order function than in optimal. Order 9 vs. order 3.
time = 0.17, size = 149, normalized size = 3.04

method result size
default \(-\frac {\sqrt {\left (A^{2}+B^{2} \left (\sin ^{2}\left (x \right )\right )\right ) \left (\cos ^{2}\left (x \right )\right )}\, \left (A \,\mathrm {csgn}\left (A \right ) \ln \left (-\frac {A^{2} \left (\sin ^{2}\left (x \right )\right )-B^{2} \left (\sin ^{2}\left (x \right )\right )-2 \,\mathrm {csgn}\left (A \right ) A \sqrt {\left (A^{2}+B^{2} \left (\sin ^{2}\left (x \right )\right )\right ) \left (\cos ^{2}\left (x \right )\right )}-2 A^{2}}{\sin \left (x \right )^{2}}\right )-B \,\mathrm {csgn}\left (B \right ) \arctan \left (\frac {\mathrm {csgn}\left (B \right ) \left (2 B^{2} \left (\sin ^{2}\left (x \right )\right )+A^{2}-B^{2}\right )}{2 B \sqrt {\left (A^{2}+B^{2} \left (\sin ^{2}\left (x \right )\right )\right ) \left (\cos ^{2}\left (x \right )\right )}}\right )\right )}{2 \cos \left (x \right ) \sqrt {A^{2}+B^{2} \left (\sin ^{2}\left (x \right )\right )}}\) \(149\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-1/2*((A^2+B^2*sin(x)^2)*cos(x)^2)^(1/2)*(A*csgn(A)*ln(-(A^2*sin(x)^2-B^2*sin(x)^2-2*csgn(A)*A*((A^2+B^2*sin(x
)^2)*cos(x)^2)^(1/2)-2*A^2)/sin(x)^2)-B*csgn(B)*arctan(1/2*csgn(B)/B*(2*B^2*sin(x)^2+A^2-B^2)/((A^2+B^2*sin(x)
^2)*cos(x)^2)^(1/2)))/cos(x)/(A^2+B^2*sin(x)^2)^(1/2)

________________________________________________________________________________________

Maxima [B] Leaf count of result is larger than twice the leaf count of optimal. 116 vs. \(2 (45) = 90\).
time = 0.37, size = 116, normalized size = 2.37 \begin {gather*} -B \arcsin \left (\frac {B^{2} \cos \left (x\right )}{\sqrt {A^{2} B^{2} + B^{4}}}\right ) - \frac {1}{2} \, A \log \left (B^{2} - \frac {A^{2}}{\cos \left (x\right ) - 1} - \frac {\sqrt {-B^{2} \cos \left (x\right )^{2} + A^{2} + B^{2}} A}{\cos \left (x\right ) - 1}\right ) + \frac {1}{2} \, A \log \left (-B^{2} + \frac {A^{2}}{\cos \left (x\right ) + 1} + \frac {\sqrt {-B^{2} \cos \left (x\right )^{2} + A^{2} + B^{2}} A}{\cos \left (x\right ) + 1}\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-B*arcsin(B^2*cos(x)/sqrt(A^2*B^2 + B^4)) - 1/2*A*log(B^2 - A^2/(cos(x) - 1) - sqrt(-B^2*cos(x)^2 + A^2 + B^2)
*A/(cos(x) - 1)) + 1/2*A*log(-B^2 + A^2/(cos(x) + 1) + sqrt(-B^2*cos(x)^2 + A^2 + B^2)*A/(cos(x) + 1))

________________________________________________________________________________________

Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 244 vs. \(2 (45) = 90\).
time = 0.39, size = 244, normalized size = 4.98 \begin {gather*} \frac {1}{2} \, B \arctan \left (-\frac {{\left (A^{4} + 2 \, A^{2} B^{2} + B^{4}\right )} \cos \left (x\right ) \sin \left (x\right ) - 2 \, {\left (2 \, B^{3} \cos \left (x\right )^{3} - {\left (A^{2} B + B^{3}\right )} \cos \left (x\right )\right )} \sqrt {-B^{2} \cos \left (x\right )^{2} + A^{2} + B^{2}}}{4 \, B^{4} \cos \left (x\right )^{4} + A^{4} + 2 \, A^{2} B^{2} + B^{4} - {\left (A^{4} + 6 \, A^{2} B^{2} + 5 \, B^{4}\right )} \cos \left (x\right )^{2}}\right ) - \frac {1}{2} \, B \arctan \left (\frac {\sin \left (x\right )}{\cos \left (x\right )}\right ) - \frac {1}{2} \, A \log \left (-B^{2} \cos \left (x\right )^{2} + A B \cos \left (x\right ) \sin \left (x\right ) + A^{2} + B^{2} + \sqrt {-B^{2} \cos \left (x\right )^{2} + A^{2} + B^{2}} {\left (A \cos \left (x\right ) + B \sin \left (x\right )\right )}\right ) + \frac {1}{2} \, A \log \left (-B^{2} \cos \left (x\right )^{2} - A B \cos \left (x\right ) \sin \left (x\right ) + A^{2} + B^{2} - \sqrt {-B^{2} \cos \left (x\right )^{2} + A^{2} + B^{2}} {\left (A \cos \left (x\right ) - B \sin \left (x\right )\right )}\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

1/2*B*arctan(-((A^4 + 2*A^2*B^2 + B^4)*cos(x)*sin(x) - 2*(2*B^3*cos(x)^3 - (A^2*B + B^3)*cos(x))*sqrt(-B^2*cos
(x)^2 + A^2 + B^2))/(4*B^4*cos(x)^4 + A^4 + 2*A^2*B^2 + B^4 - (A^4 + 6*A^2*B^2 + 5*B^4)*cos(x)^2)) - 1/2*B*arc
tan(sin(x)/cos(x)) - 1/2*A*log(-B^2*cos(x)^2 + A*B*cos(x)*sin(x) + A^2 + B^2 + sqrt(-B^2*cos(x)^2 + A^2 + B^2)
*(A*cos(x) + B*sin(x))) + 1/2*A*log(-B^2*cos(x)^2 - A*B*cos(x)*sin(x) + A^2 + B^2 - sqrt(-B^2*cos(x)^2 + A^2 +
 B^2)*(A*cos(x) - B*sin(x)))

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\sqrt {A^{2} + B^{2} \sin ^{2}{\left (x \right )}}}{\sin {\left (x \right )}}\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A**2+B**2*sin(x)**2)**(1/2)/sin(x),x)

[Out]

Integral(sqrt(A**2 + B**2*sin(x)**2)/sin(x), x)

________________________________________________________________________________________

Giac [F] N/A
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Could not integrate} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A^2+B^2*sin(x)^2)^(1/2)/sin(x),x)

[Out]

Could not integrate

________________________________________________________________________________________

Mupad [F]
time = 0.00, size = -1, normalized size = -0.02 \begin {gather*} \int \frac {\sqrt {A^2+B^2\,{\sin \left (x\right )}^2}}{\sin \left (x\right )} \,d x \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________