### 3.18 $$\int \frac{\sec (x)}{a+b \cos (x)+c \cos ^2(x)} \, dx$$

Optimal. Leaf size=245 $-\frac{2 c \left (\frac{b}{\sqrt{b^2-4 a c}}+1\right ) \tan ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \sqrt{-\sqrt{b^2-4 a c}+b-2 c}}{\sqrt{-\sqrt{b^2-4 a c}+b+2 c}}\right )}{a \sqrt{-\sqrt{b^2-4 a c}+b-2 c} \sqrt{-\sqrt{b^2-4 a c}+b+2 c}}-\frac{2 c \left (1-\frac{b}{\sqrt{b^2-4 a c}}\right ) \tan ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \sqrt{\sqrt{b^2-4 a c}+b-2 c}}{\sqrt{\sqrt{b^2-4 a c}+b+2 c}}\right )}{a \sqrt{\sqrt{b^2-4 a c}+b-2 c} \sqrt{\sqrt{b^2-4 a c}+b+2 c}}+\frac{\tanh ^{-1}(\sin (x))}{a}$

[Out]

(-2*c*(1 + b/Sqrt[b^2 - 4*a*c])*ArcTan[(Sqrt[b - 2*c - Sqrt[b^2 - 4*a*c]]*Tan[x/2])/Sqrt[b + 2*c - Sqrt[b^2 -
4*a*c]]])/(a*Sqrt[b - 2*c - Sqrt[b^2 - 4*a*c]]*Sqrt[b + 2*c - Sqrt[b^2 - 4*a*c]]) - (2*c*(1 - b/Sqrt[b^2 - 4*a
*c])*ArcTan[(Sqrt[b - 2*c + Sqrt[b^2 - 4*a*c]]*Tan[x/2])/Sqrt[b + 2*c + Sqrt[b^2 - 4*a*c]]])/(a*Sqrt[b - 2*c +
Sqrt[b^2 - 4*a*c]]*Sqrt[b + 2*c + Sqrt[b^2 - 4*a*c]]) + ArcTanh[Sin[x]]/a

________________________________________________________________________________________

Rubi [A]  time = 0.772411, antiderivative size = 245, normalized size of antiderivative = 1., number of steps used = 8, number of rules used = 5, integrand size = 17, $$\frac{\text{number of rules}}{\text{integrand size}}$$ = 0.294, Rules used = {3257, 3293, 2659, 205, 3770} $-\frac{2 c \left (\frac{b}{\sqrt{b^2-4 a c}}+1\right ) \tan ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \sqrt{-\sqrt{b^2-4 a c}+b-2 c}}{\sqrt{-\sqrt{b^2-4 a c}+b+2 c}}\right )}{a \sqrt{-\sqrt{b^2-4 a c}+b-2 c} \sqrt{-\sqrt{b^2-4 a c}+b+2 c}}-\frac{2 c \left (1-\frac{b}{\sqrt{b^2-4 a c}}\right ) \tan ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \sqrt{\sqrt{b^2-4 a c}+b-2 c}}{\sqrt{\sqrt{b^2-4 a c}+b+2 c}}\right )}{a \sqrt{\sqrt{b^2-4 a c}+b-2 c} \sqrt{\sqrt{b^2-4 a c}+b+2 c}}+\frac{\tanh ^{-1}(\sin (x))}{a}$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

(-2*c*(1 + b/Sqrt[b^2 - 4*a*c])*ArcTan[(Sqrt[b - 2*c - Sqrt[b^2 - 4*a*c]]*Tan[x/2])/Sqrt[b + 2*c - Sqrt[b^2 -
4*a*c]]])/(a*Sqrt[b - 2*c - Sqrt[b^2 - 4*a*c]]*Sqrt[b + 2*c - Sqrt[b^2 - 4*a*c]]) - (2*c*(1 - b/Sqrt[b^2 - 4*a
*c])*ArcTan[(Sqrt[b - 2*c + Sqrt[b^2 - 4*a*c]]*Tan[x/2])/Sqrt[b + 2*c + Sqrt[b^2 - 4*a*c]]])/(a*Sqrt[b - 2*c +
Sqrt[b^2 - 4*a*c]]*Sqrt[b + 2*c + Sqrt[b^2 - 4*a*c]]) + ArcTanh[Sin[x]]/a

