\(\int \frac {a+i a \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx\) [1091]

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

Optimal result

Integrand size = 26, antiderivative size = 75 \[ \int \frac {a+i a \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {a x}{(c-i d)^2}-\frac {i a \log (c \cos (e+f x)+d \sin (e+f x))}{(c-i d)^2 f}-\frac {a}{(i c+d) f (c+d \tan (e+f x))} \] Output:

a*x/(c-I*d)^2-I*a*ln(c*cos(f*x+e)+d*sin(f*x+e))/(c-I*d)^2/f-a/(I*c+d)/f/(c 
+d*tan(f*x+e))
 

Mathematica [A] (verified)

Time = 0.56 (sec) , antiderivative size = 74, normalized size of antiderivative = 0.99 \[ \int \frac {a+i a \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {i a^2 \left (\frac {\log (i+\tan (e+f x))}{a}-\frac {\log (c+d \tan (e+f x))}{a}+\frac {c-i d}{a c+a d \tan (e+f x)}\right )}{(c-i d)^2 f} \] Input:

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

Output:

(I*a^2*(Log[I + Tan[e + f*x]]/a - Log[c + d*Tan[e + f*x]]/a + (c - I*d)/(a 
*c + a*d*Tan[e + f*x])))/((c - I*d)^2*f)
 

Rubi [A] (verified)

Time = 0.51 (sec) , antiderivative size = 100, normalized size of antiderivative = 1.33, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.231, Rules used = {3042, 4012, 3042, 4014, 3042, 4013}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4012

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4014

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4013

\(\displaystyle \frac {\frac {a x (c+i d)}{c-i d}-\frac {a (-d+i c) \log (c \cos (e+f x)+d \sin (e+f x))}{f (c-i d)}}{c^2+d^2}-\frac {a}{f (d+i c) (c+d \tan (e+f x))}\)

Input:

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

Output:

((a*(c + I*d)*x)/(c - I*d) - (a*(I*c - d)*Log[c*Cos[e + f*x] + d*Sin[e + f 
*x]])/((c - I*d)*f))/(c^2 + d^2) - a/((I*c + d)*f*(c + d*Tan[e + f*x]))
 

Defintions of rubi rules used

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, 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 4013
Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)* 
(x_)]), x_Symbol] :> Simp[(c/(b*f))*Log[RemoveContent[a*Cos[e + f*x] + b*Si 
n[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] && EqQ[a*c + b*d, 0]
 

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

Time = 0.22 (sec) , antiderivative size = 139, normalized size of antiderivative = 1.85

method result size
derivativedivides \(\frac {a \left (\frac {i c -d}{\left (c^{2}+d^{2}\right ) \left (c +d \tan \left (f x +e \right )\right )}-\frac {\left (i c^{2}-i d^{2}-2 c d \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}+\frac {\frac {\left (i c^{2}-i d^{2}-2 c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (2 i c d +c^{2}-d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}\right )}{f}\) \(139\)
default \(\frac {a \left (\frac {i c -d}{\left (c^{2}+d^{2}\right ) \left (c +d \tan \left (f x +e \right )\right )}-\frac {\left (i c^{2}-i d^{2}-2 c d \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}+\frac {\frac {\left (i c^{2}-i d^{2}-2 c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (2 i c d +c^{2}-d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}\right )}{f}\) \(139\)
norman \(\frac {\frac {a c x}{\left (-i d +c \right )^{2}}-\frac {i a d \tan \left (f x +e \right )}{f \left (-i d +c \right ) c}-\frac {a d x \tan \left (f x +e \right )}{\left (i c +d \right )^{2}}}{c +d \tan \left (f x +e \right )}+\frac {i a \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f \left (-2 i c d +c^{2}-d^{2}\right )}-\frac {i a \ln \left (c +d \tan \left (f x +e \right )\right )}{f \left (-2 i c d +c^{2}-d^{2}\right )}\) \(140\)
risch \(-\frac {2 a x}{2 i c d -c^{2}+d^{2}}-\frac {2 i a x}{i c^{2}-i d^{2}+2 c d}-\frac {2 i a e}{f \left (i c^{2}-i d^{2}+2 c d \right )}-\frac {2 i a d}{f \left (i c +d \right )^{2} \left ({\mathrm e}^{2 i \left (f x +e \right )} d -d +i {\mathrm e}^{2 i \left (f x +e \right )} c +i c \right )}+\frac {a \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right )}{f \left (i c^{2}-i d^{2}+2 c d \right )}\) \(176\)
parallelrisch \(\frac {2 i a c \,d^{3}+2 i \ln \left (c +d \tan \left (f x +e \right )\right ) a c \,d^{3}+2 i a \,c^{3} d -2 i \ln \left (c +d \tan \left (f x +e \right )\right ) a \,c^{3} d +i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) a \,c^{2} d^{2}-2 x \tan \left (f x +e \right ) a \,d^{4} f +2 x a \,c^{3} d f -2 x a c \,d^{3} f -2 a \,d^{4}+i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a \,c^{3} d +4 i x a \,c^{2} d^{2} f +2 i \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a \,d^{4}+2 x \tan \left (f x +e \right ) a \,c^{2} d^{2} f -i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) a \,d^{4}-2 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) a c \,d^{3}+4 \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a c \,d^{3}-2 i \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a \,c^{2} d^{2}-2 a \,c^{2} d^{2}-2 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a \,c^{2} d^{2}+4 \ln \left (c +d \tan \left (f x +e \right )\right ) a \,c^{2} d^{2}+4 i x \tan \left (f x +e \right ) a c \,d^{3} f -i \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a c \,d^{3}}{2 f d \left (c^{2}+d^{2}\right )^{2} \left (c +d \tan \left (f x +e \right )\right )}\) \(405\)

Input:

int((a+I*a*tan(f*x+e))/(c+d*tan(f*x+e))^2,x,method=_RETURNVERBOSE)
 

Output:

1/f*a*((I*c-d)/(c^2+d^2)/(c+d*tan(f*x+e))-(I*c^2-I*d^2-2*c*d)/(c^2+d^2)^2* 
ln(c+d*tan(f*x+e))+1/(c^2+d^2)^2*(1/2*(I*c^2-I*d^2-2*c*d)*ln(1+tan(f*x+e)^ 
2)+(2*I*c*d+c^2-d^2)*arctan(tan(f*x+e))))
 

Fricas [A] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 125, normalized size of antiderivative = 1.67 \[ \int \frac {a+i a \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {-2 i \, a d - {\left (a c + i \, a d + {\left (a c - i \, a d\right )} e^{\left (2 i \, f x + 2 i \, e\right )}\right )} \log \left (\frac {{\left (i \, c + d\right )} e^{\left (2 i \, f x + 2 i \, e\right )} + i \, c - d}{i \, c + d}\right )}{{\left (-i \, c^{3} - 3 \, c^{2} d + 3 i \, c d^{2} + d^{3}\right )} f e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (-i \, c^{3} - c^{2} d - i \, c d^{2} - d^{3}\right )} f} \] Input:

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

Output:

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

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 143 vs. \(2 (58) = 116\).

Time = 1.54 (sec) , antiderivative size = 143, normalized size of antiderivative = 1.91 \[ \int \frac {a+i a \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {2 a d}{c^{3} f - i c^{2} d f + c d^{2} f - i d^{3} f + \left (c^{3} f e^{2 i e} - 3 i c^{2} d f e^{2 i e} - 3 c d^{2} f e^{2 i e} + i d^{3} f e^{2 i e}\right ) e^{2 i f x}} - \frac {i a \log {\left (\frac {c + i d}{c e^{2 i e} - i d e^{2 i e}} + e^{2 i f x} \right )}}{f \left (c - i d\right )^{2}} \] Input:

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

Output:

2*a*d/(c**3*f - I*c**2*d*f + c*d**2*f - I*d**3*f + (c**3*f*exp(2*I*e) - 3* 
I*c**2*d*f*exp(2*I*e) - 3*c*d**2*f*exp(2*I*e) + I*d**3*f*exp(2*I*e))*exp(2 
*I*f*x)) - I*a*log((c + I*d)/(c*exp(2*I*e) - I*d*exp(2*I*e)) + exp(2*I*f*x 
))/(f*(c - I*d)**2)
 

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 180 vs. \(2 (67) = 134\).

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

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

Output:

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

Giac [A] (verification not implemented)

Time = 0.45 (sec) , antiderivative size = 98, normalized size of antiderivative = 1.31 \[ \int \frac {a+i a \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=-i \, a {\left (\frac {d \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{2} d f - 2 i \, c d^{2} f - d^{3} f} - \frac {\log \left (\tan \left (f x + e\right ) + i\right )}{c^{2} f - 2 i \, c d f - d^{2} f} + \frac {c - i \, d}{{\left (d \tan \left (f x + e\right ) + c\right )} {\left (i \, c + d\right )}^{2} f}\right )} \] Input:

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

Output:

-I*a*(d*log(abs(d*tan(f*x + e) + c))/(c^2*d*f - 2*I*c*d^2*f - d^3*f) - log 
(tan(f*x + e) + I)/(c^2*f - 2*I*c*d*f - d^2*f) + (c - I*d)/((d*tan(f*x + e 
) + c)*(I*c + d)^2*f))
 

Mupad [B] (verification not implemented)

Time = 2.26 (sec) , antiderivative size = 135, normalized size of antiderivative = 1.80 \[ \int \frac {a+i a \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=-\frac {2\,a\,\mathrm {atan}\left (\frac {\left (c^2+d^2\right )\,1{}\mathrm {i}}{{\left (d+c\,1{}\mathrm {i}\right )}^2}-\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (2\,c^4\,d^2+4\,c^2\,d^4+2\,d^6\right )}{{\left (d+c\,1{}\mathrm {i}\right )}^2\,\left (c^3\,d\,1{}\mathrm {i}-c^2\,d^2+c\,d^3\,1{}\mathrm {i}-d^4\right )}\right )}{f\,{\left (d+c\,1{}\mathrm {i}\right )}^2}+\frac {a\,1{}\mathrm {i}}{d\,f\,\left (\mathrm {tan}\left (e+f\,x\right )+\frac {c}{d}\right )\,\left (c-d\,1{}\mathrm {i}\right )} \] Input:

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

Output:

(a*1i)/(d*f*(tan(e + f*x) + c/d)*(c - d*1i)) - (2*a*atan(((c^2 + d^2)*1i)/ 
(c*1i + d)^2 - (tan(e + f*x)*(2*d^6 + 4*c^2*d^4 + 2*c^4*d^2))/((c*1i + d)^ 
2*(c*d^3*1i + c^3*d*1i - d^4 - c^2*d^2))))/(f*(c*1i + d)^2)
 

Reduce [B] (verification not implemented)

Time = 0.19 (sec) , antiderivative size = 438, normalized size of antiderivative = 5.84 \[ \int \frac {a+i a \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {a \left (\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) \tan \left (f x +e \right ) c^{3} d i -2 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) \tan \left (f x +e \right ) c^{2} d^{2}-\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) \tan \left (f x +e \right ) c \,d^{3} i +\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) c^{4} i -2 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) c^{3} d -\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) c^{2} d^{2} i -2 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) \tan \left (f x +e \right ) c^{3} d i +4 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) \tan \left (f x +e \right ) c^{2} d^{2}+2 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) \tan \left (f x +e \right ) c \,d^{3} i -2 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) c^{4} i +4 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) c^{3} d +2 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) c^{2} d^{2} i +2 \tan \left (f x +e \right ) c^{3} d f x -2 \tan \left (f x +e \right ) c^{3} d i +4 \tan \left (f x +e \right ) c^{2} d^{2} f i x +2 \tan \left (f x +e \right ) c^{2} d^{2}-2 \tan \left (f x +e \right ) c \,d^{3} f x -2 \tan \left (f x +e \right ) c \,d^{3} i +2 \tan \left (f x +e \right ) d^{4}+2 c^{4} f x +4 c^{3} d f i x -2 c^{2} d^{2} f x \right )}{2 c f \left (\tan \left (f x +e \right ) c^{4} d +2 \tan \left (f x +e \right ) c^{2} d^{3}+\tan \left (f x +e \right ) d^{5}+c^{5}+2 c^{3} d^{2}+c \,d^{4}\right )} \] Input:

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

