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

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [C] (warning: unable to verify)
Fricas [A] (verification not implemented)
Sympy [F]
Maxima [A] (verification not implemented)
Giac [F]
Mupad [B] (verification not implemented)
Reduce [F]

Optimal result

Integrand size = 30, antiderivative size = 148 \[ \int (e \sec (c+d x))^{-2-n} (a+i a \tan (c+d x))^n \, dx=\frac {i (e \sec (c+d x))^{-2-n} (a+i a \tan (c+d x))^n}{d (2-n)}-\frac {2 i (e \sec (c+d x))^{-2-n} (a+i a \tan (c+d x))^{1+n}}{a d (2-n) n}+\frac {2 i (e \sec (c+d x))^{-2-n} (a+i a \tan (c+d x))^{2+n}}{a^2 d n \left (4-n^2\right )} \] Output:

I*(e*sec(d*x+c))^(-2-n)*(a+I*a*tan(d*x+c))^n/d/(2-n)-2*I*(e*sec(d*x+c))^(- 
2-n)*(a+I*a*tan(d*x+c))^(1+n)/a/d/(2-n)/n+2*I*(e*sec(d*x+c))^(-2-n)*(a+I*a 
*tan(d*x+c))^(2+n)/a^2/d/n/(-n^2+4)
 

Mathematica [A] (verified)

Time = 1.21 (sec) , antiderivative size = 82, normalized size of antiderivative = 0.55 \[ \int (e \sec (c+d x))^{-2-n} (a+i a \tan (c+d x))^n \, dx=-\frac {i (e \sec (c+d x))^{-n} \left (-4+n^2+n^2 \cos (2 (c+d x))-2 i n \sin (2 (c+d x))\right ) (a+i a \tan (c+d x))^n}{2 d e^2 (-2+n) n (2+n)} \] Input:

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

Output:

((-1/2*I)*(-4 + n^2 + n^2*Cos[2*(c + d*x)] - (2*I)*n*Sin[2*(c + d*x)])*(a 
+ I*a*Tan[c + d*x])^n)/(d*e^2*(-2 + n)*n*(2 + n)*(e*Sec[c + d*x])^n)
 

Rubi [A] (verified)

Time = 0.62 (sec) , antiderivative size = 147, normalized size of antiderivative = 0.99, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.200, Rules used = {3042, 3985, 3042, 3985, 3042, 3969}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3985

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3985

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3969

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

Input:

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

Output:

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

Defintions of rubi rules used

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

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

rule 3985
Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*( 
x_)])^(n_), x_Symbol] :> Simp[a*(d*Sec[e + f*x])^m*((a + b*Tan[e + f*x])^n/ 
(b*f*(m + 2*n))), x] + Simp[Simplify[m + n]/(a*(m + 2*n))   Int[(d*Sec[e + 
f*x])^m*(a + b*Tan[e + f*x])^(n + 1), x], x] /; FreeQ[{a, b, d, e, f, m, n} 
, x] && EqQ[a^2 + b^2, 0] && ILtQ[Simplify[m + n], 0] && NeQ[m + 2*n, 0]
 
Maple [C] (warning: unable to verify)

Result contains higher order function than in optimal. Order 9 vs. order 3.

Time = 5.47 (sec) , antiderivative size = 2581, normalized size of antiderivative = 17.44

method result size
risch \(\text {Expression too large to display}\) \(2581\)

Input:

int((e*sec(d*x+c))^(-n-2)*(a+I*a*tan(d*x+c))^n,x,method=_RETURNVERBOSE)
 

Output:

-1/4*I/(n-2)/d*a^n/e^2*exp(I*(d*x+c))^n/(e^n)*exp(-1/2*I*(n*Pi*csgn(I*e)*c 
sgn(I*e*exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))^2-n*Pi*csgn(I*e)*csgn(I*exp(I 
*(d*x+c))/(exp(2*I*(d*x+c))+1))*csgn(I*e*exp(I*(d*x+c))/(exp(2*I*(d*x+c))+ 
1))+csgn(I*a*exp(2*I*(d*x+c))/(exp(2*I*(d*x+c))+1))^3*Pi*n-csgn(I*a*exp(2* 
I*(d*x+c))/(exp(2*I*(d*x+c))+1))^2*csgn(I*a)*Pi*n-csgn(I*a*exp(2*I*(d*x+c) 
)/(exp(2*I*(d*x+c))+1))^2*csgn(I/(exp(2*I*(d*x+c))+1)*exp(2*I*(d*x+c)))*Pi 
*n+csgn(I*a*exp(2*I*(d*x+c))/(exp(2*I*(d*x+c))+1))*csgn(I*a)*csgn(I/(exp(2 
*I*(d*x+c))+1)*exp(2*I*(d*x+c)))*Pi*n+csgn(I/(exp(2*I*(d*x+c))+1)*exp(2*I* 
(d*x+c)))^3*Pi*n-csgn(I/(exp(2*I*(d*x+c))+1)*exp(2*I*(d*x+c)))^2*csgn(I*ex 
p(2*I*(d*x+c)))*Pi*n-csgn(I/(exp(2*I*(d*x+c))+1)*exp(2*I*(d*x+c)))^2*csgn( 
I/(exp(2*I*(d*x+c))+1))*Pi*n+csgn(I/(exp(2*I*(d*x+c))+1)*exp(2*I*(d*x+c))) 
*csgn(I*exp(2*I*(d*x+c)))*csgn(I/(exp(2*I*(d*x+c))+1))*Pi*n-n*Pi*csgn(I*e* 
exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))^3+n*Pi*csgn(I*exp(I*(d*x+c))/(exp(2*I 
*(d*x+c))+1))*csgn(I*e*exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))^2-n*Pi*csgn(I* 
exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))^3+n*Pi*csgn(I*exp(I*(d*x+c)))*csgn(I* 
exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))^2+n*Pi*csgn(I*exp(I*(d*x+c))/(exp(2*I 
*(d*x+c))+1))^2*csgn(I/(exp(2*I*(d*x+c))+1))-n*Pi*csgn(I*exp(I*(d*x+c)))*c 
sgn(I*exp(I*(d*x+c))/(exp(2*I*(d*x+c))+1))*csgn(I/(exp(2*I*(d*x+c))+1))+cs 
gn(I*exp(2*I*(d*x+c)))^3*Pi*n-2*csgn(I*exp(2*I*(d*x+c)))^2*csgn(I*exp(I*(d 
*x+c)))*Pi*n+csgn(I*exp(2*I*(d*x+c)))*csgn(I*exp(I*(d*x+c)))^2*Pi*n+4*d...
 

Fricas [A] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 178, normalized size of antiderivative = 1.20 \[ \int (e \sec (c+d x))^{-2-n} (a+i a \tan (c+d x))^n \, dx=\frac {{\left (-i \, n^{2} + {\left (-i \, n^{2} + 2 i \, n\right )} e^{\left (4 i \, d x + 4 i \, c\right )} - 2 \, {\left (i \, n^{2} - 4 i\right )} e^{\left (2 i \, d x + 2 i \, c\right )} - 2 i \, n\right )} \left (\frac {2 \, e e^{\left (i \, d x + i \, c\right )}}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}\right )^{-n - 2} e^{\left (i \, d n x + i \, c n + n \log \left (\frac {2 \, e e^{\left (i \, d x + i \, c\right )}}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}\right ) + n \log \left (\frac {a}{e}\right )\right )}}{d n^{3} - 4 \, d n + {\left (d n^{3} - 4 \, d n\right )} e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, {\left (d n^{3} - 4 \, d n\right )} e^{\left (2 i \, d x + 2 i \, c\right )}} \] Input:

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

Output:

(-I*n^2 + (-I*n^2 + 2*I*n)*e^(4*I*d*x + 4*I*c) - 2*(I*n^2 - 4*I)*e^(2*I*d* 
x + 2*I*c) - 2*I*n)*(2*e*e^(I*d*x + I*c)/(e^(2*I*d*x + 2*I*c) + 1))^(-n - 
2)*e^(I*d*n*x + I*c*n + n*log(2*e*e^(I*d*x + I*c)/(e^(2*I*d*x + 2*I*c) + 1 
)) + n*log(a/e))/(d*n^3 - 4*d*n + (d*n^3 - 4*d*n)*e^(4*I*d*x + 4*I*c) + 2* 
(d*n^3 - 4*d*n)*e^(2*I*d*x + 2*I*c))
 

Sympy [F]

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

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

Output:

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

Maxima [A] (verification not implemented)