Rule 3257

Int[cos[(d_.) + (e_.)*(x_)]^(m_.)*((a_.) + cos[(d_.) + (e_.)*(x_)]^(n_.)*(b_.) + cos[(d_.) + (e_.)*(x_)]^(n2_.
)*(c_.))^(p_), x_Symbol] :> Int[ExpandTrig[cos[d + e*x]^m*(a + b*cos[d + e*x]^n + c*cos[d + e*x]^(2*n))^p, x],
x] /; FreeQ[{a, b, c, d, e}, x] && EqQ[n2, 2*n] && NeQ[b^2 - 4*a*c, 0] && IntegersQ[m, n, p]

Rule 3293

Int[(cos[(d_.) + (e_.)*(x_)]*(B_.) + (A_))/((a_.) + cos[(d_.) + (e_.)*(x_)]*(b_.) + cos[(d_.) + (e_.)*(x_)]^2*
(c_.)), x_Symbol] :> Module[{q = Rt[b^2 - 4*a*c, 2]}, Dist[B + (b*B - 2*A*c)/q, Int[1/(b + q + 2*c*Cos[d + e*x
]), x], x] + Dist[B - (b*B - 2*A*c)/q, Int[1/(b - q + 2*c*Cos[d + e*x]), x], x]] /; FreeQ[{a, b, c, d, e, A, B
}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 2659

Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x
]}, Dist[(2*e)/d, Subst[Int[1/(a + b + (a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}
, x] && NeQ[a^2 - b^2, 0]

Rule 205

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]*ArcTan[x/Rt[a/b, 2]])/a, x] /; FreeQ[{a, b}, x]
&& PosQ[a/b]

Rule 3770

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

Rubi steps

\begin{align*} \int \frac{\sec (x)}{a+b \cos (x)+c \cos ^2(x)} \, dx &=\int \left (\frac{-b-c \cos (x)}{a \left (a+b \cos (x)+c \cos ^2(x)\right )}+\frac{\sec (x)}{a}\right ) \, dx\\ &=\frac{\int \frac{-b-c \cos (x)}{a+b \cos (x)+c \cos ^2(x)} \, dx}{a}+\frac{\int \sec (x) \, dx}{a}\\ &=\frac{\tanh ^{-1}(\sin (x))}{a}-\frac{\left (c \left (1-\frac{b}{\sqrt{b^2-4 a c}}\right )\right ) \int \frac{1}{b+\sqrt{b^2-4 a c}+2 c \cos (x)} \, dx}{a}-\frac{\left (c \left (1+\frac{b}{\sqrt{b^2-4 a c}}\right )\right ) \int \frac{1}{b-\sqrt{b^2-4 a c}+2 c \cos (x)} \, dx}{a}\\ &=\frac{\tanh ^{-1}(\sin (x))}{a}-\frac{\left (2 c \left (1-\frac{b}{\sqrt{b^2-4 a c}}\right )\right ) \operatorname{Subst}\left (\int \frac{1}{b+2 c+\sqrt{b^2-4 a c}+\left (b-2 c+\sqrt{b^2-4 a c}\right ) x^2} \, dx,x,\tan \left (\frac{x}{2}\right )\right )}{a}-\frac{\left (2 c \left (1+\frac{b}{\sqrt{b^2-4 a c}}\right )\right ) \operatorname{Subst}\left (\int \frac{1}{b+2 c-\sqrt{b^2-4 a c}+\left (b-2 c-\sqrt{b^2-4 a c}\right ) x^2} \, dx,x,\tan \left (\frac{x}{2}\right )\right )}{a}\\ &=-\frac{2 c \left (1+\frac{b}{\sqrt{b^2-4 a c}}\right ) \tan ^{-1}\left (\frac{\sqrt{b-2 c-\sqrt{b^2-4 a c}} \tan \left (\frac{x}{2}\right )}{\sqrt{b+2 c-\sqrt{b^2-4 a c}}}\right )}{a \sqrt{b-2 c-\sqrt{b^2-4 a c}} \sqrt{b+2 c-\sqrt{b^2-4 a c}}}-\frac{2 c \left (1-\frac{b}{\sqrt{b^2-4 a c}}\right ) \tan ^{-1}\left (\frac{\sqrt{b-2 c+\sqrt{b^2-4 a c}} \tan \left (\frac{x}{2}\right )}{\sqrt{b+2 c+\sqrt{b^2-4 a c}}}\right )}{a \sqrt{b-2 c+\sqrt{b^2-4 a c}} \sqrt{b+2 c+\sqrt{b^2-4 a c}}}+\frac{\tanh ^{-1}(\sin (x))}{a}\\ \end{align*}

