\(\int (a \cot (x)+b \csc (x)) \, dx\) [287]

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

Optimal result

Integrand size = 9, antiderivative size = 12 \[ \int (a \cot (x)+b \csc (x)) \, dx=-b \text {arctanh}(\cos (x))+a \log (\sin (x)) \]

[Out]

-b*arctanh(cos(x))+a*ln(sin(x))

Rubi [A] (verified)

Time = 0.01 (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.222, Rules used = {3556, 3855} \[ \int (a \cot (x)+b \csc (x)) \, dx=a \log (\sin (x))-b \text {arctanh}(\cos (x)) \]

[In]

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

[Out]

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

Rule 3556

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

Rule 3855

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

Rubi steps \begin{align*} \text {integral}& = a \int \cot (x) \, dx+b \int \csc (x) \, dx \\ & = -b \text {arctanh}(\cos (x))+a \log (\sin (x)) \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(30\) vs. \(2(12)=24\).

Time = 0.00 (sec) , antiderivative size = 30, normalized size of antiderivative = 2.50 \[ \int (a \cot (x)+b \csc (x)) \, dx=-b \log \left (\cos \left (\frac {x}{2}\right )\right )+a \log (\cos (x))+b \log \left (\sin \left (\frac {x}{2}\right )\right )+a \log (\tan (x)) \]

[In]

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

[Out]

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

Maple [A] (verified)

Time = 0.30 (sec) , antiderivative size = 16, normalized size of antiderivative = 1.33

method result size
default \(a \ln \left (\sin \left (x \right )\right )-b \ln \left (\cot \left (x \right )+\csc \left (x \right )\right )\) \(16\)
parts \(a \ln \left (\sin \left (x \right )\right )-b \ln \left (\cot \left (x \right )+\csc \left (x \right )\right )\) \(16\)
norman \(a \ln \left (\tan \left (x \right )\right )+b \ln \left (\tan \left (\frac {x}{2}\right )\right )-\frac {a \ln \left (1+\tan \left (x \right )^{2}\right )}{2}\) \(24\)
parallelrisch \(a \left (\ln \left (\tan \left (x \right )\right )+\ln \left (\frac {1}{\sqrt {\sec \left (x \right )^{2}}}\right )\right )+b \ln \left (\csc \left (x \right )-\cot \left (x \right )\right )\) \(25\)
risch \(-i a x +a \ln \left ({\mathrm e}^{2 i x}-1\right )+b \ln \left ({\mathrm e}^{i x}-1\right )-b \ln \left ({\mathrm e}^{i x}+1\right )\) \(38\)

[In]

int(a*cot(x)+b*csc(x),x,method=_RETURNVERBOSE)

[Out]

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 27 vs. \(2 (12) = 24\).

Time = 0.25 (sec) , antiderivative size = 27, normalized size of antiderivative = 2.25 \[ \int (a \cot (x)+b \csc (x)) \, dx=\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 ) \]

[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] (verification not implemented)

Time = 0.05 (sec) , antiderivative size = 24, normalized size of antiderivative = 2.00 \[ \int (a \cot (x)+b \csc (x)) \, dx=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 ) \]

[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)

Maxima [A] (verification not implemented)

none

Time = 0.22 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.25 \[ \int (a \cot (x)+b \csc (x)) \, dx=-b \log \left (\cot \left (x\right ) + \csc \left (x\right )\right ) + a \log \left (\sin \left (x\right )\right ) \]

[In]

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

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.25 \[ \int (a \cot (x)+b \csc (x)) \, dx=a \log \left ({\left | \sin \left (x\right ) \right |}\right ) + b \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) \right |}\right ) \]

[In]

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

[Out]

a*log(abs(sin(x))) + b*log(abs(tan(1/2*x)))

Mupad [B] (verification not implemented)

Time = 30.15 (sec) , antiderivative size = 27, normalized size of antiderivative = 2.25 \[ \int (a \cot (x)+b \csc (x)) \, dx=a\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )\right )-a\,\ln \left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2+1\right )+b\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )\right ) \]

[In]

int(b/sin(x) + a*cot(x),x)

[Out]

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