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

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 = 25, antiderivative size = 103 \[ \int \frac {(c+d \tan (e+f x))^2}{a+b \tan (e+f x)} \, dx=\frac {a (b c-a d)^2 x}{b^2 \left (a^2+b^2\right )}+\frac {d (2 b c-a d) x}{b^2}-\frac {d^2 \log (\cos (e+f x))}{b f}+\frac {(b c-a d)^2 \log (a \cos (e+f x)+b \sin (e+f x))}{b \left (a^2+b^2\right ) f} \] Output:

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

Mathematica [C] (verified)

Result contains complex when optimal does not.

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

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

Output:

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

Rubi [A] (verified)

Time = 0.49 (sec) , antiderivative size = 93, normalized size of antiderivative = 0.90, number of steps used = 7, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.280, Rules used = {3042, 4024, 3042, 3956, 3965, 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 {(c+d \tan (e+f x))^2}{a+b \tan (e+f x)} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4024

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3956

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

\(\Big \downarrow \) 3965

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4013

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

Input:

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

Output:

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

Defintions of rubi rules used

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 3965
Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Simp[a*(x/(a^ 
2 + b^2)), x] + Simp[b/(a^2 + b^2)   Int[(b - a*Tan[c + d*x])/(a + b*Tan[c 
+ d*x]), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[a^2 + b^2, 0]
 

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 4024
Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2/((a_.) + (b_.)*tan[(e_.) + (f 
_.)*(x_)]), x_Symbol] :> Simp[d*(2*b*c - a*d)*(x/b^2), x] + (Simp[d^2/b   I 
nt[Tan[e + f*x], x], x] + Simp[(b*c - a*d)^2/b^2   Int[1/(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]
 
Maple [A] (verified)

Time = 0.15 (sec) , antiderivative size = 117, normalized size of antiderivative = 1.14

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

Input:

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

Output:

1/f*((a^2*d^2-2*a*b*c*d+b^2*c^2)/(a^2+b^2)/b*ln(a+b*tan(f*x+e))+1/(a^2+b^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)*arct 
an(tan(f*x+e))))
 

Fricas [A] (verification not implemented)

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

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

Output:

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

Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

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

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

Output:

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

Maxima [A] (verification not implemented)

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

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

Output:

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

Giac [A] (verification not implemented)

Time = 0.18 (sec) , antiderivative size = 128, normalized size of antiderivative = 1.24 \[ \int \frac {(c+d \tan (e+f x))^2}{a+b \tan (e+f x)} \, dx=\frac {{\left (a c^{2} + 2 \, b c d - a d^{2}\right )} {\left (f x + e\right )}}{a^{2} f + b^{2} 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 (a^{2} f + b^{2} f\right )}} + \frac {{\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \log \left ({\left | b \tan \left (f x + e\right ) + a \right |}\right )}{a^{2} b f + b^{3} f} \] Input:

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

Output:

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

Mupad [B] (verification not implemented)

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

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

Output:

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

Reduce [B] (verification not implemented)

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

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

Output:

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