\(\int \frac {(A+B \cos (c+d x)+C \cos ^2(c+d x)) \sec (c+d x)}{(a+a \cos (c+d x))^2} \, dx\) [351]

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

Optimal result

Integrand size = 39, antiderivative size = 83 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x)}{(a+a \cos (c+d x))^2} \, dx=\frac {A \text {arctanh}(\sin (c+d x))}{a^2 d}-\frac {(4 A-B-2 C) \sin (c+d x)}{3 a^2 d (1+\cos (c+d x))}-\frac {(A-B+C) \sin (c+d x)}{3 d (a+a \cos (c+d x))^2} \] Output:

A*arctanh(sin(d*x+c))/a^2/d-1/3*(4*A-B-2*C)*sin(d*x+c)/a^2/d/(1+cos(d*x+c) 
)-1/3*(A-B+C)*sin(d*x+c)/d/(a+a*cos(d*x+c))^2
 

Mathematica [B] (warning: unable to verify)

Leaf count is larger than twice the leaf count of optimal. \(221\) vs. \(2(83)=166\).

Time = 1.95 (sec) , antiderivative size = 221, normalized size of antiderivative = 2.66 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x)}{(a+a \cos (c+d x))^2} \, dx=-\frac {4 \cos \left (\frac {1}{2} (c+d x)\right ) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \left (6 A \cos ^3\left (\frac {1}{2} (c+d x)\right ) \left (\log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )-\log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+(A-B+C) \sec \left (\frac {c}{2}\right ) \sin \left (\frac {d x}{2}\right )+2 (4 A-B-2 C) \cos ^2\left (\frac {1}{2} (c+d x)\right ) \sec \left (\frac {c}{2}\right ) \sin \left (\frac {d x}{2}\right )+(A-B+C) \cos \left (\frac {1}{2} (c+d x)\right ) \tan \left (\frac {c}{2}\right )\right )}{3 a^2 d (1+\cos (c+d x))^2 (2 A+C+2 B \cos (c+d x)+C \cos (2 (c+d x)))} \] Input:

Integrate[((A + B*Cos[c + d*x] + C*Cos[c + d*x]^2)*Sec[c + d*x])/(a + a*Co 
s[c + d*x])^2,x]
 

Output:

(-4*Cos[(c + d*x)/2]*(A + B*Cos[c + d*x] + C*Cos[c + d*x]^2)*(6*A*Cos[(c + 
 d*x)/2]^3*(Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] - Log[Cos[(c + d*x)/2 
] + Sin[(c + d*x)/2]]) + (A - B + C)*Sec[c/2]*Sin[(d*x)/2] + 2*(4*A - B - 
2*C)*Cos[(c + d*x)/2]^2*Sec[c/2]*Sin[(d*x)/2] + (A - B + C)*Cos[(c + d*x)/ 
2]*Tan[c/2]))/(3*a^2*d*(1 + Cos[c + d*x])^2*(2*A + C + 2*B*Cos[c + d*x] + 
C*Cos[2*(c + d*x)]))
 

Rubi [A] (verified)

Time = 0.57 (sec) , antiderivative size = 84, normalized size of antiderivative = 1.01, number of steps used = 7, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.179, Rules used = {3042, 3520, 3042, 3457, 27, 3042, 4257}

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 (c+d x) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right )}{(a \cos (c+d x)+a)^2} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {A+B \sin \left (c+d x+\frac {\pi }{2}\right )+C \sin \left (c+d x+\frac {\pi }{2}\right )^2}{\sin \left (c+d x+\frac {\pi }{2}\right ) \left (a \sin \left (c+d x+\frac {\pi }{2}\right )+a\right )^2}dx\)

\(\Big \downarrow \) 3520

\(\displaystyle \frac {\int \frac {(3 a A-a (A-B-2 C) \cos (c+d x)) \sec (c+d x)}{\cos (c+d x) a+a}dx}{3 a^2}-\frac {(A-B+C) \sin (c+d x)}{3 d (a \cos (c+d x)+a)^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \frac {3 a A-a (A-B-2 C) \sin \left (c+d x+\frac {\pi }{2}\right )}{\sin \left (c+d x+\frac {\pi }{2}\right ) \left (\sin \left (c+d x+\frac {\pi }{2}\right ) a+a\right )}dx}{3 a^2}-\frac {(A-B+C) \sin (c+d x)}{3 d (a \cos (c+d x)+a)^2}\)

