\(\int (d \sec (e+f x))^{2 n} (a+i a \tan (e+f x))^{-2-n} \, dx\) [501]

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

Optimal result

Integrand size = 32, antiderivative size = 66 \[ \int (d \sec (e+f x))^{2 n} (a+i a \tan (e+f x))^{-2-n} \, dx=\frac {i \operatorname {Hypergeometric2F1}\left (3,n,1+n,\frac {1}{2} (1-i \tan (e+f x))\right ) (d \sec (e+f x))^{2 n} (a+i a \tan (e+f x))^{-n}}{8 a^2 f n} \] Output:

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

Mathematica [B] (verified)

Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(165\) vs. \(2(66)=132\).

Time = 8.56 (sec) , antiderivative size = 165, normalized size of antiderivative = 2.50 \[ \int (d \sec (e+f x))^{2 n} (a+i a \tan (e+f x))^{-2-n} \, dx=-\frac {i 2^{-3+n} e^{2 i e} \left (e^{i f x}\right )^{-n} \left (\frac {e^{i (e+f x)}}{1+e^{2 i (e+f x)}}\right )^n \left (1+e^{2 i (e+f x)}\right )^3 \operatorname {Hypergeometric2F1}\left (3,3-n,4-n,1+e^{2 i (e+f x)}\right ) \sec ^{2-n}(e+f x) (d \sec (e+f x))^{2 n} (\cos (f x)+i \sin (f x))^{2+n} (a+i a \tan (e+f x))^{-2-n}}{f (-3+n)} \] Input:

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

Output:

((-I)*2^(-3 + n)*E^((2*I)*e)*(E^(I*(e + f*x))/(1 + E^((2*I)*(e + f*x))))^n 
*(1 + E^((2*I)*(e + f*x)))^3*Hypergeometric2F1[3, 3 - n, 4 - n, 1 + E^((2* 
I)*(e + f*x))]*Sec[e + f*x]^(2 - n)*(d*Sec[e + f*x])^(2*n)*(Cos[f*x] + I*S 
in[f*x])^(2 + n)*(a + I*a*Tan[e + f*x])^(-2 - n))/((E^(I*f*x))^n*f*(-3 + n 
))
 

Rubi [A] (verified)

Time = 0.55 (sec) , antiderivative size = 70, normalized size of antiderivative = 1.06, number of steps used = 8, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.219, Rules used = {3042, 3986, 3042, 4005, 3042, 3968, 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))^{-n-2} (d \sec (e+f x))^{2 n} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3986

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4005

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3968

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

\(\Big \downarrow \) 78

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

Input:

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

Output:

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

Defintions of rubi rules used

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 3968
Int[sec[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_ 
), x_Symbol] :> Simp[1/(a^(m - 2)*b*f)   Subst[Int[(a - x)^(m/2 - 1)*(a + x 
)^(n + m/2 - 1), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x] && 
 EqQ[a^2 + b^2, 0] && IntegerQ[m/2]
 

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

rule 4005
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_) + (d_.)*tan[(e_.) + 
(f_.)*(x_)])^(n_.), x_Symbol] :> Simp[a^m*c^m   Int[Sec[e + f*x]^(2*m)*(c + 
 d*Tan[e + f*x])^(n - m), x], x] /; FreeQ[{a, b, c, d, e, f, n}, x] && EqQ[ 
b*c + a*d, 0] && EqQ[a^2 + b^2, 0] && IntegerQ[m] &&  !(IGtQ[n, 0] && (LtQ[ 
m, 0] || GtQ[m, n]))
 
Maple [F]

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

Input:

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

Output:

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

Fricas [F]

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

integrate((d*sec(f*x+e))^(2*n)*(a+I*a*tan(f*x+e))^(-2-n),x, algorithm="fri 
cas")
 

Output:

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

Sympy [F]

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

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

Output:

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

Maxima [F(-2)]

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

integrate((d*sec(f*x+e))^(2*n)*(a+I*a*tan(f*x+e))^(-2-n),x, algorithm="max 
ima")
 

Output:

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

Giac [F]

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

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

Output:

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

Mupad [F(-1)]

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

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

Output:

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

Reduce [F]

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

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

Output:

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