Mathematica [A]  time = 0.640877, size = 281, normalized size = 1.15 $\frac{\frac{\sqrt{2} c \left (\sqrt{b^2-4 a c}-b\right ) \tanh ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \left (\sqrt{b^2-4 a c}+b-2 c\right )}{\sqrt{-2 b \sqrt{b^2-4 a c}+4 c (a+c)-2 b^2}}\right )}{\sqrt{b^2-4 a c} \sqrt{-b \sqrt{b^2-4 a c}+2 c (a+c)-b^2}}-\frac{\sqrt{2} c \left (\sqrt{b^2-4 a c}+b\right ) \tanh ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \left (\sqrt{b^2-4 a c}-b+2 c\right )}{\sqrt{2 b \sqrt{b^2-4 a c}+4 c (a+c)-2 b^2}}\right )}{\sqrt{b^2-4 a c} \sqrt{b \sqrt{b^2-4 a c}+2 c (a+c)-b^2}}-\log \left (\cos \left (\frac{x}{2}\right )-\sin \left (\frac{x}{2}\right )\right )+\log \left (\sin \left (\frac{x}{2}\right )+\cos \left (\frac{x}{2}\right )\right )}{a}$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

((Sqrt[2]*c*(-b + Sqrt[b^2 - 4*a*c])*ArcTanh[((b - 2*c + Sqrt[b^2 - 4*a*c])*Tan[x/2])/Sqrt[-2*b^2 + 4*c*(a + c
) - 2*b*Sqrt[b^2 - 4*a*c]]])/(Sqrt[b^2 - 4*a*c]*Sqrt[-b^2 + 2*c*(a + c) - b*Sqrt[b^2 - 4*a*c]]) - (Sqrt[2]*c*(
b + Sqrt[b^2 - 4*a*c])*ArcTanh[((-b + 2*c + Sqrt[b^2 - 4*a*c])*Tan[x/2])/Sqrt[-2*b^2 + 4*c*(a + c) + 2*b*Sqrt[
b^2 - 4*a*c]]])/(Sqrt[b^2 - 4*a*c]*Sqrt[-b^2 + 2*c*(a + c) + b*Sqrt[b^2 - 4*a*c]]) - Log[Cos[x/2] - Sin[x/2]]
+ Log[Cos[x/2] + Sin[x/2]])/a

________________________________________________________________________________________

Maple [B]  time = 0.056, size = 1957, normalized size = 8. \begin{align*} \text{result too large to display} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

c/(a-b+c)/(((-4*a*c+b^2)^(1/2)+a-c)*(a-b+c))^(1/2)*arctan((a-b+c)*tan(1/2*x)/(((-4*a*c+b^2)^(1/2)+a-c)*(a-b+c)
)^(1/2))+c/(a-b+c)/(((-4*a*c+b^2)^(1/2)-a+c)*(a-b+c))^(1/2)*arctanh((-a+b-c)*tan(1/2*x)/(((-4*a*c+b^2)^(1/2)-a
+c)*(a-b+c))^(1/2))+1/a*ln(tan(1/2*x)+1)-1/a*ln(tan(1/2*x)-1)-2/a/(-4*a*c+b^2)^(1/2)/(a-b+c)/(((-4*a*c+b^2)^(1
/2)+a-c)*(a-b+c))^(1/2)*arctan((a-b+c)*tan(1/2*x)/(((-4*a*c+b^2)^(1/2)+a-c)*(a-b+c))^(1/2))*b^2*c+2/a/(-4*a*c+
b^2)^(1/2)/(a-b+c)/(((-4*a*c+b^2)^(1/2)-a+c)*(a-b+c))^(1/2)*arctanh((-a+b-c)*tan(1/2*x)/(((-4*a*c+b^2)^(1/2)-a
+c)*(a-b+c))^(1/2))*b^2*c+1/a/(-4*a*c+b^2)^(1/2)/(a-b+c)/(((-4*a*c+b^2)^(1/2)+a-c)*(a-b+c))^(1/2)*arctan((a-b+
c)*tan(1/2*x)/(((-4*a*c+b^2)^(1/2)+a-c)*(a-b+c))^(1/2))*b*c^2-1/a/(-4*a*c+b^2)^(1/2)/(a-b+c)/(((-4*a*c+b^2)^(1
/2)-a+c)*(a-b+c))^(1/2)*arctanh((-a+b-c)*tan(1/2*x)/(((-4*a*c+b^2)^(1/2)-a+c)*(a-b+c))^(1/2))*b*c^2-2/a*b/(a-b
+c)/(((-4*a*c+b^2)^(1/2)+a-c)*(a-b+c))^(1/2)*arctan((a-b+c)*tan(1/2*x)/(((-4*a*c+b^2)^(1/2)+a-c)*(a-b+c))^(1/2
))*c+1/a/(-4*a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c+b^2)^(1/2)-a+c)*(a-b+c))^(1/2)*arctanh((-a+b-c)*tan(1/2*x)/(((-4*a*c+b^2)^(1/2)-a+c)*(a-b+c))^(1/2))*c^2