\(\Big \downarrow \) 3457

\(\displaystyle \frac {\frac {\int 3 a^2 A \sec (c+d x)dx}{a^2}-\frac {(4 A-B-2 C) \sin (c+d x)}{d (\cos (c+d x)+1)}}{3 a^2}-\frac {(A-B+C) \sin (c+d x)}{3 d (a \cos (c+d x)+a)^2}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {3 A \int \sec (c+d x)dx-\frac {(4 A-B-2 C) \sin (c+d x)}{d (\cos (c+d x)+1)}}{3 a^2}-\frac {(A-B+C) \sin (c+d x)}{3 d (a \cos (c+d x)+a)^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {3 A \int \csc \left (c+d x+\frac {\pi }{2}\right )dx-\frac {(4 A-B-2 C) \sin (c+d x)}{d (\cos (c+d x)+1)}}{3 a^2}-\frac {(A-B+C) \sin (c+d x)}{3 d (a \cos (c+d x)+a)^2}\)

\(\Big \downarrow \) 4257

\(\displaystyle \frac {\frac {3 A \text {arctanh}(\sin (c+d x))}{d}-\frac {(4 A-B-2 C) \sin (c+d x)}{d (\cos (c+d x)+1)}}{3 a^2}-\frac {(A-B+C) \sin (c+d x)}{3 d (a \cos (c+d x)+a)^2}\)

Input:

Int[((A + B*Cos[c + d*x] + C*Cos[c + d*x]^2)*Sec[c + d*x])/(a + a*Cos[c + 
d*x])^2,x]
 

Output:

-1/3*((A - B + C)*Sin[c + d*x])/(d*(a + a*Cos[c + d*x])^2) + ((3*A*ArcTanh 
[Sin[c + d*x]])/d - ((4*A - B - 2*C)*Sin[c + d*x])/(d*(1 + Cos[c + d*x]))) 
/(3*a^2)
 

Defintions of rubi rules used

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

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

rule 3457
Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*sin[(e_.) + 
(f_.)*(x_)])*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Sim 
p[b*(A*b - a*B)*Cos[e + f*x]*(a + b*Sin[e + f*x])^m*((c + d*Sin[e + f*x])^( 
n + 1)/(a*f*(2*m + 1)*(b*c - a*d))), x] + Simp[1/(a*(2*m + 1)*(b*c - a*d)) 
  Int[(a + b*Sin[e + f*x])^(m + 1)*(c + d*Sin[e + f*x])^n*Simp[B*(a*c*m + b 
*d*(n + 1)) + A*(b*c*(m + 1) - a*d*(2*m + n + 2)) + d*(A*b - a*B)*(m + n + 
2)*Sin[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, n}, x] && NeQ 
[b*c - a*d, 0] && EqQ[a^2 - b^2, 0] && NeQ[c^2 - d^2, 0] && LtQ[m, -2^(-1)] 
 &&  !GtQ[n, 0] && IntegerQ[2*m] && (IntegerQ[2*n] || EqQ[c, 0])
 

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

rule 4257
Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] 
 /; FreeQ[{c, d}, x]
 
Maple [A] (verified)

Time = 0.36 (sec) , antiderivative size = 79, normalized size of antiderivative = 0.95

method result size
parallelrisch \(\frac {-6 A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )+6 A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )-\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (\left (A -B +C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}+9 A -3 B -3 C \right )}{6 a^{2} d}\) \(79\)
derivativedivides \(\frac {-3 A \tan \left (\frac {d x}{2}+\frac {c}{2}\right )+C \tan \left (\frac {d x}{2}+\frac {c}{2}\right )+2 A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )-\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} A}{3}+\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} B}{3}-\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} C}{3}+\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) B -2 A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 d \,a^{2}}\) \(116\)
default \(\frac {-3 A \tan \left (\frac {d x}{2}+\frac {c}{2}\right )+C \tan \left (\frac {d x}{2}+\frac {c}{2}\right )+2 A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )-\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} A}{3}+\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} B}{3}-\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} C}{3}+\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) B -2 A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 d \,a^{2}}\) \(116\)
risch \(\frac {2 i \left (-3 A \,{\mathrm e}^{2 i \left (d x +c \right )}+3 C \,{\mathrm e}^{2 i \left (d x +c \right )}-9 A \,{\mathrm e}^{i \left (d x +c \right )}+3 B \,{\mathrm e}^{i \left (d x +c \right )}+3 C \,{\mathrm e}^{i \left (d x +c \right )}-4 A +B +2 C \right )}{3 d \,a^{2} \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )^{3}}+\frac {A \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{a^{2} d}-\frac {A \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{a^{2} d}\) \(135\)
norman \(\frac {-\frac {\left (A -B +C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{7}}{6 a d}-\frac {\left (3 A -C -B \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{2 a d}-\frac {\left (11 A -5 B -C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{5}}{6 a d}-\frac {\left (19 A -7 B -5 C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}}{6 a d}}{\left (1+\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}\right )^{2} a}+\frac {A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{a^{2} d}-\frac {A \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{a^{2} d}\) \(173\)

Input:

int((A+B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c)/(a+a*cos(d*x+c))^2,x,method 
=_RETURNVERBOSE)
 

Output:

1/6*(-6*A*ln(tan(1/2*d*x+1/2*c)-1)+6*A*ln(tan(1/2*d*x+1/2*c)+1)-tan(1/2*d* 
x+1/2*c)*((A-B+C)*tan(1/2*d*x+1/2*c)^2+9*A-3*B-3*C))/a^2/d
 

Fricas [A] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 137, normalized size of antiderivative = 1.65 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x)}{(a+a \cos (c+d x))^2} \, dx=\frac {3 \, {\left (A \cos \left (d x + c\right )^{2} + 2 \, A \cos \left (d x + c\right ) + A\right )} \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, {\left (A \cos \left (d x + c\right )^{2} + 2 \, A \cos \left (d x + c\right ) + A\right )} \log \left (-\sin \left (d x + c\right ) + 1\right ) - 2 \, {\left ({\left (4 \, A - B - 2 \, C\right )} \cos \left (d x + c\right ) + 5 \, A - 2 \, B - C\right )} \sin \left (d x + c\right )}{6 \, {\left (a^{2} d \cos \left (d x + c\right )^{2} + 2 \, a^{2} d \cos \left (d x + c\right ) + a^{2} d\right )}} \] Input:

integrate((A+B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c)/(a+a*cos(d*x+c))^2,x, 
 algorithm="fricas")
 

Output:

1/6*(3*(A*cos(d*x + c)^2 + 2*A*cos(d*x + c) + A)*log(sin(d*x + c) + 1) - 3 
*(A*cos(d*x + c)^2 + 2*A*cos(d*x + c) + A)*log(-sin(d*x + c) + 1) - 2*((4* 
A - B - 2*C)*cos(d*x + c) + 5*A - 2*B - C)*sin(d*x + c))/(a^2*d*cos(d*x + 
c)^2 + 2*a^2*d*cos(d*x + c) + a^2*d)
 

Sympy [F]

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

integrate((A+B*cos(d*x+c)+C*cos(d*x+c)**2)*sec(d*x+c)/(a+a*cos(d*x+c))**2, 
x)
 

Output:

(Integral(A*sec(c + d*x)/(cos(c + d*x)**2 + 2*cos(c + d*x) + 1), x) + Inte 
gral(B*cos(c + d*x)*sec(c + d*x)/(cos(c + d*x)**2 + 2*cos(c + d*x) + 1), x 
) + Integral(C*cos(c + d*x)**2*sec(c + d*x)/(cos(c + d*x)**2 + 2*cos(c + d 
*x) + 1), x))/a**2
 

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 190 vs. \(2 (79) = 158\).

Time = 0.05 (sec) , antiderivative size = 190, normalized size of antiderivative = 2.29 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x)}{(a+a \cos (c+d x))^2} \, dx=-\frac {A {\left (\frac {\frac {9 \, \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + \frac {\sin \left (d x + c\right )^{3}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{3}}}{a^{2}} - \frac {6 \, \log \left (\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + 1\right )}{a^{2}} + \frac {6 \, \log \left (\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} - 1\right )}{a^{2}}\right )} - \frac {B {\left (\frac {3 \, \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + \frac {\sin \left (d x + c\right )^{3}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{3}}\right )}}{a^{2}} - \frac {C {\left (\frac {3 \, \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} - \frac {\sin \left (d x + c\right )^{3}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{3}}\right )}}{a^{2}}}{6 \, d} \] Input:

integrate((A+B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c)/(a+a*cos(d*x+c))^2,x, 
 algorithm="maxima")
 

Output:

-1/6*(A*((9*sin(d*x + c)/(cos(d*x + c) + 1) + sin(d*x + c)^3/(cos(d*x + c) 
 + 1)^3)/a^2 - 6*log(sin(d*x + c)/(cos(d*x + c) + 1) + 1)/a^2 + 6*log(sin( 
d*x + c)/(cos(d*x + c) + 1) - 1)/a^2) - B*(3*sin(d*x + c)/(cos(d*x + c) + 
1) + sin(d*x + c)^3/(cos(d*x + c) + 1)^3)/a^2 - C*(3*sin(d*x + c)/(cos(d*x 
 + c) + 1) - sin(d*x + c)^3/(cos(d*x + c) + 1)^3)/a^2)/d
 

Giac [A] (verification not implemented)

Time = 0.14 (sec) , antiderivative size = 144, normalized size of antiderivative = 1.73 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x)}{(a+a \cos (c+d x))^2} \, dx=\frac {\frac {6 \, A \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{a^{2}} - \frac {6 \, A \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{a^{2}} - \frac {A a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - B a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + C a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 9 \, A a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 3 \, B a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 3 \, C a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{a^{6}}}{6 \, d} \] Input:

integrate((A+B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c)/(a+a*cos(d*x+c))^2,x, 
 algorithm="giac")
 

Output:

1/6*(6*A*log(abs(tan(1/2*d*x + 1/2*c) + 1))/a^2 - 6*A*log(abs(tan(1/2*d*x 
+ 1/2*c) - 1))/a^2 - (A*a^4*tan(1/2*d*x + 1/2*c)^3 - B*a^4*tan(1/2*d*x + 1 
/2*c)^3 + C*a^4*tan(1/2*d*x + 1/2*c)^3 + 9*A*a^4*tan(1/2*d*x + 1/2*c) - 3* 
B*a^4*tan(1/2*d*x + 1/2*c) - 3*C*a^4*tan(1/2*d*x + 1/2*c))/a^6)/d
 

Mupad [B] (verification not implemented)

Time = 0.31 (sec) , antiderivative size = 83, normalized size of antiderivative = 1.00 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x)}{(a+a \cos (c+d x))^2} \, dx=\frac {2\,A\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{a^2\,d}-\frac {\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (\frac {A-B+C}{2\,a^2}+\frac {2\,A-2\,C}{2\,a^2}\right )}{d}-\frac {{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3\,\left (A-B+C\right )}{6\,a^2\,d} \] Input:

int((A + B*cos(c + d*x) + C*cos(c + d*x)^2)/(cos(c + d*x)*(a + a*cos(c + d 
*x))^2),x)
 

Output:

(2*A*atanh(tan(c/2 + (d*x)/2)))/(a^2*d) - (tan(c/2 + (d*x)/2)*((A - B + C) 
/(2*a^2) + (2*A - 2*C)/(2*a^2)))/d - (tan(c/2 + (d*x)/2)^3*(A - B + C))/(6 
*a^2*d)
 

Reduce [B] (verification not implemented)

Time = 0.17 (sec) , antiderivative size = 116, normalized size of antiderivative = 1.40 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec (c+d x)}{(a+a \cos (c+d x))^2} \, dx=\frac {-6 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) a +6 \,\mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) a -\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} a +\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} b -\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} c -9 \tan \left (\frac {d x}{2}+\frac {c}{2}\right ) a +3 \tan \left (\frac {d x}{2}+\frac {c}{2}\right ) b +3 \tan \left (\frac {d x}{2}+\frac {c}{2}\right ) c}{6 a^{2} d} \] Input:

int((A+B*cos(d*x+c)+C*cos(d*x+c)^2)*sec(d*x+c)/(a+a*cos(d*x+c))^2,x)
 

Output:

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