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

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 = 41, antiderivative size = 71 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+a \cos (c+d x)} \, dx=-\frac {(A-B) \text {arctanh}(\sin (c+d x))}{a d}+\frac {(2 A-B+C) \tan (c+d x)}{a d}-\frac {(A-B+C) \tan (c+d x)}{d (a+a \cos (c+d x))} \] Output:

-(A-B)*arctanh(sin(d*x+c))/a/d+(2*A-B+C)*tan(d*x+c)/a/d-(A-B+C)*tan(d*x+c) 
/d/(a+a*cos(d*x+c))
 

Mathematica [B] (warning: unable to verify)

Leaf count is larger than twice the leaf count of optimal. \(256\) vs. \(2(71)=142\).

Time = 2.55 (sec) , antiderivative size = 256, normalized size of antiderivative = 3.61 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+a \cos (c+d x)} \, dx=\frac {4 \cos \left (\frac {1}{2} (c+d x)\right ) \cos ^2(c+d x) \left (C+B \sec (c+d x)+A \sec ^2(c+d x)\right ) \left ((A-B+C) \sec \left (\frac {c}{2}\right ) \sin \left (\frac {d x}{2}\right )+\cos \left (\frac {1}{2} (c+d x)\right ) \left ((A-B) \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 )+\frac {A \sin (d x)}{\left (\cos \left (\frac {c}{2}\right )-\sin \left (\frac {c}{2}\right )\right ) \left (\cos \left (\frac {c}{2}\right )+\sin \left (\frac {c}{2}\right )\right ) \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right ) \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )}\right )\right )}{a d (1+\cos (c+d x)) (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]^2)/(a + a* 
Cos[c + d*x]),x]
 

Output:

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

Rubi [A] (verified)

Time = 0.57 (sec) , antiderivative size = 72, normalized size of antiderivative = 1.01, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.195, Rules used = {3042, 3520, 3042, 3227, 3042, 4254, 24, 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 ^2(c+d x) \left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right )}{a \cos (c+d x)+a} \, 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 )^2 \left (a \sin \left (c+d x+\frac {\pi }{2}\right )+a\right )}dx\)

\(\Big \downarrow \) 3520

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3227

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4254

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

\(\Big \downarrow \) 24

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

\(\Big \downarrow \) 4257

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

Input:

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

Output:

-(((A - B + C)*Tan[c + d*x])/(d*(a + a*Cos[c + d*x]))) + (-((a*(A - B)*Arc 
Tanh[Sin[c + d*x]])/d) + (a*(2*A - B + C)*Tan[c + d*x])/d)/a^2
 

Defintions of rubi rules used

rule 24
Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]
 

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

rule 3227
Int[((b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((c_) + (d_.)*sin[(e_.) + (f_.)*(x 
_)]), x_Symbol] :> Simp[c   Int[(b*Sin[e + f*x])^m, x], x] + Simp[d/b   Int 
[(b*Sin[e + f*x])^(m + 1), x], x] /; FreeQ[{b, c, d, e, f, m}, x]
 

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 4254
Int[csc[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> Simp[-d^(-1)   Subst[Int[Exp 
andIntegrand[(1 + x^2)^(n/2 - 1), x], x], x, Cot[c + d*x]], x] /; FreeQ[{c, 
 d}, x] && IGtQ[n/2, 0]
 

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.41 (sec) , antiderivative size = 96, normalized size of antiderivative = 1.35

method result size
parallelrisch \(\frac {\cos \left (d x +c \right ) \left (A -B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )-\cos \left (d x +c \right ) \left (A -B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )+2 \left (\left (A -\frac {B}{2}+\frac {C}{2}\right ) \cos \left (d x +c \right )+\frac {A}{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{a d \cos \left (d x +c \right )}\) \(96\)
derivativedivides \(\frac {A \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) B +C \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-\frac {A}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1}+\left (A -B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )-\frac {A}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1}+\left (-A +B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{d a}\) \(111\)
default \(\frac {A \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) B +C \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-\frac {A}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1}+\left (A -B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )-\frac {A}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1}+\left (-A +B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{d a}\) \(111\)
risch \(\frac {2 i \left (A \,{\mathrm e}^{2 i \left (d x +c \right )}-B \,{\mathrm e}^{2 i \left (d x +c \right )}+C \,{\mathrm e}^{2 i \left (d x +c \right )}+A \,{\mathrm e}^{i \left (d x +c \right )}+2 A -B +C \right )}{d a \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}-\frac {A \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{a d}+\frac {B \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{a d}+\frac {A \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{a d}-\frac {B \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{a d}\) \(176\)
norman \(\frac {\frac {\left (A -B +C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{7}}{a d}-\frac {\left (A +B -C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{5}}{a d}-\frac {\left (3 A -B +C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{a d}-\frac {\left (5 A -B +C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}}{a d}}{\left (1+\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}\right )^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right )}+\frac {\left (A -B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{a d}-\frac {\left (A -B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{a d}\) \(184\)

Input:

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

Output:

(cos(d*x+c)*(A-B)*ln(tan(1/2*d*x+1/2*c)-1)-cos(d*x+c)*(A-B)*ln(tan(1/2*d*x 
+1/2*c)+1)+2*((A-1/2*B+1/2*C)*cos(d*x+c)+1/2*A)*tan(1/2*d*x+1/2*c))/a/d/co 
s(d*x+c)
 

Fricas [A] (verification not implemented)

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

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

Output:

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

Sympy [F]

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

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

Output:

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

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 218 vs. \(2 (71) = 142\).

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

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

Output:

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

Giac [A] (verification not implemented)

Time = 0.15 (sec) , antiderivative size = 121, normalized size of antiderivative = 1.70 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+a \cos (c+d x)} \, dx=-\frac {\frac {{\left (A - B\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{a} - \frac {{\left (A - B\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{a} - \frac {A \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - B \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + C \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{a} + \frac {2 \, A \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )} a}}{d} \] Input:

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

Output:

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

Mupad [B] (verification not implemented)

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

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

Output:

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

Reduce [B] (verification not implemented)

Time = 0.23 (sec) , antiderivative size = 194, normalized size of antiderivative = 2.73 \[ \int \frac {\left (A+B \cos (c+d x)+C \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+a \cos (c+d x)} \, dx=\frac {\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 -\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 ) b -\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 +\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 ) b +\cos \left (d x +c \right ) a -\cos \left (d x +c \right ) b +\cos \left (d x +c \right ) c +2 \sin \left (d x +c \right )^{2} a -\sin \left (d x +c \right )^{2} b +\sin \left (d x +c \right )^{2} c -a +b -c}{\cos \left (d x +c \right ) \sin \left (d x +c \right ) a d} \] Input:

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

Output:

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