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

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

Optimal result

Integrand size = 28, antiderivative size = 95 \[ \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x))^n \, dx=-\frac {a^2 (c+d \tan (e+f x))^{1+n}}{d f (1+n)}+\frac {2 a^2 \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}}{(i c+d) f (1+n)} \] Output:

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

Mathematica [A] (verified)

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

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

Output:

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

Rubi [A] (verified)

Time = 0.41 (sec) , antiderivative size = 112, normalized size of antiderivative = 1.18, number of steps used = 7, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.214, Rules used = {3042, 4026, 3042, 4020, 27, 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 (a+i a \tan (e+f x))^2 (c+d \tan (e+f x))^n \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+i a \tan (e+f x))^2 (c+d \tan (e+f x))^ndx\)

\(\Big \downarrow \) 4026

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4020

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

\(\Big \downarrow \) 27

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

\(\Big \downarrow \) 78

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

Input:

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

Output:

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

Defintions of rubi rules used

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

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

Input:

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

Output:

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

Fricas [F]

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

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

Output:

integral(4*a^2*(((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)/(e^(4*I*f*x + 4*I*e) + 2*e^(2*I*f*x + 2*I 
*e) + 1), x)
 

Sympy [F]

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

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

Output:

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

Maxima [F]

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

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

Output:

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

Giac [F]

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

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

Output:

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

Mupad [F(-1)]

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

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

Output:

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

Reduce [F]

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

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

Output:

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