\(\int \cos (x) \cot (n x) \, dx\) [115]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [F]
   Fricas [F]
   Sympy [F]
   Maxima [F]
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 7, antiderivative size = 92 \[ \int \cos (x) \cot (n x) \, dx=-\frac {1}{2} e^{-i x}+\frac {e^{i x}}{2}+e^{-i x} \operatorname {Hypergeometric2F1}\left (1,-\frac {1}{2 n},1-\frac {1}{2 n},e^{2 i n x}\right )-e^{i x} \operatorname {Hypergeometric2F1}\left (1,\frac {1}{2 n},\frac {1}{2} \left (2+\frac {1}{n}\right ),e^{2 i n x}\right ) \]

[Out]

-1/2/exp(I*x)+1/2*exp(I*x)+hypergeom([1, -1/2/n],[1-1/2/n],exp(2*I*n*x))/exp(I*x)-exp(I*x)*hypergeom([1, 1/2/n
],[1+1/2/n],exp(2*I*n*x))

Rubi [A] (verified)

Time = 0.10 (sec) , antiderivative size = 92, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.429, Rules used = {4654, 2225, 2283} \[ \int \cos (x) \cot (n x) \, dx=e^{-i x} \operatorname {Hypergeometric2F1}\left (1,-\frac {1}{2 n},1-\frac {1}{2 n},e^{2 i n x}\right )-e^{i x} \operatorname {Hypergeometric2F1}\left (1,\frac {1}{2 n},\frac {1}{2} \left (2+\frac {1}{n}\right ),e^{2 i n x}\right )-\frac {e^{-i x}}{2}+\frac {e^{i x}}{2} \]

[In]

Int[Cos[x]*Cot[n*x],x]

[Out]

-1/2*1/E^(I*x) + E^(I*x)/2 + Hypergeometric2F1[1, -1/2*1/n, 1 - 1/(2*n), E^((2*I)*n*x)]/E^(I*x) - E^(I*x)*Hype
rgeometric2F1[1, 1/(2*n), (2 + n^(-1))/2, E^((2*I)*n*x)]

Rule 2225

Int[((F_)^((c_.)*((a_.) + (b_.)*(x_))))^(n_.), x_Symbol] :> Simp[(F^(c*(a + b*x)))^n/(b*c*n*Log[F]), x] /; Fre
eQ[{F, a, b, c, n}, x]

Rule 2283

Int[((a_) + (b_.)*(F_)^((e_.)*((c_.) + (d_.)*(x_))))^(p_)*(G_)^((h_.)*((f_.) + (g_.)*(x_))), x_Symbol] :> Simp
[a^p*(G^(h*(f + g*x))/(g*h*Log[G]))*Hypergeometric2F1[-p, g*h*(Log[G]/(d*e*Log[F])), g*h*(Log[G]/(d*e*Log[F]))
 + 1, Simplify[(-b/a)*F^(e*(c + d*x))]], x] /; FreeQ[{F, G, a, b, c, d, e, f, g, h, p}, x] && (ILtQ[p, 0] || G
tQ[a, 0])

Rule 4654

Int[Cos[(a_.) + (b_.)*(x_)]*Cot[(c_.) + (d_.)*(x_)], x_Symbol] :> Int[I*(1/(E^(I*(a + b*x))*2)) + I*(E^(I*(a +
 b*x))/2) - I*(1/(E^(I*(a + b*x))*(1 - E^(2*I*(c + d*x))))) - I*(E^(I*(a + b*x))/(1 - E^(2*I*(c + d*x)))), x]
/; FreeQ[{a, b, c, d}, x] && NeQ[b^2 - d^2, 0]

