\(\int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx\) [128]

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

Optimal result

Integrand size = 28, antiderivative size = 75 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\frac {\frac {1}{a}+\frac {a}{b^2}}{d (b+a \cot (c+d x))}-\frac {2 a \log (b+a \cot (c+d x))}{b^3 d}-\frac {2 a \log (\tan (c+d x))}{b^3 d}+\frac {\tan (c+d x)}{b^2 d} \] Output:

(1/a+a/b^2)/d/(b+a*cot(d*x+c))-2*a*ln(b+a*cot(d*x+c))/b^3/d-2*a*ln(tan(d*x 
+c))/b^3/d+tan(d*x+c)/b^2/d
 

Mathematica [A] (verified)

Time = 0.19 (sec) , antiderivative size = 51, normalized size of antiderivative = 0.68 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\frac {-2 a \log (a+b \tan (c+d x))+b \tan (c+d x)-\frac {a^2+b^2}{a+b \tan (c+d x)}}{b^3 d} \] Input:

Integrate[Sec[c + d*x]^2/(a*Cos[c + d*x] + b*Sin[c + d*x])^2,x]
 

Output:

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

Rubi [A] (verified)

Time = 0.29 (sec) , antiderivative size = 70, normalized size of antiderivative = 0.93, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3042, 3567, 522, 2009}

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 {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {1}{\cos (c+d x)^2 (a \cos (c+d x)+b \sin (c+d x))^2}dx\)

\(\Big \downarrow \) 3567

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

\(\Big \downarrow \) 522

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

\(\Big \downarrow \) 2009

\(\displaystyle -\frac {-\frac {2 a \log (\cot (c+d x))}{b^3}+\frac {2 a \log (a \cot (c+d x)+b)}{b^3}-\frac {\frac {a}{b^2}+\frac {1}{a}}{a \cot (c+d x)+b}-\frac {\tan (c+d x)}{b^2}}{d}\)

Input:

Int[Sec[c + d*x]^2/(a*Cos[c + d*x] + b*Sin[c + d*x])^2,x]
 

Output:

-((-((a^(-1) + a/b^2)/(b + a*Cot[c + d*x])) - (2*a*Log[Cot[c + d*x]])/b^3 
+ (2*a*Log[b + a*Cot[c + d*x]])/b^3 - Tan[c + d*x]/b^2)/d)
 

Defintions of rubi rules used

rule 522
Int[((e_.)*(x_))^(m_.)*((c_) + (d_.)*(x_))^(n_.)*((a_) + (b_.)*(x_)^2)^(p_. 
), x_Symbol] :> Int[ExpandIntegrand[(e*x)^m*(c + d*x)^n*(a + b*x^2)^p, x], 
x] /; FreeQ[{a, b, c, d, e, m, n}, x] && IGtQ[p, 0]
 

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

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

rule 3567
Int[cos[(c_.) + (d_.)*(x_)]^(m_.)*(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*si 
n[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[-d^(-1)   Subst[Int[x^m*((b 
+ a*x)^n/(1 + x^2)^((m + n + 2)/2)), x], x, Cot[c + d*x]], x] /; FreeQ[{a, 
b, c, d}, x] && IntegerQ[n] && IntegerQ[(m + n)/2] && NeQ[n, -1] &&  !(GtQ[ 
n, 0] && GtQ[m, 1])
 
Maple [A] (verified)

Time = 0.77 (sec) , antiderivative size = 57, normalized size of antiderivative = 0.76

method result size
derivativedivides \(\frac {\frac {\tan \left (d x +c \right )}{b^{2}}-\frac {a^{2}+b^{2}}{b^{3} \left (a +b \tan \left (d x +c \right )\right )}-\frac {2 a \ln \left (a +b \tan \left (d x +c \right )\right )}{b^{3}}}{d}\) \(57\)
default \(\frac {\frac {\tan \left (d x +c \right )}{b^{2}}-\frac {a^{2}+b^{2}}{b^{3} \left (a +b \tan \left (d x +c \right )\right )}-\frac {2 a \ln \left (a +b \tan \left (d x +c \right )\right )}{b^{3}}}{d}\) \(57\)
risch \(-\frac {4 i \left (-i a \,{\mathrm e}^{2 i \left (d x +c \right )}+b -i a \right )}{\left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) \left (b \,{\mathrm e}^{2 i \left (d x +c \right )}+i a \,{\mathrm e}^{2 i \left (d x +c \right )}-b +i a \right ) b^{2} d}+\frac {2 a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{b^{3} d}-\frac {2 a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right )}{b^{3} d}\) \(136\)
parallelrisch \(\frac {-2 a \left (a \cos \left (2 d x +2 c \right )+a +b \sin \left (2 d x +2 c \right )\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-a \right )+2 a \left (a \cos \left (2 d x +2 c \right )+a +b \sin \left (2 d x +2 c \right )\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )+2 a \left (a \cos \left (2 d x +2 c \right )+a +b \sin \left (2 d x +2 c \right )\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )+\left (-2 a^{2}-2 b^{2}\right ) \cos \left (2 d x +2 c \right )-2 a^{2}}{b^{3} d \left (a \cos \left (2 d x +2 c \right )+a +b \sin \left (2 d x +2 c \right )\right )}\) \(196\)
norman \(\frac {\frac {\left (4 a^{2}+6 b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}}{b^{3} d}-\frac {4 a^{2}+2 b^{2}}{2 b^{3} d}-\frac {\left (4 a^{2}+2 b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{4}}{2 b^{3} d}}{\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right ) \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-a \right )}+\frac {2 a \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{b^{3} d}+\frac {2 a \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{b^{3} d}-\frac {2 a \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-a \right )}{b^{3} d}\) \(209\)

Input:

int(sec(d*x+c)^2/(a*cos(d*x+c)+b*sin(d*x+c))^2,x,method=_RETURNVERBOSE)
 

Output:

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 178 vs. \(2 (75) = 150\).

Time = 0.09 (sec) , antiderivative size = 178, normalized size of antiderivative = 2.37 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {2 \, b^{2} \cos \left (d x + c\right )^{2} - 2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) - b^{2} + {\left (a^{2} \cos \left (d x + c\right )^{2} + a b \cos \left (d x + c\right ) \sin \left (d x + c\right )\right )} \log \left (2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + b^{2}\right ) - {\left (a^{2} \cos \left (d x + c\right )^{2} + a b \cos \left (d x + c\right ) \sin \left (d x + c\right )\right )} \log \left (\cos \left (d x + c\right )^{2}\right )}{a b^{3} d \cos \left (d x + c\right )^{2} + b^{4} d \cos \left (d x + c\right ) \sin \left (d x + c\right )} \] Input:

