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

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 = 28, antiderivative size = 273 \[ \int \frac {(c+d \tan (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=\frac {\operatorname {Hypergeometric2F1}\left (1,1+n,2+n,\frac {c+d \tan (e+f x)}{c-i d}\right ) (c+d \tan (e+f x))^{1+n}}{8 a^2 (i c+d) f (1+n)}+\frac {\left (c^2+2 i c d (1-n)-d^2 \left (1-4 n+2 n^2\right )\right ) \operatorname {Hypergeometric2F1}\left (1,1+n,2+n,\frac {c+d \tan (e+f x)}{c+i d}\right ) (c+d \tan (e+f x))^{1+n}}{8 a^2 (i c-d)^3 f (1+n)}+\frac {(i c-d (2-n)) (c+d \tan (e+f x))^{1+n}}{4 a^2 (c+i d)^2 f (1+i \tan (e+f x))}-\frac {(c+d \tan (e+f x))^{1+n}}{4 (i c-d) f (a+i a \tan (e+f x))^2} \] Output:

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

Mathematica [A] (verified)

Time = 1.45 (sec) , antiderivative size = 207, normalized size of antiderivative = 0.76 \[ \int \frac {(c+d \tan (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=-\frac {(c+d \tan (e+f x))^{1+n} \left (-\frac {(c+i d)^2 \operatorname {Hypergeometric2F1}\left (1,1+n,2+n,\frac {c+d \tan (e+f x)}{c-i d}\right )}{(i c+d) (1+n)}-\frac {i \left (c^2-2 i c d (-1+n)+d^2 \left (-1+4 n-2 n^2\right )\right ) \operatorname {Hypergeometric2F1}\left (1,1+n,2+n,\frac {c+d \tan (e+f x)}{c+i d}\right )}{(c+i d) (1+n)}+\frac {2 i (c+i d)}{(-i+\tan (e+f x))^2}-\frac {2 (c-i d (-2+n))}{-i+\tan (e+f x)}\right )}{8 a^2 (c+i d)^2 f} \] Input:

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

Output:

-1/8*((c + d*Tan[e + f*x])^(1 + n)*(-(((c + I*d)^2*Hypergeometric2F1[1, 1 
+ n, 2 + n, (c + d*Tan[e + f*x])/(c - I*d)])/((I*c + d)*(1 + n))) - (I*(c^ 
2 - (2*I)*c*d*(-1 + n) + d^2*(-1 + 4*n - 2*n^2))*Hypergeometric2F1[1, 1 + 
n, 2 + n, (c + d*Tan[e + f*x])/(c + I*d)])/((c + I*d)*(1 + n)) + ((2*I)*(c 
 + I*d))/(-I + Tan[e + f*x])^2 - (2*(c - I*d*(-2 + n)))/(-I + Tan[e + f*x] 
)))/(a^2*(c + I*d)^2*f)
 

Rubi [A] (verified)

Time = 1.16 (sec) , antiderivative size = 313, normalized size of antiderivative = 1.15, number of steps used = 13, number of rules used = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.429, Rules used = {3042, 4042, 25, 3042, 4079, 27, 3042, 4022, 3042, 4020, 25, 78}

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 {(c+d \tan (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4042

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

\(\Big \downarrow \) 25

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4079

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

\(\Big \downarrow \) 27

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4022

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4020

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

\(\Big \downarrow \) 25

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

\(\Big \downarrow \) 78

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

Input:

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

Output:

-1/4*(c + d*Tan[e + f*x])^(1 + n)/((I*c - d)*f*(a + I*a*Tan[e + f*x])^2) + 
 (-(((c + I*d*(2 - n))*(c + d*Tan[e + f*x])^(1 + n))/((c + I*d)*f*(1 + I*T 
an[e + f*x]))) - (((-1/2*I)*a^2*(c + I*d)^2*Hypergeometric2F1[1, 1 + n, 2 
+ n, (c + d*Tan[e + f*x])/(c - I*d)]*(c + d*Tan[e + f*x])^(1 + n))/((c - I 
*d)*f*(1 + n)) + ((I/2)*a^2*(c^2 + (2*I)*c*d*(1 - n) - d^2*(1 - 4*n + 2*n^ 
2))*Hypergeometric2F1[1, 1 + n, 2 + n, (c + d*Tan[e + f*x])/(c + I*d)]*(c 
+ d*Tan[e + f*x])^(1 + n))/((c + I*d)*f*(1 + n)))/(a^2*(I*c - d)))/(4*a^2* 
(I*c - d))
 

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 78
Int[((a_) + (b_.)*(x_))^(m_)*((c_) + (d_.)*(x_))^(n_), x_Symbol] :> Simp[(b 
*c - a*d)^n*((a + b*x)^(m + 1)/(b^(n + 1)*(m + 1)))*Hypergeometric2F1[-n, m 
 + 1, m + 2, (-d)*((a + b*x)/(b*c - a*d))], x] /; FreeQ[{a, b, c, d, m}, x] 
 &&  !IntegerQ[m] && IntegerQ[n]
 

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

rule 4020
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_) + (d_.)*tan[(e_.) + 
(f_.)*(x_)]), x_Symbol] :> Simp[c*(d/f)   Subst[Int[(a + (b/d)*x)^m/(d^2 + 
c*x), x], x, d*Tan[e + f*x]], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && NeQ[ 
b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && EqQ[c^2 + d^2, 0]
 

rule 4022
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)]), x_Symbol] :> Simp[(c + I*d)/2   Int[(a + b*Tan[e + f*x])^m*( 
1 - I*Tan[e + f*x]), x], x] + Simp[(c - I*d)/2   Int[(a + b*Tan[e + f*x])^m 
*(1 + I*Tan[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && NeQ[b*c 
 - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0] &&  !IntegerQ[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]
 
Maple [F]

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

Input:

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

Output:

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

Fricas [F]

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

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

Output:

integral(1/4*(((c - I*d)*e^(2*I*f*x + 2*I*e) + c + 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 {(c+d \tan (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=- \frac {\int \frac {\left (c + d \tan {\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((c+d*tan(f*x+e))**n/(a+I*a*tan(f*x+e))**2,x)
 

Output:

-Integral((c + d*tan(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 {(c+d \tan (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=\text {Exception raised: RuntimeError} \] Input:

integrate((c+d*tan(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 {(c+d \tan (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=\int { \frac {{\left (d \tan \left (f x + e\right ) + c\right )}^{n}}{{\left (i \, a \tan \left (f x + e\right ) + a\right )}^{2}} \,d x } \] Input:

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

Output:

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

Mupad [F(-1)]

Timed out. \[ \int \frac {(c+d \tan (e+f x))^n}{(a+i a \tan (e+f x))^2} \, dx=\int \frac {{\left (c+d\,\mathrm {tan}\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((c + d*tan(e + f*x))^n/(a + a*tan(e + f*x)*1i)^2,x)
 

Output:

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

Reduce [F]

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

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

Output:

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