Output:

(a*(log(tan(e + f*x)**2 + 1)*tan(e + f*x)*c**3*d*i - 2*log(tan(e + f*x)**2 
 + 1)*tan(e + f*x)*c**2*d**2 - log(tan(e + f*x)**2 + 1)*tan(e + f*x)*c*d** 
3*i + log(tan(e + f*x)**2 + 1)*c**4*i - 2*log(tan(e + f*x)**2 + 1)*c**3*d 
- log(tan(e + f*x)**2 + 1)*c**2*d**2*i - 2*log(tan(e + f*x)*d + c)*tan(e + 
 f*x)*c**3*d*i + 4*log(tan(e + f*x)*d + c)*tan(e + f*x)*c**2*d**2 + 2*log( 
tan(e + f*x)*d + c)*tan(e + f*x)*c*d**3*i - 2*log(tan(e + f*x)*d + c)*c**4 
*i + 4*log(tan(e + f*x)*d + c)*c**3*d + 2*log(tan(e + f*x)*d + c)*c**2*d** 
2*i + 2*tan(e + f*x)*c**3*d*f*x - 2*tan(e + f*x)*c**3*d*i + 4*tan(e + f*x) 
*c**2*d**2*f*i*x + 2*tan(e + f*x)*c**2*d**2 - 2*tan(e + f*x)*c*d**3*f*x - 
2*tan(e + f*x)*c*d**3*i + 2*tan(e + f*x)*d**4 + 2*c**4*f*x + 4*c**3*d*f*i* 
x - 2*c**2*d**2*f*x))/(2*c*f*(tan(e + f*x)*c**4*d + 2*tan(e + f*x)*c**2*d* 
*3 + tan(e + f*x)*d**5 + c**5 + 2*c**3*d**2 + c*d**4))