________________________________________________________________________________________

Maxima [F]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{result too large to display} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-1/2*(2*a*integrate(2*(2*b*c*cos(3*x)^2 + 2*b*c*cos(x)^2 + 2*b*c*sin(3*x)^2 + 2*b*c*sin(x)^2 + 4*(2*a*b + b*c)
*cos(2*x)^2 + c^2*cos(x) + 4*(2*a*b + b*c)*sin(2*x)^2 + 2*(2*b^2 + 2*a*c + c^2)*sin(2*x)*sin(x) + (c^2*cos(3*x
) + 2*b*c*cos(2*x) + c^2*cos(x))*cos(4*x) + (4*b*c*cos(x) + c^2 + 2*(2*b^2 + 2*a*c + c^2)*cos(2*x))*cos(3*x) +
2*(b*c + (2*b^2 + 2*a*c + c^2)*cos(x))*cos(2*x) + (c^2*sin(3*x) + 2*b*c*sin(2*x) + c^2*sin(x))*sin(4*x) + 2*(
2*b*c*sin(x) + (2*b^2 + 2*a*c + c^2)*sin(2*x))*sin(3*x))/(a*c^2*cos(4*x)^2 + 4*a*b^2*cos(3*x)^2 + 4*a*b^2*cos(
x)^2 + a*c^2*sin(4*x)^2 + 4*a*b^2*sin(3*x)^2 + 4*a*b^2*sin(x)^2 + 4*a*b*c*cos(x) + a*c^2 + 4*(4*a^3 + 4*a^2*c
+ a*c^2)*cos(2*x)^2 + 4*(4*a^3 + 4*a^2*c + a*c^2)*sin(2*x)^2 + 8*(2*a^2*b + a*b*c)*sin(2*x)*sin(x) + 2*(2*a*b*
c*cos(3*x) + 2*a*b*c*cos(x) + a*c^2 + 2*(2*a^2*c + a*c^2)*cos(2*x))*cos(4*x) + 4*(2*a*b^2*cos(x) + a*b*c + 2*(
2*a^2*b + a*b*c)*cos(2*x))*cos(3*x) + 4*(2*a^2*c + a*c^2 + 2*(2*a^2*b + a*b*c)*cos(x))*cos(2*x) + 4*(a*b*c*sin
(3*x) + a*b*c*sin(x) + (2*a^2*c + a*c^2)*sin(2*x))*sin(4*x) + 8*(a*b^2*sin(x) + (2*a^2*b + a*b*c)*sin(2*x))*si
n(3*x)), x) - log(cos(x)^2 + sin(x)^2 + 2*sin(x) + 1) + log(cos(x)^2 + sin(x)^2 - 2*sin(x) + 1))/a

________________________________________________________________________________________

Fricas [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Timed out

________________________________________________________________________________________

Sympy [F]  time = 0., size = 0, normalized size = 0. \begin{align*} \int \frac{\sec{\left (x \right )}}{a + b \cos{\left (x \right )} + c \cos ^{2}{\left (x \right )}}\, dx \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Giac [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Timed out