integrate(sec(d*x+c)^2/(a*cos(d*x+c)+b*sin(d*x+c))^2,x, algorithm="fricas" 
)
 

Output:

-(2*b^2*cos(d*x + c)^2 - 2*a*b*cos(d*x + c)*sin(d*x + c) - b^2 + (a^2*cos( 
d*x + c)^2 + a*b*cos(d*x + c)*sin(d*x + c))*log(2*a*b*cos(d*x + c)*sin(d*x 
 + c) + (a^2 - b^2)*cos(d*x + c)^2 + b^2) - (a^2*cos(d*x + c)^2 + a*b*cos( 
d*x + c)*sin(d*x + c))*log(cos(d*x + c)^2))/(a*b^3*d*cos(d*x + c)^2 + b^4* 
d*cos(d*x + c)*sin(d*x + c))
 

Sympy [F]

\[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\int \frac {\sec ^{2}{\left (c + d x \right )}}{\left (a \cos {\left (c + d x \right )} + b \sin {\left (c + d x \right )}\right )^{2}}\, dx \] Input:

integrate(sec(d*x+c)**2/(a*cos(d*x+c)+b*sin(d*x+c))**2,x)
 

Output:

Integral(sec(c + d*x)**2/(a*cos(c + d*x) + b*sin(c + d*x))**2, x)
 

Maxima [A] (verification not implemented)

Time = 0.03 (sec) , antiderivative size = 60, normalized size of antiderivative = 0.80 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {\frac {a^{2} + b^{2}}{b^{4} \tan \left (d x + c\right ) + a b^{3}} + \frac {2 \, a \log \left (b \tan \left (d x + c\right ) + a\right )}{b^{3}} - \frac {\tan \left (d x + c\right )}{b^{2}}}{d} \] Input:

integrate(sec(d*x+c)^2/(a*cos(d*x+c)+b*sin(d*x+c))^2,x, algorithm="maxima" 
)
 

Output:

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

Giac [A] (verification not implemented)

Time = 0.14 (sec) , antiderivative size = 71, normalized size of antiderivative = 0.95 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {\frac {2 \, a \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{b^{3}} - \frac {\tan \left (d x + c\right )}{b^{2}} - \frac {2 \, a b \tan \left (d x + c\right ) + a^{2} - b^{2}}{{\left (b \tan \left (d x + c\right ) + a\right )} b^{3}}}{d} \] Input:

integrate(sec(d*x+c)^2/(a*cos(d*x+c)+b*sin(d*x+c))^2,x, algorithm="giac")
 

Output:

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

Mupad [B] (verification not implemented)

