\(\int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx\) [792]

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

Optimal result

Integrand size = 26, antiderivative size = 202 \[ \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=-\frac {i n (d \cot (e+f x))^{3+n}}{4 a^2 d^3 f (i+\cot (e+f x))}-\frac {(d \cot (e+f x))^{3+n}}{4 d^3 f (i a+a \cot (e+f x))^2}+\frac {(1+n)^2 (d \cot (e+f x))^{3+n} \operatorname {Hypergeometric2F1}\left (1,\frac {3+n}{2},\frac {5+n}{2},-\cot ^2(e+f x)\right )}{4 a^2 d^3 f (3+n)}+\frac {i n (2+n) (d \cot (e+f x))^{4+n} \operatorname {Hypergeometric2F1}\left (1,\frac {4+n}{2},\frac {6+n}{2},-\cot ^2(e+f x)\right )}{4 a^2 d^4 f (4+n)} \] Output:

-1/4*I*n*(d*cot(f*x+e))^(3+n)/a^2/d^3/f/(I+cot(f*x+e))-1/4*(d*cot(f*x+e))^ 
(3+n)/d^3/f/(I*a+a*cot(f*x+e))^2+1/4*(1+n)^2*(d*cot(f*x+e))^(3+n)*hypergeo 
m([1, 3/2+1/2*n],[5/2+1/2*n],-cot(f*x+e)^2)/a^2/d^3/f/(3+n)+1/4*I*n*(2+n)* 
(d*cot(f*x+e))^(4+n)*hypergeom([1, 2+1/2*n],[3+1/2*n],-cot(f*x+e)^2)/a^2/d 
^4/f/(4+n)
 

Mathematica [A] (verified)

Time = 2.45 (sec) , antiderivative size = 221, normalized size of antiderivative = 1.09 \[ \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=\frac {-2 a^3 d (3+n) (4+n) (d \cot (e+f x))^{3+n}+a (i+\cot (e+f x)) \left (-2 i a^2 d^4 n (3+n) (4+n) \cot ^3(e+f x) (d \cot (e+f x))^n+2 a^2 (i+\cot (e+f x)) \left (d (1+n)^2 (4+n) (d \cot (e+f x))^{3+n} \operatorname {Hypergeometric2F1}\left (1,\frac {3+n}{2},\frac {5+n}{2},-\cot ^2(e+f x)\right )+i n (2+n) (3+n) (d \cot (e+f x))^{4+n} \operatorname {Hypergeometric2F1}\left (1,\frac {4+n}{2},\frac {6+n}{2},-\cot ^2(e+f x)\right )\right )\right )}{8 a^5 d^4 f (3+n) (4+n) (i+\cot (e+f x))^2} \] Input:

Integrate[(d*Cot[e + f*x])^n/(a + I*a*Tan[e + f*x])^2,x]
 

Output:

(-2*a^3*d*(3 + n)*(4 + n)*(d*Cot[e + f*x])^(3 + n) + a*(I + Cot[e + f*x])* 
((-2*I)*a^2*d^4*n*(3 + n)*(4 + n)*Cot[e + f*x]^3*(d*Cot[e + f*x])^n + 2*a^ 
2*(I + Cot[e + f*x])*(d*(1 + n)^2*(4 + n)*(d*Cot[e + f*x])^(3 + n)*Hyperge 
ometric2F1[1, (3 + n)/2, (5 + n)/2, -Cot[e + f*x]^2] + I*n*(2 + n)*(3 + n) 
*(d*Cot[e + f*x])^(4 + n)*Hypergeometric2F1[1, (4 + n)/2, (6 + n)/2, -Cot[ 
e + f*x]^2])))/(8*a^5*d^4*f*(3 + n)*(4 + n)*(I + Cot[e + f*x])^2)
 

Rubi [A] (verified)

Time = 1.04 (sec) , antiderivative size = 208, normalized size of antiderivative = 1.03, number of steps used = 14, number of rules used = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.500, Rules used = {3042, 4156, 3042, 4042, 25, 3042, 4079, 27, 3042, 4021, 3042, 3957, 278}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2}dx\)

