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

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

Optimal result

Integrand size = 34, antiderivative size = 102 \[ \int \frac {\cot ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=-\frac {(3 A+i B) x}{2 a}-\frac {(3 A+i B) \cot (c+d x)}{2 a d}-\frac {(i A-B) \log (\sin (c+d x))}{a d}+\frac {(A+i B) \cot (c+d x)}{2 d (a+i a \tan (c+d x))} \] Output:

-1/2*(3*A+I*B)*x/a-1/2*(3*A+I*B)*cot(d*x+c)/a/d-(I*A-B)*ln(sin(d*x+c))/a/d 
+1/2*(A+I*B)*cot(d*x+c)/d/(a+I*a*tan(d*x+c))
 

Mathematica [C] (verified)

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

Time = 0.80 (sec) , antiderivative size = 98, normalized size of antiderivative = 0.96 \[ \int \frac {\cot ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=\frac {\frac {(A+i B) \cot ^2(c+d x)}{i+\cot (c+d x)}-(3 A+i B) \cot (c+d x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(c+d x)\right )+2 (-i A+B) (\log (\cos (c+d x))+\log (\tan (c+d x)))}{2 a d} \] Input:

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

Output:

(((A + I*B)*Cot[c + d*x]^2)/(I + Cot[c + d*x]) - (3*A + I*B)*Cot[c + d*x]* 
Hypergeometric2F1[-1/2, 1, 1/2, -Tan[c + d*x]^2] + 2*((-I)*A + B)*(Log[Cos 
[c + d*x]] + Log[Tan[c + d*x]]))/(2*a*d)
 

Rubi [A] (verified)

Time = 0.60 (sec) , antiderivative size = 102, normalized size of antiderivative = 1.00, number of steps used = 10, number of rules used = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.294, Rules used = {3042, 4079, 3042, 4012, 25, 3042, 4014, 3042, 25, 3956}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4079

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4012

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

\(\Big \downarrow \) 25

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4014

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

\(\Big \downarrow \) 3042

\(\displaystyle \frac {-2 a (-B+i A) \int -\tan \left (c+d x+\frac {\pi }{2}\right )dx-\frac {a (3 A+i B) \cot (c+d x)}{d}-a x (3 A+i B)}{2 a^2}+\frac {(A+i B) \cot (c+d x)}{2 d (a+i a \tan (c+d x))}\)

\(\Big \downarrow \) 25

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

\(\Big \downarrow \) 3956

\(\displaystyle \frac {-\frac {a (3 A+i B) \cot (c+d x)}{d}-\frac {2 a (-B+i A) \log (-\sin (c+d x))}{d}-a x (3 A+i B)}{2 a^2}+\frac {(A+i B) \cot (c+d x)}{2 d (a+i a \tan (c+d x))}\)

Input:

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

Output:

(-(a*(3*A + I*B)*x) - (a*(3*A + I*B)*Cot[c + d*x])/d - (2*a*(I*A - B)*Log[ 
-Sin[c + d*x]])/d)/(2*a^2) + ((A + I*B)*Cot[c + d*x])/(2*d*(a + I*a*Tan[c 
+ d*x]))
 

Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

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

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

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

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

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 [A] (verified)

Time = 0.33 (sec) , antiderivative size = 140, normalized size of antiderivative = 1.37

method result size
risch \(-\frac {3 i x B}{2 a}-\frac {5 x A}{2 a}+\frac {{\mathrm e}^{-2 i \left (d x +c \right )} B}{4 a d}-\frac {i {\mathrm e}^{-2 i \left (d x +c \right )} A}{4 a d}-\frac {2 i B c}{a d}-\frac {2 A c}{a d}-\frac {2 i A}{a d \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}+\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) B}{a d}-\frac {i \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) A}{a d}\) \(140\)
norman \(\frac {-\frac {A}{a d}-\frac {\left (i B +3 A \right ) \tan \left (d x +c \right )^{2}}{2 a d}-\frac {\left (i B +3 A \right ) x \tan \left (d x +c \right )}{2 a}-\frac {\left (i B +3 A \right ) x \tan \left (d x +c \right )^{3}}{2 a}+\frac {\left (-i A +B \right ) \tan \left (d x +c \right )}{2 a d}}{\tan \left (d x +c \right ) \left (1+\tan \left (d x +c \right )^{2}\right )}+\frac {\left (-i A +B \right ) \ln \left (\tan \left (d x +c \right )\right )}{a d}-\frac {\left (-i A +B \right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 a d}\) \(164\)
derivativedivides \(\frac {i A \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d a}-\frac {3 A \arctan \left (\tan \left (d x +c \right )\right )}{2 d a}-\frac {B \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d a}-\frac {i B \arctan \left (\tan \left (d x +c \right )\right )}{2 d a}-\frac {A}{2 d a \left (-i+\tan \left (d x +c \right )\right )}-\frac {i B}{2 d a \left (-i+\tan \left (d x +c \right )\right )}-\frac {i A \ln \left (\tan \left (d x +c \right )\right )}{a d}+\frac {B \ln \left (\tan \left (d x +c \right )\right )}{a d}-\frac {A}{a d \tan \left (d x +c \right )}\) \(166\)
default \(\frac {i A \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d a}-\frac {3 A \arctan \left (\tan \left (d x +c \right )\right )}{2 d a}-\frac {B \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d a}-\frac {i B \arctan \left (\tan \left (d x +c \right )\right )}{2 d a}-\frac {A}{2 d a \left (-i+\tan \left (d x +c \right )\right )}-\frac {i B}{2 d a \left (-i+\tan \left (d x +c \right )\right )}-\frac {i A \ln \left (\tan \left (d x +c \right )\right )}{a d}+\frac {B \ln \left (\tan \left (d x +c \right )\right )}{a d}-\frac {A}{a d \tan \left (d x +c \right )}\) \(166\)

Input:

int(cot(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x,method=_RETURNVERBO 
SE)
 

Output:

-3/2*I*x/a*B-5/2*x/a*A+1/4/a/d*exp(-2*I*(d*x+c))*B-1/4*I/a/d*exp(-2*I*(d*x 
+c))*A-2*I/a/d*B*c-2/a/d*A*c-2*I*A/a/d/(exp(2*I*(d*x+c))-1)+1/a/d*ln(exp(2 
*I*(d*x+c))-1)*B-I/a/d*ln(exp(2*I*(d*x+c))-1)*A
 

Fricas [A] (verification not implemented)

Time = 0.09 (sec) , antiderivative size = 129, normalized size of antiderivative = 1.26 \[ \int \frac {\cot ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=-\frac {2 \, {\left (5 \, A + 3 i \, B\right )} d x e^{\left (4 i \, d x + 4 i \, c\right )} - {\left (2 \, {\left (5 \, A + 3 i \, B\right )} d x - 9 i \, A + B\right )} e^{\left (2 i \, d x + 2 i \, c\right )} + 4 \, {\left ({\left (i \, A - B\right )} e^{\left (4 i \, d x + 4 i \, c\right )} + {\left (-i \, A + B\right )} e^{\left (2 i \, d x + 2 i \, c\right )}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} - 1\right ) - i \, A + B}{4 \, {\left (a d e^{\left (4 i \, d x + 4 i \, c\right )} - a d e^{\left (2 i \, d x + 2 i \, c\right )}\right )}} \] Input:

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

Output:

-1/4*(2*(5*A + 3*I*B)*d*x*e^(4*I*d*x + 4*I*c) - (2*(5*A + 3*I*B)*d*x - 9*I 
*A + B)*e^(2*I*d*x + 2*I*c) + 4*((I*A - B)*e^(4*I*d*x + 4*I*c) + (-I*A + B 
)*e^(2*I*d*x + 2*I*c))*log(e^(2*I*d*x + 2*I*c) - 1) - I*A + B)/(a*d*e^(4*I 
*d*x + 4*I*c) - a*d*e^(2*I*d*x + 2*I*c))
 

Sympy [A] (verification not implemented)

Time = 0.37 (sec) , antiderivative size = 158, normalized size of antiderivative = 1.55 \[ \int \frac {\cot ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=- \frac {2 i A}{a d e^{2 i c} e^{2 i d x} - a d} + \begin {cases} \frac {\left (- i A + B\right ) e^{- 2 i c} e^{- 2 i d x}}{4 a d} & \text {for}\: a d e^{2 i c} \neq 0 \\x \left (- \frac {- 5 A - 3 i B}{2 a} + \frac {\left (- 5 A e^{2 i c} - A - 3 i B e^{2 i c} - i B\right ) e^{- 2 i c}}{2 a}\right ) & \text {otherwise} \end {cases} + \frac {x \left (- 5 A - 3 i B\right )}{2 a} - \frac {i \left (A + i B\right ) \log {\left (e^{2 i d x} - e^{- 2 i c} \right )}}{a d} \] Input:

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

Output:

-2*I*A/(a*d*exp(2*I*c)*exp(2*I*d*x) - a*d) + Piecewise(((-I*A + B)*exp(-2* 
I*c)*exp(-2*I*d*x)/(4*a*d), Ne(a*d*exp(2*I*c), 0)), (x*(-(-5*A - 3*I*B)/(2 
*a) + (-5*A*exp(2*I*c) - A - 3*I*B*exp(2*I*c) - I*B)*exp(-2*I*c)/(2*a)), T 
rue)) + x*(-5*A - 3*I*B)/(2*a) - I*(A + I*B)*log(exp(2*I*d*x) - exp(-2*I*c 
))/(a*d)
 

Maxima [F(-2)]

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

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

Output:

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negati 
ve exponent.
 

Giac [A] (verification not implemented)

Time = 0.47 (sec) , antiderivative size = 111, normalized size of antiderivative = 1.09 \[ \int \frac {\cot ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=-\frac {{\left (i \, A + B\right )} \log \left (\tan \left (d x + c\right ) + i\right )}{4 \, a d} - \frac {{\left (-5 i \, A + 3 \, B\right )} \log \left (\tan \left (d x + c\right ) - i\right )}{4 \, a d} + \frac {{\left (-i \, A + B\right )} \log \left ({\left | \tan \left (d x + c\right ) \right |}\right )}{a d} - \frac {{\left (3 \, A + i \, B\right )} \tan \left (d x + c\right ) - 2 i \, A}{2 \, a d {\left (\tan \left (d x + c\right ) - i\right )} \tan \left (d x + c\right )} \] Input:

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

Output:

-1/4*(I*A + B)*log(tan(d*x + c) + I)/(a*d) - 1/4*(-5*I*A + 3*B)*log(tan(d* 
x + c) - I)/(a*d) + (-I*A + B)*log(abs(tan(d*x + c)))/(a*d) - 1/2*((3*A + 
I*B)*tan(d*x + c) - 2*I*A)/(a*d*(tan(d*x + c) - I)*tan(d*x + c))
 

Mupad [B] (verification not implemented)

Time = 3.55 (sec) , antiderivative size = 126, normalized size of antiderivative = 1.24 \[ \int \frac {\cot ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx=-\frac {\frac {A}{a}+\mathrm {tan}\left (c+d\,x\right )\,\left (-\frac {B}{2\,a}+\frac {A\,3{}\mathrm {i}}{2\,a}\right )}{d\,\left ({\mathrm {tan}\left (c+d\,x\right )}^2\,1{}\mathrm {i}+\mathrm {tan}\left (c+d\,x\right )\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )\right )\,\left (-B+A\,1{}\mathrm {i}\right )}{a\,d}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B+A\,1{}\mathrm {i}\right )}{4\,a\,d}+\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (-3\,B+A\,5{}\mathrm {i}\right )}{4\,a\,d} \] Input:

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

Output:

(log(tan(c + d*x) - 1i)*(A*5i - 3*B))/(4*a*d) - (log(tan(c + d*x))*(A*1i - 
 B))/(a*d) - (log(tan(c + d*x) + 1i)*(A*1i + B))/(4*a*d) - (A/a + tan(c + 
d*x)*((A*3i)/(2*a) - B/(2*a)))/(d*(tan(c + d*x) + tan(c + d*x)^2*1i))
 

Reduce [F]

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

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

Output:

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