\(\int \frac {\cot (c+d x) (B \tan (c+d x)+C \tan ^2(c+d x))}{a+b \tan (c+d x)} \, dx\) [28]

Optimal result
Mathematica [A] (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 = 38, antiderivative size = 58 \[ \int \frac {\cot (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx=\frac {(a B+b C) x}{a^2+b^2}+\frac {(b B-a C) \log (a \cos (c+d x)+b \sin (c+d x))}{\left (a^2+b^2\right ) d} \] Output:

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

Mathematica [A] (verified)

Time = 0.09 (sec) , antiderivative size = 67, normalized size of antiderivative = 1.16 \[ \int \frac {\cot (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx=\frac {-2 (a B+b C) \arctan (\cot (c+d x))+(b B-a C) \left (2 \log (b+a \cot (c+d x))-\log \left (\csc ^2(c+d x)\right )\right )}{2 \left (a^2+b^2\right ) d} \] Input:

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

Output:

(-2*(a*B + b*C)*ArcTan[Cot[c + d*x]] + (b*B - a*C)*(2*Log[b + a*Cot[c + d* 
x]] - Log[Csc[c + d*x]^2]))/(2*(a^2 + b^2)*d)
 

Rubi [A] (verified)

Time = 0.76 (sec) , antiderivative size = 58, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.158, Rules used = {3042, 4115, 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 {\cot (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4115

\(\displaystyle \int \frac {B+C \tan (c+d x)}{a+b \tan (c+d x)}dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {B+C \tan (c+d x)}{a+b \tan (c+d x)}dx\)

\(\Big \downarrow \) 4014

\(\displaystyle \frac {(b B-a C) \int \frac {b-a \tan (c+d x)}{a+b \tan (c+d x)}dx}{a^2+b^2}+\frac {x (a B+b C)}{a^2+b^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {(b B-a C) \int \frac {b-a \tan (c+d x)}{a+b \tan (c+d x)}dx}{a^2+b^2}+\frac {x (a B+b C)}{a^2+b^2}\)

\(\Big \downarrow \) 4013

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

Input:

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

Output:

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

Defintions of rubi rules used

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

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]
 

rule 4115
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) 
+ (f_.)*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_ 
.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[1/b^2   Int[(a + b*Tan[e + f*x])^(m 
+ 1)*(c + d*Tan[e + f*x])^n*(b*B - a*C + b*C*Tan[e + f*x]), x], x] /; FreeQ 
[{a, b, c, d, e, f, A, B, C, m, n}, x] && NeQ[b*c - a*d, 0] && EqQ[A*b^2 - 
a*b*B + a^2*C, 0]
 
Maple [A] (verified)

Time = 0.14 (sec) , antiderivative size = 62, normalized size of antiderivative = 1.07

method result size
parallelrisch \(\frac {2 B a d x +2 C b d x +\left (-\ln \left (\sec \left (d x +c \right )^{2}\right )+2 \ln \left (a +b \tan \left (d x +c \right )\right )\right ) \left (B b -C a \right )}{2 d \left (a^{2}+b^{2}\right )}\) \(62\)
derivativedivides \(\frac {\frac {\left (B b -C a \right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{a^{2}+b^{2}}+\frac {\frac {\left (-B b +C a \right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (B a +C b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{a^{2}+b^{2}}}{d}\) \(82\)
default \(\frac {\frac {\left (B b -C a \right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{a^{2}+b^{2}}+\frac {\frac {\left (-B b +C a \right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (B a +C b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{a^{2}+b^{2}}}{d}\) \(82\)
norman \(\frac {\left (B a +C b \right ) x}{a^{2}+b^{2}}+\frac {\left (B b -C a \right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{d \left (a^{2}+b^{2}\right )}-\frac {\left (B b -C a \right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d \left (a^{2}+b^{2}\right )}\) \(85\)
risch \(-\frac {x B}{i b -a}+\frac {i x C}{i b -a}-\frac {2 i B b x}{a^{2}+b^{2}}+\frac {2 i C a x}{a^{2}+b^{2}}-\frac {2 i B b c}{d \left (a^{2}+b^{2}\right )}+\frac {2 i C a c}{d \left (a^{2}+b^{2}\right )}+\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) B b}{d \left (a^{2}+b^{2}\right )}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) C a}{d \left (a^{2}+b^{2}\right )}\) \(186\)

Input:

int(cot(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c)),x,method=_RE 
TURNVERBOSE)
 

Output:

1/2/d/(a^2+b^2)*(2*B*a*d*x+2*C*b*d*x+(-ln(sec(d*x+c)^2)+2*ln(a+b*tan(d*x+c 
)))*(B*b-C*a))
 

Fricas [A] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.31 \[ \int \frac {\cot (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx=\frac {2 \, {\left (B a + C b\right )} d x - {\left (C a - B b\right )} \log \left (\frac {b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right )}{2 \, {\left (a^{2} + b^{2}\right )} d} \] Input:

integrate(cot(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c)),x, alg 
orithm="fricas")
 

Output:

1/2*(2*(B*a + C*b)*d*x - (C*a - B*b)*log((b^2*tan(d*x + c)^2 + 2*a*b*tan(d 
*x + c) + a^2)/(tan(d*x + c)^2 + 1)))/((a^2 + b^2)*d)
 

Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 1.26 (sec) , antiderivative size = 541, normalized size of antiderivative = 9.33 \[ \int \frac {\cot (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx=\begin {cases} \frac {\tilde {\infty } x \left (B \tan {\left (c \right )} + C \tan ^{2}{\left (c \right )}\right ) \cot {\left (c \right )}}{\tan {\left (c \right )}} & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {B x + \frac {C \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d}}{a} & \text {for}\: b = 0 \\\frac {i B d x \tan {\left (c + d x \right )}}{2 b d \tan {\left (c + d x \right )} - 2 i b d} + \frac {B d x}{2 b d \tan {\left (c + d x \right )} - 2 i b d} + \frac {i B}{2 b d \tan {\left (c + d x \right )} - 2 i b d} + \frac {C d x \tan {\left (c + d x \right )}}{2 b d \tan {\left (c + d x \right )} - 2 i b d} - \frac {i C d x}{2 b d \tan {\left (c + d x \right )} - 2 i b d} - \frac {C}{2 b d \tan {\left (c + d x \right )} - 2 i b d} & \text {for}\: a = - i b \\- \frac {i B d x \tan {\left (c + d x \right )}}{2 b d \tan {\left (c + d x \right )} + 2 i b d} + \frac {B d x}{2 b d \tan {\left (c + d x \right )} + 2 i b d} - \frac {i B}{2 b d \tan {\left (c + d x \right )} + 2 i b d} + \frac {C d x \tan {\left (c + d x \right )}}{2 b d \tan {\left (c + d x \right )} + 2 i b d} + \frac {i C d x}{2 b d \tan {\left (c + d x \right )} + 2 i b d} - \frac {C}{2 b d \tan {\left (c + d x \right )} + 2 i b d} & \text {for}\: a = i b \\\frac {x \left (B \tan {\left (c \right )} + C \tan ^{2}{\left (c \right )}\right ) \cot {\left (c \right )}}{a + b \tan {\left (c \right )}} & \text {for}\: d = 0 \\\frac {2 B a d x}{2 a^{2} d + 2 b^{2} d} + \frac {2 B b \log {\left (\frac {a}{b} + \tan {\left (c + d x \right )} \right )}}{2 a^{2} d + 2 b^{2} d} - \frac {B b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 a^{2} d + 2 b^{2} d} - \frac {2 C a \log {\left (\frac {a}{b} + \tan {\left (c + d x \right )} \right )}}{2 a^{2} d + 2 b^{2} d} + \frac {C a \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 a^{2} d + 2 b^{2} d} + \frac {2 C b d x}{2 a^{2} d + 2 b^{2} d} & \text {otherwise} \end {cases} \] Input:

integrate(cot(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)**2)/(a+b*tan(d*x+c)),x)
 

Output:

Piecewise((zoo*x*(B*tan(c) + C*tan(c)**2)*cot(c)/tan(c), Eq(a, 0) & Eq(b, 
0) & Eq(d, 0)), ((B*x + C*log(tan(c + d*x)**2 + 1)/(2*d))/a, Eq(b, 0)), (I 
*B*d*x*tan(c + d*x)/(2*b*d*tan(c + d*x) - 2*I*b*d) + B*d*x/(2*b*d*tan(c + 
d*x) - 2*I*b*d) + I*B/(2*b*d*tan(c + d*x) - 2*I*b*d) + C*d*x*tan(c + d*x)/ 
(2*b*d*tan(c + d*x) - 2*I*b*d) - I*C*d*x/(2*b*d*tan(c + d*x) - 2*I*b*d) - 
C/(2*b*d*tan(c + d*x) - 2*I*b*d), Eq(a, -I*b)), (-I*B*d*x*tan(c + d*x)/(2* 
b*d*tan(c + d*x) + 2*I*b*d) + B*d*x/(2*b*d*tan(c + d*x) + 2*I*b*d) - I*B/( 
2*b*d*tan(c + d*x) + 2*I*b*d) + C*d*x*tan(c + d*x)/(2*b*d*tan(c + d*x) + 2 
*I*b*d) + I*C*d*x/(2*b*d*tan(c + d*x) + 2*I*b*d) - C/(2*b*d*tan(c + d*x) + 
 2*I*b*d), Eq(a, I*b)), (x*(B*tan(c) + C*tan(c)**2)*cot(c)/(a + b*tan(c)), 
 Eq(d, 0)), (2*B*a*d*x/(2*a**2*d + 2*b**2*d) + 2*B*b*log(a/b + tan(c + d*x 
))/(2*a**2*d + 2*b**2*d) - B*b*log(tan(c + d*x)**2 + 1)/(2*a**2*d + 2*b**2 
*d) - 2*C*a*log(a/b + tan(c + d*x))/(2*a**2*d + 2*b**2*d) + C*a*log(tan(c 
+ d*x)**2 + 1)/(2*a**2*d + 2*b**2*d) + 2*C*b*d*x/(2*a**2*d + 2*b**2*d), Tr 
ue))
 

Maxima [A] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 88, normalized size of antiderivative = 1.52 \[ \int \frac {\cot (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx=\frac {\frac {2 \, {\left (B a + C b\right )} {\left (d x + c\right )}}{a^{2} + b^{2}} - \frac {2 \, {\left (C a - B b\right )} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{2} + b^{2}} + \frac {{\left (C a - B b\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{2} + b^{2}}}{2 \, d} \] Input:

integrate(cot(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c)),x, alg 
orithm="maxima")
 

Output:

1/2*(2*(B*a + C*b)*(d*x + c)/(a^2 + b^2) - 2*(C*a - B*b)*log(b*tan(d*x + c 
) + a)/(a^2 + b^2) + (C*a - B*b)*log(tan(d*x + c)^2 + 1)/(a^2 + b^2))/d
 

Giac [A] (verification not implemented)

Time = 0.51 (sec) , antiderivative size = 100, normalized size of antiderivative = 1.72 \[ \int \frac {\cot (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx=\frac {{\left (B a + C b\right )} {\left (d x + c\right )}}{a^{2} d + b^{2} d} + \frac {{\left (C a - B b\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{2 \, {\left (a^{2} d + b^{2} d\right )}} - \frac {{\left (C a b - B b^{2}\right )} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{2} b d + b^{3} d} \] Input:

integrate(cot(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c)),x, alg 
orithm="giac")
 

Output:

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

Mupad [B] (verification not implemented)

Time = 5.62 (sec) , antiderivative size = 93, normalized size of antiderivative = 1.60 \[ \int \frac {\cot (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx=\frac {\ln \left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )\,\left (B\,b-C\,a\right )}{d\,\left (a^2+b^2\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B-C\,1{}\mathrm {i}\right )}{2\,d\,\left (b+a\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (-C+B\,1{}\mathrm {i}\right )}{2\,d\,\left (a+b\,1{}\mathrm {i}\right )} \] Input:

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

Output:

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

Reduce [B] (verification not implemented)

Time = 0.26 (sec) , antiderivative size = 128, normalized size of antiderivative = 2.21 \[ \int \frac {\cot (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx=\frac {\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}+1\right ) a c -\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}+1\right ) b^{2}-\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 \tan \left (\frac {d x}{2}+\frac {c}{2}\right ) b -a \right ) a c +\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 \tan \left (\frac {d x}{2}+\frac {c}{2}\right ) b -a \right ) b^{2}+a b d x +b c d x}{d \left (a^{2}+b^{2}\right )} \] Input:

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

Output:

(log(tan((c + d*x)/2)**2 + 1)*a*c - log(tan((c + d*x)/2)**2 + 1)*b**2 - lo 
g(tan((c + d*x)/2)**2*a - 2*tan((c + d*x)/2)*b - a)*a*c + log(tan((c + d*x 
)/2)**2*a - 2*tan((c + d*x)/2)*b - a)*b**2 + a*b*d*x + b*c*d*x)/(d*(a**2 + 
 b**2))