\(\Big \downarrow \) 4156

\(\displaystyle \frac {\int \frac {(d \cot (e+f x))^{n+2}}{(\cot (e+f x) a+i a)^2}dx}{d^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \frac {\left (-d \tan \left (e+f x+\frac {\pi }{2}\right )\right )^{n+2}}{\left (i a-a \tan \left (e+f x+\frac {\pi }{2}\right )\right )^2}dx}{d^2}\)

\(\Big \downarrow \) 4042

\(\displaystyle \frac {\frac {\int -\frac {(d \cot (e+f x))^{n+2} (i a d (1-n)+a d (n+1) \cot (e+f x))}{\cot (e+f x) a+i a}dx}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {-\frac {\int \frac {(d \cot (e+f x))^{n+2} (i a d (1-n)+a d (n+1) \cot (e+f x))}{\cot (e+f x) a+i a}dx}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {-\frac {\int \frac {\left (-d \tan \left (e+f x+\frac {\pi }{2}\right )\right )^{n+2} \left (i a d (1-n)-a d (n+1) \tan \left (e+f x+\frac {\pi }{2}\right )\right )}{i a-a \tan \left (e+f x+\frac {\pi }{2}\right )}dx}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

\(\Big \downarrow \) 4079

\(\displaystyle \frac {-\frac {\frac {\int 2 (d \cot (e+f x))^{n+2} \left (a^2 (n+1)^2 d^2+i a^2 n (n+2) \cot (e+f x) d^2\right )dx}{2 a^2 d}+\frac {i n (d \cot (e+f x))^{n+3}}{f (\cot (e+f x)+i)}}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {-\frac {\frac {\int (d \cot (e+f x))^{n+2} \left (a^2 (n+1)^2 d^2+i a^2 n (n+2) \cot (e+f x) d^2\right )dx}{a^2 d}+\frac {i n (d \cot (e+f x))^{n+3}}{f (\cot (e+f x)+i)}}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {-\frac {\frac {\int \left (-d \tan \left (e+f x+\frac {\pi }{2}\right )\right )^{n+2} \left (a^2 d^2 (n+1)^2-i a^2 d^2 n (n+2) \tan \left (e+f x+\frac {\pi }{2}\right )\right )dx}{a^2 d}+\frac {i n (d \cot (e+f x))^{n+3}}{f (\cot (e+f x)+i)}}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

\(\Big \downarrow \) 4021

\(\displaystyle \frac {-\frac {\frac {a^2 d^2 (n+1)^2 \int (d \cot (e+f x))^{n+2}dx+i a^2 d n (n+2) \int (d \cot (e+f x))^{n+3}dx}{a^2 d}+\frac {i n (d \cot (e+f x))^{n+3}}{f (\cot (e+f x)+i)}}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {-\frac {\frac {a^2 d^2 (n+1)^2 \int \left (-d \tan \left (e+f x+\frac {\pi }{2}\right )\right )^{n+2}dx+i a^2 d n (n+2) \int \left (-d \tan \left (e+f x+\frac {\pi }{2}\right )\right )^{n+3}dx}{a^2 d}+\frac {i n (d \cot (e+f x))^{n+3}}{f (\cot (e+f x)+i)}}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

\(\Big \downarrow \) 3957

\(\displaystyle \frac {-\frac {\frac {-\frac {a^2 d^3 (n+1)^2 \int \frac {(d \cot (e+f x))^{n+2}}{\cot ^2(e+f x) d^2+d^2}d(d \cot (e+f x))}{f}-\frac {i a^2 d^2 n (n+2) \int \frac {(d \cot (e+f x))^{n+3}}{\cot ^2(e+f x) d^2+d^2}d(d \cot (e+f x))}{f}}{a^2 d}+\frac {i n (d \cot (e+f x))^{n+3}}{f (\cot (e+f x)+i)}}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

\(\Big \downarrow \) 278

\(\displaystyle \frac {-\frac {\frac {-\frac {a^2 d (n+1)^2 (d \cot (e+f x))^{n+3} \operatorname {Hypergeometric2F1}\left (1,\frac {n+3}{2},\frac {n+5}{2},-\cot ^2(e+f x)\right )}{f (n+3)}-\frac {i a^2 n (n+2) (d \cot (e+f x))^{n+4} \operatorname {Hypergeometric2F1}\left (1,\frac {n+4}{2},\frac {n+6}{2},-\cot ^2(e+f x)\right )}{f (n+4)}}{a^2 d}+\frac {i n (d \cot (e+f x))^{n+3}}{f (\cot (e+f x)+i)}}{4 a^2 d}-\frac {(d \cot (e+f x))^{n+3}}{4 d f (a \cot (e+f x)+i a)^2}}{d^2}\)

Input:

Int[(d*Cot[e + f*x])^n/(a + I*a*Tan[e + f*x])^2,x]
 

Output:

(-1/4*(d*Cot[e + f*x])^(3 + n)/(d*f*(I*a + a*Cot[e + f*x])^2) - ((I*n*(d*C 
ot[e + f*x])^(3 + n))/(f*(I + Cot[e + f*x])) + (-((a^2*d*(1 + n)^2*(d*Cot[ 
e + f*x])^(3 + n)*Hypergeometric2F1[1, (3 + n)/2, (5 + n)/2, -Cot[e + f*x] 
^2])/(f*(3 + n))) - (I*a^2*n*(2 + n)*(d*Cot[e + f*x])^(4 + n)*Hypergeometr 
ic2F1[1, (4 + n)/2, (6 + n)/2, -Cot[e + f*x]^2])/(f*(4 + n)))/(a^2*d))/(4* 
a^2*d))/d^2
 

Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

rule 278
Int[((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^2)^(p_), x_Symbol] :> Simp[a^p*(( 
c*x)^(m + 1)/(c*(m + 1)))*Hypergeometric2F1[-p, (m + 1)/2, (m + 1)/2 + 1, ( 
-b)*(x^2/a)], x] /; FreeQ[{a, b, c, m, p}, x] &&  !IGtQ[p, 0] && (ILtQ[p, 0 
] || GtQ[a, 0])
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3957
Int[((b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b/d   Subst[Int 
[x^n/(b^2 + x^2), x], x, b*Tan[c + d*x]], x] /; FreeQ[{b, c, d, n}, x] && 
!IntegerQ[n]
 

rule 4021
Int[((b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_) + (d_.)*tan[(e_.) + (f_.)*(x 
_)]), x_Symbol] :> Simp[c   Int[(b*Tan[e + f*x])^m, x], x] + Simp[d/b   Int 
[(b*Tan[e + f*x])^(m + 1), x], x] /; FreeQ[{b, c, d, e, f, m}, x] && NeQ[c^ 
2 + d^2, 0] &&  !IntegerQ[2*m]
 

rule 4042
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
(f_.)*(x_)])^(n_), x_Symbol] :> Simp[a*(a + b*Tan[e + f*x])^m*((c + d*Tan[e 
 + f*x])^(n + 1)/(2*f*m*(b*c - a*d))), x] + Simp[1/(2*a*m*(b*c - a*d))   In 
t[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^n*Simp[b*c*m - a*d*(2*m 
 + n + 1) + b*d*(m + n + 1)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, 
e, f, n}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0] 
 && LtQ[m, 0] && (IntegerQ[m] || IntegersQ[2*m, 2*n])
 

rule 4079
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + 
(f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Sim 
p[(a*A + b*B)*(a + b*Tan[e + f*x])^m*((c + d*Tan[e + f*x])^(n + 1)/(2*f*m*( 
b*c - a*d))), x] + Simp[1/(2*a*m*(b*c - a*d))   Int[(a + b*Tan[e + f*x])^(m 
 + 1)*(c + d*Tan[e + f*x])^n*Simp[A*(b*c*m - a*d*(2*m + n + 1)) + B*(a*c*m 
- b*d*(n + 1)) + d*(A*b - a*B)*(m + n + 1)*Tan[e + f*x], x], x], x] /; Free 
Q[{a, b, c, d, e, f, A, B, n}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] 
 && LtQ[m, 0] &&  !GtQ[n, 0]
 

rule 4156
Int[(cot[(e_.) + (f_.)*(x_)]*(d_.))^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x 
_)]^(n_.))^(p_.), x_Symbol] :> Simp[d^(n*p)   Int[(d*Cot[e + f*x])^(m - n*p 
)*(b + a*Cot[e + f*x]^n)^p, x], x] /; FreeQ[{a, b, d, e, f, m, n, p}, x] && 
  !IntegerQ[m] && IntegersQ[n, p]
 
Maple [F]

\[\int \frac {\left (d \cot \left (f x +e \right )\right )^{n}}{\left (a +i a \tan \left (f x +e \right )\right )^{2}}d x\]

Input:

int((d*cot(f*x+e))^n/(a+I*a*tan(f*x+e))^2,x)
 

Output:

int((d*cot(f*x+e))^n/(a+I*a*tan(f*x+e))^2,x)
 

Fricas [F]

\[ \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=\int { \frac {\left (d \cot \left (f x + e\right )\right )^{n}}{{\left (i \, a \tan \left (f x + e\right ) + a\right )}^{2}} \,d x } \] Input:

integrate((d*cot(f*x+e))^n/(a+I*a*tan(f*x+e))^2,x, algorithm="fricas")
 

Output:

integral(1/4*((I*d*e^(2*I*f*x + 2*I*e) + I*d)/(e^(2*I*f*x + 2*I*e) - 1))^n 
*(e^(4*I*f*x + 4*I*e) + 2*e^(2*I*f*x + 2*I*e) + 1)*e^(-4*I*f*x - 4*I*e)/a^ 
2, x)
 

Sympy [F]

\[ \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=- \frac {\int \frac {\left (d \cot {\left (e + f x \right )}\right )^{n}}{\tan ^{2}{\left (e + f x \right )} - 2 i \tan {\left (e + f x \right )} - 1}\, dx}{a^{2}} \] Input:

integrate((d*cot(f*x+e))**n/(a+I*a*tan(f*x+e))**2,x)
 

Output:

-Integral((d*cot(e + f*x))**n/(tan(e + f*x)**2 - 2*I*tan(e + f*x) - 1), x) 
/a**2
 

Maxima [F(-2)]

Exception generated. \[ \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=\text {Exception raised: RuntimeError} \] Input:

integrate((d*cot(f*x+e))^n/(a+I*a*tan(f*x+e))^2,x, algorithm="maxima")
                                                                                    
                                                                                    
 

Output:

Exception raised: RuntimeError >> ECL says: THROW: The catch RAT-ERR is un 
defined.
 

Giac [F]

\[ \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=\int { \frac {\left (d \cot \left (f x + e\right )\right )^{n}}{{\left (i \, a \tan \left (f x + e\right ) + a\right )}^{2}} \,d x } \] Input:

integrate((d*cot(f*x+e))^n/(a+I*a*tan(f*x+e))^2,x, algorithm="giac")
 

Output:

integrate((d*cot(f*x + e))^n/(I*a*tan(f*x + e) + a)^2, x)
 

Mupad [F(-1)]

Timed out. \[ \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=\int \frac {{\left (d\,\mathrm {cot}\left (e+f\,x\right )\right )}^n}{{\left (a+a\,\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )}^2} \,d x \] Input:

int((d*cot(e + f*x))^n/(a + a*tan(e + f*x)*1i)^2,x)
 

Output:

int((d*cot(e + f*x))^n/(a + a*tan(e + f*x)*1i)^2, x)
 

Reduce [F]

\[ \int \frac {(d \cot (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=-\frac {d^{n} \left (\int \frac {\cot \left (f x +e \right )^{n}}{\tan \left (f x +e \right )^{2}-2 \tan \left (f x +e \right ) i -1}d x \right )}{a^{2}} \] Input:

int((d*cot(f*x+e))^n/(a+I*a*tan(f*x+e))^2,x)
 

Output:

( - d**n*int(cot(e + f*x)**n/(tan(e + f*x)**2 - 2*tan(e + f*x)*i - 1),x))/ 
a**2