3.287 \(\int (a \cot (x)+b \csc (x)) \, dx\)

Optimal. Leaf size=12 \[ a \log (\sin (x))-b \tanh ^{-1}(\cos (x)) \]

[Out]

-(b*ArcTanh[Cos[x]]) + a*Log[Sin[x]]

________________________________________________________________________________________

Rubi [A]  time = 0.0074097, antiderivative size = 12, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 2, integrand size = 9, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.222, Rules used = {3475, 3770} \[ a \log (\sin (x))-b \tanh ^{-1}(\cos (x)) \]

Antiderivative was successfully verified.

[In]

Int[a*Cot[x] + b*Csc[x],x]

[Out]

-(b*ArcTanh[Cos[x]]) + a*Log[Sin[x]]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3770

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int (a \cot (x)+b \csc (x)) \, dx &=a \int \cot (x) \, dx+b \int \csc (x) \, dx\\ &=-b \tanh ^{-1}(\cos (x))+a \log (\sin (x))\\ \end{align*}

Mathematica [B]  time = 0.0085695, size = 25, normalized size = 2.08 \[ a \log (\sin (x))+b \log \left (\sin \left (\frac{x}{2}\right )\right )-b \log \left (\cos \left (\frac{x}{2}\right )\right ) \]

Antiderivative was successfully verified.

[In]

Integrate[a*Cot[x] + b*Csc[x],x]

[Out]

-(b*Log[Cos[x/2]]) + b*Log[Sin[x/2]] + a*Log[Sin[x]]

________________________________________________________________________________________

Maple [A]  time = 0.003, size = 16, normalized size = 1.3 \begin{align*} a\ln \left ( \sin \left ( x \right ) \right ) -b\ln \left ( \cot \left ( x \right ) +\csc \left ( x \right ) \right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(a*cot(x)+b*csc(x),x)

[Out]

a*ln(sin(x))-b*ln(cot(x)+csc(x))

________________________________________________________________________________________

Maxima [A]  time = 0.988407, size = 20, normalized size = 1.67 \begin{align*} -b \log \left (\cot \left (x\right ) + \csc \left (x\right )\right ) + a \log \left (\sin \left (x\right )\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(a*cot(x)+b*csc(x),x, algorithm="maxima")

[Out]

-b*log(cot(x) + csc(x)) + a*log(sin(x))

________________________________________________________________________________________

Fricas [B]  time = 2.01705, size = 97, normalized size = 8.08 \begin{align*} \frac{1}{2} \,{\left (a - b\right )} \log \left (\frac{1}{2} \, \cos \left (x\right ) + \frac{1}{2}\right ) + \frac{1}{2} \,{\left (a + b\right )} \log \left (-\frac{1}{2} \, \cos \left (x\right ) + \frac{1}{2}\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(a*cot(x)+b*csc(x),x, algorithm="fricas")

[Out]

1/2*(a - b)*log(1/2*cos(x) + 1/2) + 1/2*(a + b)*log(-1/2*cos(x) + 1/2)

________________________________________________________________________________________

Sympy [A]  time = 0.124325, size = 24, normalized size = 2. \begin{align*} a \log{\left (\sin{\left (x \right )} \right )} + b \left (\frac{\log{\left (\cos{\left (x \right )} - 1 \right )}}{2} - \frac{\log{\left (\cos{\left (x \right )} + 1 \right )}}{2}\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(a*cot(x)+b*csc(x),x)

[Out]

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

________________________________________________________________________________________

Giac [A]  time = 1.14671, size = 28, normalized size = 2.33 \begin{align*} \frac{1}{2} \, a \log \left (-\cos \left (x\right )^{2} + 1\right ) + b \log \left ({\left | \tan \left (\frac{1}{2} \, x\right ) \right |}\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(a*cot(x)+b*csc(x),x, algorithm="giac")

[Out]

1/2*a*log(-cos(x)^2 + 1) + b*log(abs(tan(1/2*x)))