Time = 0.23 (sec) , antiderivative size = 175, normalized size of antiderivative = 1.18 \[ \int (e \sec (c+d x))^{-2-n} (a+i a \tan (c+d x))^n \, dx=\frac {{\left (-i \, a^{n} n^{2} + 2 i \, a^{n} n\right )} \cos \left ({\left (d x + c\right )} {\left (n + 2\right )}\right ) + {\left (-i \, a^{n} n^{2} - 2 i \, a^{n} n\right )} \cos \left ({\left (d x + c\right )} {\left (n - 2\right )}\right ) - 2 \, {\left (i \, a^{n} n^{2} - 4 i \, a^{n}\right )} \cos \left ({\left (d x + c\right )} n\right ) + {\left (a^{n} n^{2} - 2 \, a^{n} n\right )} \sin \left ({\left (d x + c\right )} {\left (n + 2\right )}\right ) + {\left (a^{n} n^{2} + 2 \, a^{n} n\right )} \sin \left ({\left (d x + c\right )} {\left (n - 2\right )}\right ) + 2 \, {\left (a^{n} n^{2} - 4 \, a^{n}\right )} \sin \left ({\left (d x + c\right )} n\right )}{4 \, {\left (e^{n + 2} n^{3} - 4 \, e^{n + 2} n\right )} d} \] Input:

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

Output:

1/4*((-I*a^n*n^2 + 2*I*a^n*n)*cos((d*x + c)*(n + 2)) + (-I*a^n*n^2 - 2*I*a 
^n*n)*cos((d*x + c)*(n - 2)) - 2*(I*a^n*n^2 - 4*I*a^n)*cos((d*x + c)*n) + 
(a^n*n^2 - 2*a^n*n)*sin((d*x + c)*(n + 2)) + (a^n*n^2 + 2*a^n*n)*sin((d*x 
+ c)*(n - 2)) + 2*(a^n*n^2 - 4*a^n)*sin((d*x + c)*n))/((e^(n + 2)*n^3 - 4* 
e^(n + 2)*n)*d)
 

Giac [F]

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

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

Output:

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

Mupad [B] (verification not implemented)

Time = 6.67 (sec) , antiderivative size = 227, normalized size of antiderivative = 1.53 \[ \int (e \sec (c+d x))^{-2-n} (a+i a \tan (c+d x))^n \, dx=\frac {\left (\cos \left (2\,c+2\,d\,x\right )-\sin \left (2\,c+2\,d\,x\right )\,1{}\mathrm {i}\right )\,\left (\frac {{\left (a+\frac {a\,\sin \left (c+d\,x\right )\,1{}\mathrm {i}}{\cos \left (c+d\,x\right )}\right )}^n\,\left (n+2\right )}{d\,\left (n^2\,1{}\mathrm {i}-4{}\mathrm {i}\right )}+\frac {\left (\cos \left (4\,c+4\,d\,x\right )+\sin \left (4\,c+4\,d\,x\right )\,1{}\mathrm {i}\right )\,{\left (a+\frac {a\,\sin \left (c+d\,x\right )\,1{}\mathrm {i}}{\cos \left (c+d\,x\right )}\right )}^n\,\left (n-2\right )}{d\,\left (n^2\,1{}\mathrm {i}-4{}\mathrm {i}\right )}+\frac {\left (\cos \left (2\,c+2\,d\,x\right )+\sin \left (2\,c+2\,d\,x\right )\,1{}\mathrm {i}\right )\,\left (2\,n^2-8\right )\,{\left (a+\frac {a\,\sin \left (c+d\,x\right )\,1{}\mathrm {i}}{\cos \left (c+d\,x\right )}\right )}^n}{d\,n\,\left (n^2\,1{}\mathrm {i}-4{}\mathrm {i}\right )}\right )}{4\,\left (\frac {\cos \left (2\,c+2\,d\,x\right )}{2}+\frac {1}{2}\right )\,{\left (\frac {e}{\cos \left (c+d\,x\right )}\right )}^{n+2}} \] Input:

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

Output:

((cos(2*c + 2*d*x) - sin(2*c + 2*d*x)*1i)*(((a + (a*sin(c + d*x)*1i)/cos(c 
 + d*x))^n*(n + 2))/(d*(n^2*1i - 4i)) + ((cos(4*c + 4*d*x) + sin(4*c + 4*d 
*x)*1i)*(a + (a*sin(c + d*x)*1i)/cos(c + d*x))^n*(n - 2))/(d*(n^2*1i - 4i) 
) + ((cos(2*c + 2*d*x) + sin(2*c + 2*d*x)*1i)*(2*n^2 - 8)*(a + (a*sin(c + 
d*x)*1i)/cos(c + d*x))^n)/(d*n*(n^2*1i - 4i))))/(4*(cos(2*c + 2*d*x)/2 + 1 
/2)*(e/cos(c + d*x))^(n + 2))
 

Reduce [F]

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

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

Output:

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