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

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

Optimal result

Integrand size = 21, antiderivative size = 246 \[ \int \frac {d+e \cos (x)}{a+b \cos (x)+c \cos ^2(x)} \, dx=\frac {2 \left (e+\frac {2 c d-b e}{\sqrt {b^2-4 a c}}\right ) \arctan \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 )}{\sqrt {b-2 c-\sqrt {b^2-4 a c}} \sqrt {b+2 c-\sqrt {b^2-4 a c}}}+\frac {2 \left (e-\frac {2 c d-b e}{\sqrt {b^2-4 a c}}\right ) \arctan \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 )}{\sqrt {b-2 c+\sqrt {b^2-4 a c}} \sqrt {b+2 c+\sqrt {b^2-4 a c}}} \] Output:

2*(e+(-b*e+2*c*d)/(-4*a*c+b^2)^(1/2))*arctan((b-2*c-(-4*a*c+b^2)^(1/2))^(1 
/2)*tan(1/2*x)/(b+2*c-(-4*a*c+b^2)^(1/2))^(1/2))/(b-2*c-(-4*a*c+b^2)^(1/2) 
)^(1/2)/(b+2*c-(-4*a*c+b^2)^(1/2))^(1/2)+2*(e-(-b*e+2*c*d)/(-4*a*c+b^2)^(1 
/2))*arctan((b-2*c+(-4*a*c+b^2)^(1/2))^(1/2)*tan(1/2*x)/(b+2*c+(-4*a*c+b^2 
)^(1/2))^(1/2))/(b-2*c+(-4*a*c+b^2)^(1/2))^(1/2)/(b+2*c+(-4*a*c+b^2)^(1/2) 
)^(1/2)
 

Mathematica [A] (verified)

Time = 0.94 (sec) , antiderivative size = 241, normalized size of antiderivative = 0.98 \[ \int \frac {d+e \cos (x)}{a+b \cos (x)+c \cos ^2(x)} \, dx=\frac {\sqrt {2} \left (-\frac {\left (-2 c d+\left (b+\sqrt {b^2-4 a c}\right ) e\right ) \text {arctanh}\left (\frac {\left (b-2 c+\sqrt {b^2-4 a c}\right ) \tan \left (\frac {x}{2}\right )}{\sqrt {-2 b^2+4 c (a+c)-2 b \sqrt {b^2-4 a c}}}\right )}{\sqrt {-b^2+2 c (a+c)-b \sqrt {b^2-4 a c}}}+\frac {\left (2 c d+\left (-b+\sqrt {b^2-4 a c}\right ) e\right ) \text {arctanh}\left (\frac {\left (-b+2 c+\sqrt {b^2-4 a c}\right ) \tan \left (\frac {x}{2}\right )}{\sqrt {-2 b^2+4 c (a+c)+2 b \sqrt {b^2-4 a c}}}\right )}{\sqrt {-b^2+2 c (a+c)+b \sqrt {b^2-4 a c}}}\right )}{\sqrt {b^2-4 a c}} \] Input:

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

Output:

(Sqrt[2]*(-(((-2*c*d + (b + Sqrt[b^2 - 4*a*c])*e)*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 + 2*c*(a + c) - b*Sqrt[b^2 - 4*a*c]]) + ((2*c*d + (-b + Sqrt 
[b^2 - 4*a*c])*e)*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 + 2*c*(a + c) + b 
*Sqrt[b^2 - 4*a*c]]))/Sqrt[b^2 - 4*a*c]
 

Rubi [A] (verified)

Time = 0.66 (sec) , antiderivative size = 246, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.238, Rules used = {3042, 3774, 3042, 3138, 218}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3774

\(\displaystyle \left (\frac {2 c d-b e}{\sqrt {b^2-4 a c}}+e\right ) \int \frac {1}{b+2 c \cos (x)-\sqrt {b^2-4 a c}}dx+\left (e-\frac {2 c d-b e}{\sqrt {b^2-4 a c}}\right ) \int \frac {1}{b+2 c \cos (x)+\sqrt {b^2-4 a c}}dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \left (\frac {2 c d-b e}{\sqrt {b^2-4 a c}}+e\right ) \int \frac {1}{b+2 c \sin \left (x+\frac {\pi }{2}\right )-\sqrt {b^2-4 a c}}dx+\left (e-\frac {2 c d-b e}{\sqrt {b^2-4 a c}}\right ) \int \frac {1}{b+2 c \sin \left (x+\frac {\pi }{2}\right )+\sqrt {b^2-4 a c}}dx\)

\(\Big \downarrow \) 3138

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

\(\Big \downarrow \) 218

\(\displaystyle \frac {2 \left (\frac {2 c d-b e}{\sqrt {b^2-4 a c}}+e\right ) \arctan \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 )}{\sqrt {-\sqrt {b^2-4 a c}+b-2 c} \sqrt {-\sqrt {b^2-4 a c}+b+2 c}}+\frac {2 \left (e-\frac {2 c d-b e}{\sqrt {b^2-4 a c}}\right ) \arctan \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 )}{\sqrt {\sqrt {b^2-4 a c}+b-2 c} \sqrt {\sqrt {b^2-4 a c}+b+2 c}}\)