Time = 19.05 (sec) , antiderivative size = 382, normalized size of antiderivative = 5.09 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\frac {\frac {4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{b}-\frac {2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3\,\left (2\,a^2+b^2\right )}{a\,b^2}+\frac {2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (2\,a^2+b^2\right )}{a\,b^2}}{d\,\left (a\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4-2\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3-2\,a\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+2\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )+a\right )}-\frac {4\,a\,\mathrm {atanh}\left (\frac {64\,a^3\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{64\,a^3-64\,a^3\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+\frac {128\,a^5}{b^2}-\frac {128\,a^5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{b^2}+\frac {128\,a^4\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{b}}-\frac {64\,a^3}{64\,a^3-64\,a^3\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+\frac {128\,a^5}{b^2}-\frac {128\,a^5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{b^2}+\frac {128\,a^4\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{b}}+\frac {128\,a^4\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{64\,a^3\,b+\frac {128\,a^5}{b}+128\,a^4\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )-\frac {128\,a^5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{b}-64\,a^3\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}\right )}{b^3\,d} \] Input:

int(1/(cos(c + d*x)^2*(a*cos(c + d*x) + b*sin(c + d*x))^2),x)
 

Output:

((4*tan(c/2 + (d*x)/2)^2)/b - (2*tan(c/2 + (d*x)/2)^3*(2*a^2 + b^2))/(a*b^ 
2) + (2*tan(c/2 + (d*x)/2)*(2*a^2 + b^2))/(a*b^2))/(d*(a + 2*b*tan(c/2 + ( 
d*x)/2) - 2*a*tan(c/2 + (d*x)/2)^2 + a*tan(c/2 + (d*x)/2)^4 - 2*b*tan(c/2 
+ (d*x)/2)^3)) - (4*a*atanh((64*a^3*tan(c/2 + (d*x)/2)^2)/(64*a^3 - 64*a^3 
*tan(c/2 + (d*x)/2)^2 + (128*a^5)/b^2 - (128*a^5*tan(c/2 + (d*x)/2)^2)/b^2 
 + (128*a^4*tan(c/2 + (d*x)/2))/b) - (64*a^3)/(64*a^3 - 64*a^3*tan(c/2 + ( 
d*x)/2)^2 + (128*a^5)/b^2 - (128*a^5*tan(c/2 + (d*x)/2)^2)/b^2 + (128*a^4* 
tan(c/2 + (d*x)/2))/b) + (128*a^4*tan(c/2 + (d*x)/2))/(64*a^3*b + (128*a^5 
)/b + 128*a^4*tan(c/2 + (d*x)/2) - (128*a^5*tan(c/2 + (d*x)/2)^2)/b - 64*a 
^3*b*tan(c/2 + (d*x)/2)^2)))/(b^3*d)
 

Reduce [B] (verification not implemented)

Time = 0.21 (sec) , antiderivative size = 337, normalized size of antiderivative = 4.49 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\frac {2 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) \sin \left (d x +c \right ) a b +2 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) \sin \left (d x +c \right ) a b -2 \cos \left (d x +c \right ) \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 ) \sin \left (d x +c \right ) a b -2 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) \sin \left (d x +c \right )^{2} a^{2}+2 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) a^{2}-2 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) \sin \left (d x +c \right )^{2} a^{2}+2 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) a^{2}+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 ) \sin \left (d x +c \right )^{2} a^{2}-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^{2}+2 \sin \left (d x +c \right )^{2} a^{2}+2 \sin \left (d x +c \right )^{2} b^{2}-2 a^{2}-b^{2}}{b^{3} d \left (\cos \left (d x +c \right ) \sin \left (d x +c \right ) b -\sin \left (d x +c \right )^{2} a +a \right )} \] Input:

int(sec(d*x+c)^2/(a*cos(d*x+c)+b*sin(d*x+c))^2,x)
 

Output:

(2*cos(c + d*x)*log(tan((c + d*x)/2) - 1)*sin(c + d*x)*a*b + 2*cos(c + d*x 
)*log(tan((c + d*x)/2) + 1)*sin(c + d*x)*a*b - 2*cos(c + d*x)*log(tan((c + 
 d*x)/2)**2*a - 2*tan((c + d*x)/2)*b - a)*sin(c + d*x)*a*b - 2*log(tan((c 
+ d*x)/2) - 1)*sin(c + d*x)**2*a**2 + 2*log(tan((c + d*x)/2) - 1)*a**2 - 2 
*log(tan((c + d*x)/2) + 1)*sin(c + d*x)**2*a**2 + 2*log(tan((c + d*x)/2) + 
 1)*a**2 + 2*log(tan((c + d*x)/2)**2*a - 2*tan((c + d*x)/2)*b - a)*sin(c + 
 d*x)**2*a**2 - 2*log(tan((c + d*x)/2)**2*a - 2*tan((c + d*x)/2)*b - a)*a* 
*2 + 2*sin(c + d*x)**2*a**2 + 2*sin(c + d*x)**2*b**2 - 2*a**2 - b**2)/(b** 
3*d*(cos(c + d*x)*sin(c + d*x)*b - sin(c + d*x)**2*a + a))