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

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

Optimal result

Integrand size = 23, antiderivative size = 111 \[ \int \frac {a+b \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {\left (2 b c d+a \left (c^2-d^2\right )\right ) x}{\left (c^2+d^2\right )^2}+\frac {\left (2 a c d-b \left (c^2-d^2\right )\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{\left (c^2+d^2\right )^2 f}+\frac {b c-a d}{\left (c^2+d^2\right ) f (c+d \tan (e+f x))} \] Output:

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

Mathematica [C] (verified)

Result contains complex when optimal does not.

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

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

Output:

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

Rubi [A] (verified)

Time = 0.54 (sec) , antiderivative size = 122, normalized size of antiderivative = 1.10, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.261, 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+b \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4012

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4014

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4013

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

Input:

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

Output:

(((2*b*c*d + a*(c^2 - d^2))*x)/(c^2 + d^2) + ((2*a*c*d - b*(c^2 - d^2))*Lo 
g[c*Cos[e + f*x] + d*Sin[e + f*x]])/((c^2 + d^2)*f))/(c^2 + d^2) + (b*c - 
a*d)/((c^2 + d^2)*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.16 (sec) , antiderivative size = 141, normalized size of antiderivative = 1.27

method result size
derivativedivides \(\frac {\frac {\frac {\left (-2 a c d +b \,c^{2}-b \,d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (a \,c^{2}-a \,d^{2}+2 b c d \right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}-\frac {a d -b c}{\left (c^{2}+d^{2}\right ) \left (c +d \tan \left (f x +e \right )\right )}+\frac {\left (2 a c d -b \,c^{2}+b \,d^{2}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}}{f}\) \(141\)
default \(\frac {\frac {\frac {\left (-2 a c d +b \,c^{2}-b \,d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (a \,c^{2}-a \,d^{2}+2 b c d \right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}-\frac {a d -b c}{\left (c^{2}+d^{2}\right ) \left (c +d \tan \left (f x +e \right )\right )}+\frac {\left (2 a c d -b \,c^{2}+b \,d^{2}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}}{f}\) \(141\)
norman \(\frac {\frac {c \left (a \,c^{2}-a \,d^{2}+2 b c d \right ) x}{c^{4}+2 c^{2} d^{2}+d^{4}}+\frac {d \left (a \,c^{2}-a \,d^{2}+2 b c d \right ) x \tan \left (f x +e \right )}{c^{4}+2 c^{2} d^{2}+d^{4}}+\frac {\left (a d -b c \right ) d \tan \left (f x +e \right )}{c f \left (c^{2}+d^{2}\right )}}{c +d \tan \left (f x +e \right )}+\frac {\left (2 a c d -b \,c^{2}+b \,d^{2}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {\left (2 a c d -b \,c^{2}+b \,d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}\) \(226\)
parallelrisch \(-\frac {2 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) a \,c^{2} d^{2}-\ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) b \,c^{3} d +\ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) b c \,d^{3}-4 \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a \,c^{2} d^{2}+2 \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) b \,c^{3} d -2 \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) b c \,d^{3}+2 x a \,c^{2} d^{2} f -4 x b \,c^{3} d f -2 x \tan \left (f x +e \right ) a \,c^{3} d f +2 x \tan \left (f x +e \right ) a c \,d^{3} f -4 x \tan \left (f x +e \right ) b \,c^{2} d^{2} f -2 x a \,c^{4} f -2 \tan \left (f x +e \right ) a \,c^{2} d^{2}+2 \tan \left (f x +e \right ) b \,c^{3} d +2 \tan \left (f x +e \right ) b c \,d^{3}+2 \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a \,c^{3} d +\ln \left (1+\tan \left (f x +e \right )^{2}\right ) b \,c^{2} d^{2}-4 \ln \left (c +d \tan \left (f x +e \right )\right ) a \,c^{3} d -2 \ln \left (c +d \tan \left (f x +e \right )\right ) b \,c^{2} d^{2}-2 \tan \left (f x +e \right ) a \,d^{4}+2 \ln \left (c +d \tan \left (f x +e \right )\right ) b \,c^{4}-\ln \left (1+\tan \left (f x +e \right )^{2}\right ) b \,c^{4}}{2 \left (c +d \tan \left (f x +e \right )\right ) \left (c^{2}+d^{2}\right )^{2} c f}\) \(415\)
risch \(\frac {i x b}{2 i c d -c^{2}+d^{2}}-\frac {a x}{2 i c d -c^{2}+d^{2}}-\frac {4 i a c d x}{c^{4}+2 c^{2} d^{2}+d^{4}}+\frac {2 i b \,c^{2} x}{c^{4}+2 c^{2} d^{2}+d^{4}}-\frac {2 i b \,d^{2} x}{c^{4}+2 c^{2} d^{2}+d^{4}}-\frac {4 i a c d e}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}+\frac {2 i b \,c^{2} e}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {2 i b \,d^{2} e}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {2 i d^{2} a}{\left (-i c +d \right ) 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 {2 i d b c}{\left (-i c +d \right ) 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 {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) a c d}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) b \,c^{2}}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) b \,d^{2}}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}\) \(482\)

Input:

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

Output:

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

Fricas [A] (verification not implemented)

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

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

Output:

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

Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 0.83 (sec) , antiderivative size = 2878, normalized size of antiderivative = 25.93 \[ \int \frac {a+b \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\text {Too large to display} \] Input:

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

Output:

Piecewise((zoo*x*(a + b*tan(e))/tan(e)**2, Eq(c, 0) & Eq(d, 0) & Eq(f, 0)) 
, ((a*x + b*log(tan(e + f*x)**2 + 1)/(2*f))/c**2, Eq(d, 0)), (-a*f*x*tan(e 
 + f*x)**2/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) 
 + 2*I*a*f*x*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f 
*x) - 4*d**2*f) + a*f*x/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x 
) - 4*d**2*f) - a*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan( 
e + f*x) - 4*d**2*f) + 2*I*a/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e 
+ f*x) - 4*d**2*f) + I*b*f*x*tan(e + f*x)**2/(4*d**2*f*tan(e + f*x)**2 - 8 
*I*d**2*f*tan(e + f*x) - 4*d**2*f) + 2*b*f*x*tan(e + f*x)/(4*d**2*f*tan(e 
+ f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) - I*b*f*x/(4*d**2*f*tan(e 
+ f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + I*b*tan(e + f*x)/(4*d**2 
*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f), Eq(c, -I*d)), (- 
a*f*x*tan(e + f*x)**2/(4*d**2*f*tan(e + f*x)**2 + 8*I*d**2*f*tan(e + f*x) 
- 4*d**2*f) - 2*I*a*f*x*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 + 8*I*d**2* 
f*tan(e + f*x) - 4*d**2*f) + a*f*x/(4*d**2*f*tan(e + f*x)**2 + 8*I*d**2*f* 
tan(e + f*x) - 4*d**2*f) - a*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 + 8*I* 
d**2*f*tan(e + f*x) - 4*d**2*f) - 2*I*a/(4*d**2*f*tan(e + f*x)**2 + 8*I*d* 
*2*f*tan(e + f*x) - 4*d**2*f) - I*b*f*x*tan(e + f*x)**2/(4*d**2*f*tan(e + 
f*x)**2 + 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + 2*b*f*x*tan(e + f*x)/(4*d* 
*2*f*tan(e + f*x)**2 + 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + I*b*f*x/(4...
 

Maxima [A] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 177, normalized size of antiderivative = 1.59 \[ \int \frac {a+b \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {\frac {2 \, {\left (a c^{2} + 2 \, b c d - a d^{2}\right )} {\left (f x + e\right )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac {2 \, {\left (b c^{2} - 2 \, a c d - b 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 (b c^{2} - 2 \, a c d - b 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 (b 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+b*tan(f*x+e))/(c+d*tan(f*x+e))^2,x, algorithm="maxima")
 

Output:

1/2*(2*(a*c^2 + 2*b*c*d - a*d^2)*(f*x + e)/(c^4 + 2*c^2*d^2 + d^4) - 2*(b* 
c^2 - 2*a*c*d - b*d^2)*log(d*tan(f*x + e) + c)/(c^4 + 2*c^2*d^2 + d^4) + ( 
b*c^2 - 2*a*c*d - b*d^2)*log(tan(f*x + e)^2 + 1)/(c^4 + 2*c^2*d^2 + d^4) + 
 2*(b*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.23 (sec) , antiderivative size = 205, normalized size of antiderivative = 1.85 \[ \int \frac {a+b \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {{\left (a c^{2} + 2 \, b c d - a d^{2}\right )} {\left (f x + e\right )}}{c^{4} f + 2 \, c^{2} d^{2} f + d^{4} f} + \frac {{\left (b c^{2} - 2 \, a c d - b d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{2 \, {\left (c^{4} f + 2 \, c^{2} d^{2} f + d^{4} f\right )}} - \frac {{\left (b c^{2} d - 2 \, a c d^{2} - b d^{3}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{4} d f + 2 \, c^{2} d^{3} f + d^{5} f} + \frac {b c^{3} - a c^{2} d + b c d^{2} - a d^{3}}{{\left (c^{2} + d^{2}\right )}^{2} {\left (d \tan \left (f x + e\right ) + c\right )} f} \] Input:

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

Output:

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

Mupad [B] (verification not implemented)

Time = 2.53 (sec) , antiderivative size = 153, normalized size of antiderivative = 1.38 \[ \int \frac {a+b \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {\ln \left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (-b\,c^2+2\,a\,c\,d+b\,d^2\right )}{f\,{\left (c^2+d^2\right )}^2}-\frac {a\,d-b\,c}{f\,\left (c^2+d^2\right )\,\left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (b+a\,1{}\mathrm {i}\right )}{2\,f\,\left (-c^2+c\,d\,2{}\mathrm {i}+d^2\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (a+b\,1{}\mathrm {i}\right )}{2\,f\,\left (-c^2\,1{}\mathrm {i}+2\,c\,d+d^2\,1{}\mathrm {i}\right )} \] Input:

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

Output:

(log(c + d*tan(e + f*x))*(b*d^2 - b*c^2 + 2*a*c*d))/(f*(c^2 + d^2)^2) - (a 
*d - b*c)/(f*(c^2 + d^2)*(c + d*tan(e + f*x))) - (log(tan(e + f*x) + 1i)*( 
a*1i + b))/(2*f*(c*d*2i - c^2 + d^2)) - (log(tan(e + f*x) - 1i)*(a + b*1i) 
)/(2*f*(2*c*d - c^2*1i + d^2*1i))
 

Reduce [B] (verification not implemented)

Time = 0.21 (sec) , antiderivative size = 447, normalized size of antiderivative = 4.03 \[ \int \frac {a+b \tan (e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {-2 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) \tan \left (f x +e \right ) a \,c^{2} d^{2}+\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) \tan \left (f x +e \right ) b \,c^{3} d -\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) \tan \left (f x +e \right ) b c \,d^{3}-2 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a \,c^{3} d +\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) b \,c^{4}-\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) b \,c^{2} d^{2}+4 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) \tan \left (f x +e \right ) a \,c^{2} d^{2}-2 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) \tan \left (f x +e \right ) b \,c^{3} d +2 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) \tan \left (f x +e \right ) b c \,d^{3}+4 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) a \,c^{3} d -2 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) b \,c^{4}+2 \,\mathrm {log}\left (d \tan \left (f x +e \right )+c \right ) b \,c^{2} d^{2}+2 \tan \left (f x +e \right ) a \,c^{3} d f x +2 \tan \left (f x +e \right ) a \,c^{2} d^{2}-2 \tan \left (f x +e \right ) a c \,d^{3} f x +2 \tan \left (f x +e \right ) a \,d^{4}-2 \tan \left (f x +e \right ) b \,c^{3} d +4 \tan \left (f x +e \right ) b \,c^{2} d^{2} f x -2 \tan \left (f x +e \right ) b c \,d^{3}+2 a \,c^{4} f x -2 a \,c^{2} d^{2} f x +4 b \,c^{3} d f x}{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+b*tan(f*x+e))/(c+d*tan(f*x+e))^2,x)
 

Output:

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