Input:

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

Output:

(2*(e + (2*c*d - b*e)/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]]])/(Sqrt[b - 2*c - Sqr 
t[b^2 - 4*a*c]]*Sqrt[b + 2*c - Sqrt[b^2 - 4*a*c]]) + (2*(e - (2*c*d - b*e) 
/Sqrt[b^2 - 4*a*c])*ArcTan[(Sqrt[b - 2*c + Sqrt[b^2 - 4*a*c]]*Tan[x/2])/Sq 
rt[b + 2*c + Sqrt[b^2 - 4*a*c]]])/(Sqrt[b - 2*c + Sqrt[b^2 - 4*a*c]]*Sqrt[ 
b + 2*c + Sqrt[b^2 - 4*a*c]])
 

Defintions of rubi rules used

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

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

rule 3138
Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{ 
e = FreeFactors[Tan[(c + d*x)/2], x]}, Simp[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 3774
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]}, Simp[(B + (b*B - 2*A*c)/q)   Int[1/(b + q + 2*c*Cos[d + e*x]) 
, x], x] + Simp[(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]
 
Maple [A] (verified)

Time = 1.42 (sec) , antiderivative size = 254, normalized size of antiderivative = 1.03

method result size
default \(2 \left (a -b +c \right ) \left (\frac {\left (\sqrt {-4 a c +b^{2}}\, d -e \sqrt {-4 a c +b^{2}}-2 a e +b d +b e -2 c d \right ) \arctan \left (\frac {\left (a -b +c \right ) \tan \left (\frac {x}{2}\right )}{\sqrt {\left (\sqrt {-4 a c +b^{2}}+a -c \right ) \left (a -b +c \right )}}\right )}{2 \sqrt {-4 a c +b^{2}}\, \left (a -b +c \right ) \sqrt {\left (\sqrt {-4 a c +b^{2}}+a -c \right ) \left (a -b +c \right )}}+\frac {\left (\sqrt {-4 a c +b^{2}}\, d -e \sqrt {-4 a c +b^{2}}+2 a e -b d -b e +2 c d \right ) \operatorname {arctanh}\left (\frac {\left (-a +b -c \right ) \tan \left (\frac {x}{2}\right )}{\sqrt {\left (\sqrt {-4 a c +b^{2}}-a +c \right ) \left (a -b +c \right )}}\right )}{2 \sqrt {-4 a c +b^{2}}\, \left (a -b +c \right ) \sqrt {\left (\sqrt {-4 a c +b^{2}}-a +c \right ) \left (a -b +c \right )}}\right )\) \(254\)
risch \(\text {Expression too large to display}\) \(8335\)

Input:

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

Output:

2*(a-b+c)*(1/2*((-4*a*c+b^2)^(1/2)*d-e*(-4*a*c+b^2)^(1/2)-2*a*e+b*d+b*e-2* 
c*d)/(-4*a*c+b^2)^(1/2)/(a-b+c)/(((-4*a*c+b^2)^(1/2)+a-c)*(a-b+c))^(1/2)*a 
rctan((a-b+c)*tan(1/2*x)/(((-4*a*c+b^2)^(1/2)+a-c)*(a-b+c))^(1/2))+1/2*((- 
4*a*c+b^2)^(1/2)*d-e*(-4*a*c+b^2)^(1/2)+2*a*e-b*d-b*e+2*c*d)/(-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)*ta 
n(1/2*x)/(((-4*a*c+b^2)^(1/2)-a+c)*(a-b+c))^(1/2)))
 

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 6697 vs. \(2 (206) = 412\).

Time = 5.69 (sec) , antiderivative size = 6697, normalized size of antiderivative = 27.22 \[ \int \frac {d+e \cos (x)}{a+b \cos (x)+c \cos ^2(x)} \, dx=\text {Too large to display} \] Input:

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

Output:

Too large to include
 

Sympy [F(-1)]

Timed out. \[ \int \frac {d+e \cos (x)}{a+b \cos (x)+c \cos ^2(x)} \, dx=\text {Timed out} \] Input:

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

Output:

Timed out
 

Maxima [F]

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

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

Output:

integrate((e*cos(x) + d)/(c*cos(x)^2 + b*cos(x) + a), x)
 

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 5300 vs. \(2 (206) = 412\).

Time = 2.36 (sec) , antiderivative size = 5300, normalized size of antiderivative = 21.54 \[ \int \frac {d+e \cos (x)}{a+b \cos (x)+c \cos ^2(x)} \, dx=\text {Too large to display} \] Input:

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

Output:

((2*a^2*b^3 - 2*b^5 - 8*a^3*b*c - 12*a^2*b^2*c + 20*a*b^3*c + 4*b^4*c + 48 
*a^3*c^2 - 48*a^2*b*c^2 - 24*a*b^2*c^2 - 6*b^3*c^2 + 32*a^2*c^3 + 24*a*b*c 
^3 + 4*b^2*c^3 - 16*a*c^4 + 3*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a* 
c)*(a - b + c))*a^2*b^2 - 2*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c) 
*(a - b + c))*a*b^3 - 5*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a 
- b + c))*b^4 - 12*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + 
 c))*a^3*c + 8*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + c)) 