Rubi steps \begin{align*} \text {integral}& = \int \left (\frac {1}{2} i e^{-i x}+\frac {1}{2} i e^{i x}-\frac {i e^{-i x}}{1-e^{2 i n x}}-\frac {i e^{i x}}{1-e^{2 i n x}}\right ) \, dx \\ & = \frac {1}{2} i \int e^{-i x} \, dx+\frac {1}{2} i \int e^{i x} \, dx-i \int \frac {e^{-i x}}{1-e^{2 i n x}} \, dx-i \int \frac {e^{i x}}{1-e^{2 i n x}} \, dx \\ & = -\frac {1}{2} e^{-i x}+\frac {e^{i x}}{2}+e^{-i x} \operatorname {Hypergeometric2F1}\left (1,-\frac {1}{2 n},1-\frac {1}{2 n},e^{2 i n x}\right )-e^{i x} \operatorname {Hypergeometric2F1}\left (1,\frac {1}{2 n},\frac {1}{2} \left (2+\frac {1}{n}\right ),e^{2 i n x}\right ) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.21 (sec) , antiderivative size = 179, normalized size of antiderivative = 1.95 \[ \int \cos (x) \cot (n x) \, dx=\frac {1}{2} e^{-2 i x} \left (-\frac {e^{i (x+2 n x)} \operatorname {Hypergeometric2F1}\left (1,1-\frac {1}{2 n},2-\frac {1}{2 n},e^{2 i n x}\right )}{-1+2 n}-\frac {e^{i (3+2 n) x} \operatorname {Hypergeometric2F1}\left (1,1+\frac {1}{2 n},2+\frac {1}{2 n},e^{2 i n x}\right )}{1+2 n}+e^{i x} \operatorname {Hypergeometric2F1}\left (1,-\frac {1}{2 n},1-\frac {1}{2 n},e^{2 i n x}\right )-e^{3 i x} \operatorname {Hypergeometric2F1}\left (1,\frac {1}{2 n},1+\frac {1}{2 n},e^{2 i n x}\right )\right ) \]

[In]

Integrate[Cos[x]*Cot[n*x],x]

[Out]

(-((E^(I*(x + 2*n*x))*Hypergeometric2F1[1, 1 - 1/(2*n), 2 - 1/(2*n), E^((2*I)*n*x)])/(-1 + 2*n)) - (E^(I*(3 +
2*n)*x)*Hypergeometric2F1[1, 1 + 1/(2*n), 2 + 1/(2*n), E^((2*I)*n*x)])/(1 + 2*n) + E^(I*x)*Hypergeometric2F1[1
, -1/2*1/n, 1 - 1/(2*n), E^((2*I)*n*x)] - E^((3*I)*x)*Hypergeometric2F1[1, 1/(2*n), 1 + 1/(2*n), E^((2*I)*n*x)
])/(2*E^((2*I)*x))

Maple [F]

\[\int \cos \left (x \right ) \cot \left (n x \right )d x\]

[In]

int(cos(x)*cot(n*x),x)

[Out]

int(cos(x)*cot(n*x),x)

Fricas [F]

\[ \int \cos (x) \cot (n x) \, dx=\int { \cos \left (x\right ) \cot \left (n x\right ) \,d x } \]

[In]

integrate(cos(x)*cot(n*x),x, algorithm="fricas")

[Out]

integral(cos(x)*cot(n*x), x)

Sympy [F]

\[ \int \cos (x) \cot (n x) \, dx=\int \cos {\left (x \right )} \cot {\left (n x \right )}\, dx \]

[In]

integrate(cos(x)*cot(n*x),x)

[Out]

Integral(cos(x)*cot(n*x), x)

Maxima [F]

\[ \int \cos (x) \cot (n x) \, dx=\int { \cos \left (x\right ) \cot \left (n x\right ) \,d x } \]

[In]

integrate(cos(x)*cot(n*x),x, algorithm="maxima")

[Out]

integrate(cos(x)*cot(n*x), x)

Giac [F]

\[ \int \cos (x) \cot (n x) \, dx=\int { \cos \left (x\right ) \cot \left (n x\right ) \,d x } \]

[In]

integrate(cos(x)*cot(n*x),x, algorithm="giac")

[Out]

integrate(cos(x)*cot(n*x), x)

Mupad [F(-1)]

Timed out. \[ \int \cos (x) \cot (n x) \, dx=\int \mathrm {cot}\left (n\,x\right )\,\cos \left (x\right ) \,d x \]

[In]

int(cot(n*x)*cos(x),x)

[Out]

int(cot(n*x)*cos(x), x)