\(\int \frac {\tan ^m(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx\) [209]

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

Optimal result

Integrand size = 34, antiderivative size = 226 \[ \int \frac {\tan ^m(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {(1-m) (A (1-m)-i B (1+m)) \operatorname {Hypergeometric2F1}\left (1,\frac {1+m}{2},\frac {3+m}{2},-\tan ^2(c+d x)\right ) \tan ^{1+m}(c+d x)}{4 a^2 d (1+m)}+\frac {(A (2-m)-i B m) \tan ^{1+m}(c+d x)}{4 a^2 d (1+i \tan (c+d x))}+\frac {m (i A (2-m)+B m) \operatorname {Hypergeometric2F1}\left (1,\frac {2+m}{2},\frac {4+m}{2},-\tan ^2(c+d x)\right ) \tan ^{2+m}(c+d x)}{4 a^2 d (2+m)}+\frac {(A+i B) \tan ^{1+m}(c+d x)}{4 d (a+i a \tan (c+d x))^2} \] Output:

1/4*(1-m)*(A*(1-m)-I*B*(1+m))*hypergeom([1, 1/2+1/2*m],[3/2+1/2*m],-tan(d* 
x+c)^2)*tan(d*x+c)^(1+m)/a^2/d/(1+m)+1/4*(A*(2-m)-I*B*m)*tan(d*x+c)^(1+m)/ 
a^2/d/(1+I*tan(d*x+c))+1/4*m*(I*A*(2-m)+B*m)*hypergeom([1, 1+1/2*m],[2+1/2 
*m],-tan(d*x+c)^2)*tan(d*x+c)^(2+m)/a^2/d/(2+m)+1/4*(A+I*B)*tan(d*x+c)^(1+ 
m)/d/(a+I*a*tan(d*x+c))^2
 

Mathematica [A] (verified)

Time = 2.08 (sec) , antiderivative size = 175, normalized size of antiderivative = 0.77 \[ \int \frac {\tan ^m(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {\tan ^{1+m}(c+d x) \left (\frac {2 a (-1+m) (A (-1+m)+i B (1+m)) \operatorname {Hypergeometric2F1}\left (1,\frac {1+m}{2},\frac {3+m}{2},-\tan ^2(c+d x)\right )}{1+m}+\frac {2 a m (-i A (-2+m)+B m) \operatorname {Hypergeometric2F1}\left (1,\frac {2+m}{2},\frac {4+m}{2},-\tan ^2(c+d x)\right ) \tan (c+d x)}{2+m}-\frac {2 a (A+i B)}{(-i+\tan (c+d x))^2}+\frac {2 i a A (-2+m)-2 a B m}{-i+\tan (c+d x)}\right )}{8 a^3 d} \] Input:

Integrate[(Tan[c + d*x]^m*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^2,x 
]
 

Output:

(Tan[c + d*x]^(1 + m)*((2*a*(-1 + m)*(A*(-1 + m) + I*B*(1 + m))*Hypergeome 
tric2F1[1, (1 + m)/2, (3 + m)/2, -Tan[c + d*x]^2])/(1 + m) + (2*a*m*((-I)* 
A*(-2 + m) + B*m)*Hypergeometric2F1[1, (2 + m)/2, (4 + m)/2, -Tan[c + d*x] 
^2]*Tan[c + d*x])/(2 + m) - (2*a*(A + I*B))/(-I + Tan[c + d*x])^2 + ((2*I) 
*a*A*(-2 + m) - 2*a*B*m)/(-I + Tan[c + d*x])))/(8*a^3*d)
 

Rubi [A] (verified)

Time = 0.95 (sec) , antiderivative size = 227, normalized size of antiderivative = 1.00, number of steps used = 11, number of rules used = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.294, Rules used = {3042, 4079, 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 {\tan ^m(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {\tan (c+d x)^m (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2}dx\)

\(\Big \downarrow \) 4079

\(\displaystyle \frac {\int \frac {\tan ^m(c+d x) (a (A (3-m)-i B (m+1))-a (i A-B) (1-m) \tan (c+d x))}{i \tan (c+d x) a+a}dx}{4 a^2}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \frac {\tan (c+d x)^m (a (A (3-m)-i B (m+1))-a (i A-B) (1-m) \tan (c+d x))}{i \tan (c+d x) a+a}dx}{4 a^2}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\)

\(\Big \downarrow \) 4079

\(\displaystyle \frac {\frac {\int 2 \tan ^m(c+d x) \left ((1-m) (A (1-m)-i B (m+1)) a^2+m (i A (2-m)+B m) \tan (c+d x) a^2\right )dx}{2 a^2}+\frac {(A (2-m)-i B m) \tan ^{m+1}(c+d x)}{d (1+i \tan (c+d x))}}{4 a^2}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {\frac {\int \tan ^m(c+d x) \left ((1-m) (A (1-m)-i B (m+1)) a^2+m (i A (2-m)+B m) \tan (c+d x) a^2\right )dx}{a^2}+\frac {(A (2-m)-i B m) \tan ^{m+1}(c+d x)}{d (1+i \tan (c+d x))}}{4 a^2}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\frac {\int \tan (c+d x)^m \left ((1-m) (A (1-m)-i B (m+1)) a^2+m (i A (2-m)+B m) \tan (c+d x) a^2\right )dx}{a^2}+\frac {(A (2-m)-i B m) \tan ^{m+1}(c+d x)}{d (1+i \tan (c+d x))}}{4 a^2}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\)

\(\Big \downarrow \) 4021

\(\displaystyle \frac {\frac {a^2 m (B m+i A (2-m)) \int \tan ^{m+1}(c+d x)dx+a^2 (1-m) (A (1-m)-i B (m+1)) \int \tan ^m(c+d x)dx}{a^2}+\frac {(A (2-m)-i B m) \tan ^{m+1}(c+d x)}{d (1+i \tan (c+d x))}}{4 a^2}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\frac {a^2 (1-m) (A (1-m)-i B (m+1)) \int \tan (c+d x)^mdx+a^2 m (B m+i A (2-m)) \int \tan (c+d x)^{m+1}dx}{a^2}+\frac {(A (2-m)-i B m) \tan ^{m+1}(c+d x)}{d (1+i \tan (c+d x))}}{4 a^2}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\)

\(\Big \downarrow \) 3957

\(\displaystyle \frac {\frac {\frac {a^2 m (B m+i A (2-m)) \int \frac {\tan ^{m+1}(c+d x)}{\tan ^2(c+d x)+1}d\tan (c+d x)}{d}+\frac {a^2 (1-m) (A (1-m)-i B (m+1)) \int \frac {\tan ^m(c+d x)}{\tan ^2(c+d x)+1}d\tan (c+d x)}{d}}{a^2}+\frac {(A (2-m)-i B m) \tan ^{m+1}(c+d x)}{d (1+i \tan (c+d x))}}{4 a^2}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\)

\(\Big \downarrow \) 278

\(\displaystyle \frac {\frac {\frac {a^2 (1-m) (A (1-m)-i B (m+1)) \tan ^{m+1}(c+d x) \operatorname {Hypergeometric2F1}\left (1,\frac {m+1}{2},\frac {m+3}{2},-\tan ^2(c+d x)\right )}{d (m+1)}+\frac {a^2 m (B m+i A (2-m)) \tan ^{m+2}(c+d x) \operatorname {Hypergeometric2F1}\left (1,\frac {m+2}{2},\frac {m+4}{2},-\tan ^2(c+d x)\right )}{d (m+2)}}{a^2}+\frac {(A (2-m)-i B m) \tan ^{m+1}(c+d x)}{d (1+i \tan (c+d x))}}{4 a^2}+\frac {(A+i B) \tan ^{m+1}(c+d x)}{4 d (a+i a \tan (c+d x))^2}\)

Input:

Int[(Tan[c + d*x]^m*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^2,x]
 

Output:

((A + I*B)*Tan[c + d*x]^(1 + m))/(4*d*(a + I*a*Tan[c + d*x])^2) + (((A*(2 
- m) - I*B*m)*Tan[c + d*x]^(1 + m))/(d*(1 + I*Tan[c + d*x])) + ((a^2*(1 - 
m)*(A*(1 - m) - I*B*(1 + m))*Hypergeometric2F1[1, (1 + m)/2, (3 + m)/2, -T 
an[c + d*x]^2]*Tan[c + d*x]^(1 + m))/(d*(1 + m)) + (a^2*m*(I*A*(2 - m) + B 
*m)*Hypergeometric2F1[1, (2 + m)/2, (4 + m)/2, -Tan[c + d*x]^2]*Tan[c + d* 
x]^(2 + m))/(d*(2 + m)))/a^2)/(4*a^2)
 

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 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 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 {\tan \left (d x +c \right )^{m} \left (A +B \tan \left (d x +c \right )\right )}{\left (a +i a \tan \left (d x +c \right )\right )^{2}}d x\]

Input:

int(tan(d*x+c)^m*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x)
 

Output:

int(tan(d*x+c)^m*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x)
 

Fricas [F]

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

integrate(tan(d*x+c)^m*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm= 
"fricas")
 

Output:

integral(1/4*((A - I*B)*e^(4*I*d*x + 4*I*c) + 2*A*e^(2*I*d*x + 2*I*c) + A 
+ I*B)*((-I*e^(2*I*d*x + 2*I*c) + I)/(e^(2*I*d*x + 2*I*c) + 1))^m*e^(-4*I* 
d*x - 4*I*c)/a^2, x)
 

Sympy [F]

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

integrate(tan(d*x+c)**m*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))**2,x)
 

Output:

-(Integral(A*tan(c + d*x)**m/(tan(c + d*x)**2 - 2*I*tan(c + d*x) - 1), x) 
+ Integral(B*tan(c + d*x)*tan(c + d*x)**m/(tan(c + d*x)**2 - 2*I*tan(c + d 
*x) - 1), x))/a**2
 

Maxima [F(-2)]

Exception generated. \[ \int \frac {\tan ^m(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\text {Exception raised: RuntimeError} \] Input:

integrate(tan(d*x+c)^m*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm= 
"maxima")
 

Output:

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

Giac [F(-2)]

Exception generated. \[ \int \frac {\tan ^m(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\text {Exception raised: RuntimeError} \] Input:

integrate(tan(d*x+c)^m*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm= 
"giac")
 

Output:

Exception raised: RuntimeError >> an error occurred running a Giac command 
:INPUT:sage2OUTPUT:Unable to divide, perhaps due to rounding error%%%{1,[0 
,1,0]%%%} / %%%{1,[0,0,2]%%%} Error: Bad Argument Value
 

Mupad [F(-1)]

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

int((tan(c + d*x)^m*(A + B*tan(c + d*x)))/(a + a*tan(c + d*x)*1i)^2,x)
 

Output:

int((tan(c + d*x)^m*(A + B*tan(c + d*x)))/(a + a*tan(c + d*x)*1i)^2, x)
 

Reduce [F]

\[ \int \frac {\tan ^m(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {-\left (\int \frac {\tan \left (d x +c \right )^{m}}{\tan \left (d x +c \right )^{2}-2 \tan \left (d x +c \right ) i -1}d x \right ) a -\left (\int \frac {\tan \left (d x +c \right )^{m} \tan \left (d x +c \right )}{\tan \left (d x +c \right )^{2}-2 \tan \left (d x +c \right ) i -1}d x \right ) b}{a^{2}} \] Input:

int(tan(d*x+c)^m*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x)
                                                                                    
                                                                                    
 

Output:

( - (int(tan(c + d*x)**m/(tan(c + d*x)**2 - 2*tan(c + d*x)*i - 1),x)*a + i 
nt((tan(c + d*x)**m*tan(c + d*x))/(tan(c + d*x)**2 - 2*tan(c + d*x)*i - 1) 
,x)*b))/a**2