*a^2*b*c + 34*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))* 
a*b^2*c + 6*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))*b^ 
3*c - 56*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))*a^2*c 
^2 - 24*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))*a*b*c^ 
2 - 5*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))*b^2*c^2 
+ 20*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))*a*c^3 + 3 
*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))*sqrt(b^2 - 4* 
a*c)*a^2*b - 2*(b^2 - 4*a*c)*a^2*b - 2*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b 
^2 - 4*a*c)*(a - b + c))*sqrt(b^2 - 4*a*c)*a*b^2 - 5*sqrt(a^2 - a*b + b*c 
- c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))*sqrt(b^2 - 4*a*c)*b^3 + 2*(b^2 - 4* 
a*c)*b^3 + 6*sqrt(a^2 - a*b + b*c - c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))*s 
qrt(b^2 - 4*a*c)*a^2*c + 12*(b^2 - 4*a*c)*a^2*c + 10*sqrt(a^2 - a*b + b*c 
- c^2 + sqrt(b^2 - 4*a*c)*(a - b + c))*sqrt(b^2 - 4*a*c)*a*b*c - 12*(b^...
 

Mupad [B] (verification not implemented)

Time = 31.29 (sec) , antiderivative size = 11781, normalized size of antiderivative = 47.89 \[ \int \frac {d+e \cos (x)}{a+b \cos (x)+c \cos ^2(x)} \, dx=\text {Too large to display} \] Input:

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

Output:

- atan((((-(b^4*d^2 - b^4*e^2 + 8*a*c^3*d^2 + b*d^2*(-(4*a*c - b^2)^3)^(1/ 
2) - 8*a^3*c*e^2 + b*e^2*(-(4*a*c - b^2)^3)^(1/2) + 2*a^2*b^2*e^2 + 8*a^2* 
c^2*d^2 - 8*a^2*c^2*e^2 - 2*b^2*c^2*d^2 - 2*a*b^3*d*e - 2*a*d*e*(-(4*a*c - 
 b^2)^3)^(1/2) + 2*b^3*c*d*e - 2*c*d*e*(-(4*a*c - b^2)^3)^(1/2) - 6*a*b^2* 
c*d^2 + 6*a*b^2*c*e^2 - 8*a*b*c^2*d*e + 8*a^2*b*c*d*e)/(2*(a^2*b^4 - b^6 + 
 16*a^2*c^4 + 32*a^3*c^3 + 16*a^4*c^2 + b^4*c^2 - 8*a*b^2*c^3 - 8*a^3*b^2* 
c - 32*a^2*b^2*c^2 + 10*a*b^4*c)))^(1/2)*(256*a^2*c^2*d - 32*b^4*e - 32*a^ 
2*b^2*d - 32*a^2*b^2*e - 32*b^4*d + 256*a^2*c^2*e - 32*b^2*c^2*d - 32*b^2* 
c^2*e + tan(x/2)*(-(b^4*d^2 - b^4*e^2 + 8*a*c^3*d^2 + b*d^2*(-(4*a*c - b^2 
)^3)^(1/2) - 8*a^3*c*e^2 + b*e^2*(-(4*a*c - b^2)^3)^(1/2) + 2*a^2*b^2*e^2 
+ 8*a^2*c^2*d^2 - 8*a^2*c^2*e^2 - 2*b^2*c^2*d^2 - 2*a*b^3*d*e - 2*a*d*e*(- 
(4*a*c - b^2)^3)^(1/2) + 2*b^3*c*d*e - 2*c*d*e*(-(4*a*c - b^2)^3)^(1/2) - 
6*a*b^2*c*d^2 + 6*a*b^2*c*e^2 - 8*a*b*c^2*d*e + 8*a^2*b*c*d*e)/(2*(a^2*b^4 
 - b^6 + 16*a^2*c^4 + 32*a^3*c^3 + 16*a^4*c^2 + b^4*c^2 - 8*a*b^2*c^3 - 8* 
a^3*b^2*c - 32*a^2*b^2*c^2 + 10*a*b^4*c)))^(1/2)*(64*a*b^4 + 256*a*c^4 - 2 
56*a^4*c - 64*b^4*c - 128*a^2*b^3 + 64*a^3*b^2 + 256*a^2*c^3 - 256*a^3*c^2 
 - 64*b^2*c^3 + 128*b^3*c^2 + 192*a*b^2*c^2 - 192*a^2*b^2*c - 512*a*b*c^3 
+ 512*a^3*b*c) + 64*a*b^3*d + 64*a*b^3*e + 128*a*c^3*d + 128*a^3*c*d + 128 
*a*c^3*e + 128*a^3*c*e + 64*b^3*c*d + 64*b^3*c*e - 256*a*b*c^2*d + 64*a*b^ 
2*c*d - 256*a^2*b*c*d - 256*a*b*c^2*e + 64*a*b^2*c*e - 256*a^2*b*c*e) +...
 

Reduce [F]

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

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

Output:

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