Integrand size = 15, antiderivative size = 52 \[ \int \frac {\cos ^2(x)}{a+b \cos (2 x)} \, dx=\frac {x}{2 b}-\frac {\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \tan (x)}{\sqrt {a+b}}\right )}{2 b \sqrt {a+b}} \] Output:
1/2*x/b-1/2*(a-b)^(1/2)*arctan((a-b)^(1/2)*tan(x)/(a+b)^(1/2))/b/(a+b)^(1/ 2)
Time = 0.06 (sec) , antiderivative size = 50, normalized size of antiderivative = 0.96 \[ \int \frac {\cos ^2(x)}{a+b \cos (2 x)} \, dx=\frac {x+\frac {(a-b) \text {arctanh}\left (\frac {(a-b) \tan (x)}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2}}}{2 b} \] Input:
Integrate[Cos[x]^2/(a + b*Cos[2*x]),x]
Output:
(x + ((a - b)*ArcTanh[((a - b)*Tan[x])/Sqrt[-a^2 + b^2]])/Sqrt[-a^2 + b^2] )/(2*b)
Time = 0.29 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.04, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.267, Rules used = {3042, 4889, 1406, 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 {\cos ^2(x)}{a+b \cos (2 x)} \, dx\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \int \frac {\cos (x)^2}{a+b \cos (2 x)}dx\) |
\(\Big \downarrow \) 4889 |
\(\displaystyle \int \frac {1}{(a-b) \tan ^4(x)+2 a \tan ^2(x)+a+b}d\tan (x)\) |
\(\Big \downarrow \) 1406 |
\(\displaystyle \frac {(a-b) \int \frac {1}{(a-b) \tan ^2(x)+a-b}d\tan (x)}{2 b}-\frac {(a-b) \int \frac {1}{(a-b) \tan ^2(x)+a+b}d\tan (x)}{2 b}\) |
\(\Big \downarrow \) 218 |
\(\displaystyle \frac {\arctan (\tan (x))}{2 b}-\frac {\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \tan (x)}{\sqrt {a+b}}\right )}{2 b \sqrt {a+b}}\) |
Input:
Int[Cos[x]^2/(a + b*Cos[2*x]),x]
Output:
ArcTan[Tan[x]]/(2*b) - (Sqrt[a - b]*ArcTan[(Sqrt[a - b]*Tan[x])/Sqrt[a + b ]])/(2*b*Sqrt[a + b])
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]
Int[((a_) + (b_.)*(x_)^2 + (c_.)*(x_)^4)^(-1), x_Symbol] :> With[{q = Rt[b^ 2 - 4*a*c, 2]}, Simp[c/q Int[1/(b/2 - q/2 + c*x^2), x], x] - Simp[c/q I nt[1/(b/2 + q/2 + c*x^2), x], x]] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c , 0] && PosQ[b^2 - 4*a*c]
Int[u_, x_Symbol] :> With[{v = FunctionOfTrig[u, x]}, With[{d = FreeFactors [Tan[v], x]}, Simp[d/Coefficient[v, x, 1] Subst[Int[SubstFor[1/(1 + d^2*x ^2), Tan[v]/d, u, x], x], x, Tan[v]/d], x]] /; !FalseQ[v] && FunctionOfQ[N onfreeFactors[Tan[v], x], u, x]] /; InverseFunctionFreeQ[u, x] && !MatchQ[ u, (v_.)*((c_.)*tan[w_]^(n_.)*tan[z_]^(n_.))^(p_.) /; FreeQ[{c, p}, x] && I ntegerQ[n] && LinearQ[w, x] && EqQ[z, 2*w]]
Time = 1.73 (sec) , antiderivative size = 51, normalized size of antiderivative = 0.98
method | result | size |
default | \(\frac {\arctan \left (\tan \left (x \right )\right )}{2 b}+\frac {\left (b -a \right ) \arctan \left (\frac {\left (a -b \right ) \tan \left (x \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{2 b \sqrt {\left (a -b \right ) \left (a +b \right )}}\) | \(51\) |
risch | \(\frac {x}{2 b}+\frac {\sqrt {-\left (a -b \right ) \left (a +b \right )}\, \ln \left ({\mathrm e}^{2 i x}+\frac {i \sqrt {-\left (a -b \right ) \left (a +b \right )}+a}{b}\right )}{4 \left (a +b \right ) b}-\frac {\sqrt {-\left (a -b \right ) \left (a +b \right )}\, \ln \left ({\mathrm e}^{2 i x}-\frac {i \sqrt {-\left (a -b \right ) \left (a +b \right )}-a}{b}\right )}{4 \left (a +b \right ) b}\) | \(111\) |
Input:
int(cos(x)^2/(a+b*cos(2*x)),x,method=_RETURNVERBOSE)
Output:
1/2/b*arctan(tan(x))+1/2*(b-a)/b/((a-b)*(a+b))^(1/2)*arctan((a-b)*tan(x)/( (a-b)*(a+b))^(1/2))
Time = 0.10 (sec) , antiderivative size = 224, normalized size of antiderivative = 4.31 \[ \int \frac {\cos ^2(x)}{a+b \cos (2 x)} \, dx=\left [\frac {\sqrt {-\frac {a - b}{a + b}} \log \left (\frac {4 \, {\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{4} - 4 \, {\left (2 \, a^{2} - a b - b^{2}\right )} \cos \left (x\right )^{2} + 4 \, {\left (2 \, {\left (a^{2} + a b\right )} \cos \left (x\right )^{3} - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )\right )} \sqrt {-\frac {a - b}{a + b}} \sin \left (x\right ) + a^{2} - 2 \, a b + b^{2}}{4 \, b^{2} \cos \left (x\right )^{4} + 4 \, {\left (a b - b^{2}\right )} \cos \left (x\right )^{2} + a^{2} - 2 \, a b + b^{2}}\right ) + 4 \, x}{8 \, b}, -\frac {\sqrt {\frac {a - b}{a + b}} \arctan \left (-\frac {{\left (2 \, a \cos \left (x\right )^{2} - a + b\right )} \sqrt {\frac {a - b}{a + b}}}{2 \, {\left (a - b\right )} \cos \left (x\right ) \sin \left (x\right )}\right ) - 2 \, x}{4 \, b}\right ] \] Input:
integrate(cos(x)^2/(a+b*cos(2*x)),x, algorithm="fricas")
Output:
[1/8*(sqrt(-(a - b)/(a + b))*log((4*(2*a^2 - b^2)*cos(x)^4 - 4*(2*a^2 - a* b - b^2)*cos(x)^2 + 4*(2*(a^2 + a*b)*cos(x)^3 - (a^2 - b^2)*cos(x))*sqrt(- (a - b)/(a + b))*sin(x) + a^2 - 2*a*b + b^2)/(4*b^2*cos(x)^4 + 4*(a*b - b^ 2)*cos(x)^2 + a^2 - 2*a*b + b^2)) + 4*x)/b, -1/4*(sqrt((a - b)/(a + b))*ar ctan(-1/2*(2*a*cos(x)^2 - a + b)*sqrt((a - b)/(a + b))/((a - b)*cos(x)*sin (x))) - 2*x)/b]
Leaf count of result is larger than twice the leaf count of optimal. 148 vs. \(2 (39) = 78\).
Time = 15.57 (sec) , antiderivative size = 432, normalized size of antiderivative = 8.31 \[ \int \frac {\cos ^2(x)}{a+b \cos (2 x)} \, dx=\begin {cases} \tilde {\infty } \left (- \frac {\log {\left (\tan {\left (x \right )} - 1 \right )}}{2} + \frac {\log {\left (\tan {\left (x \right )} + 1 \right )}}{2}\right ) & \text {for}\: a = 0 \wedge b = 0 \\\frac {\tan {\left (x \right )}}{4 b} & \text {for}\: a = b \\\frac {1}{4 b \tan {\left (x \right )}} & \text {for}\: a = - b \\\frac {\log {\left (- \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (x \right )} \right )}}{4 a \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - 4 b \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {\log {\left (\sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (x \right )} \right )}}{4 a \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - 4 b \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} & \text {otherwise} \end {cases} + \begin {cases} \tilde {\infty } x & \text {for}\: a = 0 \wedge b = 0 \\\frac {x}{2 b} - \frac {\tan {\left (x \right )}}{4 b} & \text {for}\: a = b \\\frac {x}{2 b} + \frac {1}{4 b \tan {\left (x \right )}} & \text {for}\: a = - b \\\frac {\sin {\left (2 x \right )}}{4 a} & \text {for}\: b = 0 \\\frac {2 a x \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}}{4 a b \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - 4 b^{2} \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {a \log {\left (- \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (x \right )} \right )}}{4 a b \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - 4 b^{2} \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} + \frac {a \log {\left (\sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (x \right )} \right )}}{4 a b \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - 4 b^{2} \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {2 b x \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}}{4 a b \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - 4 b^{2} \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} & \text {otherwise} \end {cases} \] Input:
integrate(cos(x)**2/(a+b*cos(2*x)),x)
Output:
Piecewise((zoo*(-log(tan(x) - 1)/2 + log(tan(x) + 1)/2), Eq(a, 0) & Eq(b, 0)), (tan(x)/(4*b), Eq(a, b)), (1/(4*b*tan(x)), Eq(a, -b)), (log(-sqrt(-a/ (a - b) - b/(a - b)) + tan(x))/(4*a*sqrt(-a/(a - b) - b/(a - b)) - 4*b*sqr t(-a/(a - b) - b/(a - b))) - log(sqrt(-a/(a - b) - b/(a - b)) + tan(x))/(4 *a*sqrt(-a/(a - b) - b/(a - b)) - 4*b*sqrt(-a/(a - b) - b/(a - b))), True) ) + Piecewise((zoo*x, Eq(a, 0) & Eq(b, 0)), (x/(2*b) - tan(x)/(4*b), Eq(a, b)), (x/(2*b) + 1/(4*b*tan(x)), Eq(a, -b)), (sin(2*x)/(4*a), Eq(b, 0)), ( 2*a*x*sqrt(-a/(a - b) - b/(a - b))/(4*a*b*sqrt(-a/(a - b) - b/(a - b)) - 4 *b**2*sqrt(-a/(a - b) - b/(a - b))) - a*log(-sqrt(-a/(a - b) - b/(a - b)) + tan(x))/(4*a*b*sqrt(-a/(a - b) - b/(a - b)) - 4*b**2*sqrt(-a/(a - b) - b /(a - b))) + a*log(sqrt(-a/(a - b) - b/(a - b)) + tan(x))/(4*a*b*sqrt(-a/( a - b) - b/(a - b)) - 4*b**2*sqrt(-a/(a - b) - b/(a - b))) - 2*b*x*sqrt(-a /(a - b) - b/(a - b))/(4*a*b*sqrt(-a/(a - b) - b/(a - b)) - 4*b**2*sqrt(-a /(a - b) - b/(a - b))), True))
Exception generated. \[ \int \frac {\cos ^2(x)}{a+b \cos (2 x)} \, dx=\text {Exception raised: ValueError} \] Input:
integrate(cos(x)^2/(a+b*cos(2*x)),x, algorithm="maxima")
Output:
Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(4*a^2-4*b^2>0)', see `assume?` f or more de
Leaf count of result is larger than twice the leaf count of optimal. 159 vs. \(2 (40) = 80\).
Time = 0.12 (sec) , antiderivative size = 159, normalized size of antiderivative = 3.06 \[ \int \frac {\cos ^2(x)}{a+b \cos (2 x)} \, dx=-\frac {\sqrt {a^{2} - b^{2}} {\left (\pi \left \lfloor \frac {x}{\pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \tan \left (x\right )}{\sqrt {\frac {4 \, a + \sqrt {-16 \, {\left (a + b\right )} {\left (a - b\right )} + 16 \, a^{2}}}{a - b}}}\right )\right )} {\left | a - b \right |}}{2 \, {\left ({\left (a - b\right )} b^{2} + {\left (a^{2} - a b\right )} {\left | b \right |}\right )}} - \frac {{\left (\pi \left \lfloor \frac {x}{\pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \tan \left (x\right )}{\sqrt {\frac {4 \, a - \sqrt {-16 \, {\left (a + b\right )} {\left (a - b\right )} + 16 \, a^{2}}}{a - b}}}\right )\right )} {\left (a - b\right )}}{2 \, {\left (b^{2} - a {\left | b \right |}\right )}} \] Input:
integrate(cos(x)^2/(a+b*cos(2*x)),x, algorithm="giac")
Output:
-1/2*sqrt(a^2 - b^2)*(pi*floor(x/pi + 1/2) + arctan(2*tan(x)/sqrt((4*a + s qrt(-16*(a + b)*(a - b) + 16*a^2))/(a - b))))*abs(a - b)/((a - b)*b^2 + (a ^2 - a*b)*abs(b)) - 1/2*(pi*floor(x/pi + 1/2) + arctan(2*tan(x)/sqrt((4*a - sqrt(-16*(a + b)*(a - b) + 16*a^2))/(a - b))))*(a - b)/(b^2 - a*abs(b))
Time = 15.92 (sec) , antiderivative size = 684, normalized size of antiderivative = 13.15 \[ \int \frac {\cos ^2(x)}{a+b \cos (2 x)} \, dx=\frac {\mathrm {atan}\left (\frac {2\,a^2\,\mathrm {tan}\left (x\right )}{2\,a^2-4\,a\,b+2\,b^2}+\frac {2\,b^2\,\mathrm {tan}\left (x\right )}{2\,a^2-4\,a\,b+2\,b^2}-\frac {4\,a\,b\,\mathrm {tan}\left (x\right )}{2\,a^2-4\,a\,b+2\,b^2}\right )}{2\,b}+\frac {\mathrm {atan}\left (\frac {\frac {\left (\frac {\mathrm {tan}\left (x\right )\,\left (4\,a^3-12\,a^2\,b+12\,a\,b^2-4\,b^3\right )}{4}+\frac {\sqrt {b^2-a^2}\,\left (4\,b^4-8\,a\,b^3+4\,a^2\,b^2+\frac {\mathrm {tan}\left (x\right )\,\sqrt {b^2-a^2}\,\left (64\,a^3\,b^2-128\,a^2\,b^3+64\,a\,b^4\right )}{16\,\left (b^2+a\,b\right )}\right )}{4\,\left (b^2+a\,b\right )}\right )\,\sqrt {b^2-a^2}\,1{}\mathrm {i}}{b^2+a\,b}+\frac {\left (\frac {\mathrm {tan}\left (x\right )\,\left (4\,a^3-12\,a^2\,b+12\,a\,b^2-4\,b^3\right )}{4}+\frac {\sqrt {b^2-a^2}\,\left (8\,a\,b^3-4\,b^4-4\,a^2\,b^2+\frac {\mathrm {tan}\left (x\right )\,\sqrt {b^2-a^2}\,\left (64\,a^3\,b^2-128\,a^2\,b^3+64\,a\,b^4\right )}{16\,\left (b^2+a\,b\right )}\right )}{4\,\left (b^2+a\,b\right )}\right )\,\sqrt {b^2-a^2}\,1{}\mathrm {i}}{b^2+a\,b}}{\frac {\left (\frac {\mathrm {tan}\left (x\right )\,\left (4\,a^3-12\,a^2\,b+12\,a\,b^2-4\,b^3\right )}{4}+\frac {\sqrt {b^2-a^2}\,\left (4\,b^4-8\,a\,b^3+4\,a^2\,b^2+\frac {\mathrm {tan}\left (x\right )\,\sqrt {b^2-a^2}\,\left (64\,a^3\,b^2-128\,a^2\,b^3+64\,a\,b^4\right )}{16\,\left (b^2+a\,b\right )}\right )}{4\,\left (b^2+a\,b\right )}\right )\,\sqrt {b^2-a^2}}{b^2+a\,b}-\frac {\left (\frac {\mathrm {tan}\left (x\right )\,\left (4\,a^3-12\,a^2\,b+12\,a\,b^2-4\,b^3\right )}{4}+\frac {\sqrt {b^2-a^2}\,\left (8\,a\,b^3-4\,b^4-4\,a^2\,b^2+\frac {\mathrm {tan}\left (x\right )\,\sqrt {b^2-a^2}\,\left (64\,a^3\,b^2-128\,a^2\,b^3+64\,a\,b^4\right )}{16\,\left (b^2+a\,b\right )}\right )}{4\,\left (b^2+a\,b\right )}\right )\,\sqrt {b^2-a^2}}{b^2+a\,b}}\right )\,\sqrt {b^2-a^2}\,1{}\mathrm {i}}{2\,\left (b^2+a\,b\right )} \] Input:
int(cos(x)^2/(a + b*cos(2*x)),x)
Output:
atan((2*a^2*tan(x))/(2*a^2 - 4*a*b + 2*b^2) + (2*b^2*tan(x))/(2*a^2 - 4*a* b + 2*b^2) - (4*a*b*tan(x))/(2*a^2 - 4*a*b + 2*b^2))/(2*b) + (atan(((((tan (x)*(12*a*b^2 - 12*a^2*b + 4*a^3 - 4*b^3))/4 + ((b^2 - a^2)^(1/2)*(4*b^4 - 8*a*b^3 + 4*a^2*b^2 + (tan(x)*(b^2 - a^2)^(1/2)*(64*a*b^4 - 128*a^2*b^3 + 64*a^3*b^2))/(16*(a*b + b^2))))/(4*(a*b + b^2)))*(b^2 - a^2)^(1/2)*1i)/(a *b + b^2) + (((tan(x)*(12*a*b^2 - 12*a^2*b + 4*a^3 - 4*b^3))/4 + ((b^2 - a ^2)^(1/2)*(8*a*b^3 - 4*b^4 - 4*a^2*b^2 + (tan(x)*(b^2 - a^2)^(1/2)*(64*a*b ^4 - 128*a^2*b^3 + 64*a^3*b^2))/(16*(a*b + b^2))))/(4*(a*b + b^2)))*(b^2 - a^2)^(1/2)*1i)/(a*b + b^2))/((((tan(x)*(12*a*b^2 - 12*a^2*b + 4*a^3 - 4*b ^3))/4 + ((b^2 - a^2)^(1/2)*(4*b^4 - 8*a*b^3 + 4*a^2*b^2 + (tan(x)*(b^2 - a^2)^(1/2)*(64*a*b^4 - 128*a^2*b^3 + 64*a^3*b^2))/(16*(a*b + b^2))))/(4*(a *b + b^2)))*(b^2 - a^2)^(1/2))/(a*b + b^2) - (((tan(x)*(12*a*b^2 - 12*a^2* b + 4*a^3 - 4*b^3))/4 + ((b^2 - a^2)^(1/2)*(8*a*b^3 - 4*b^4 - 4*a^2*b^2 + (tan(x)*(b^2 - a^2)^(1/2)*(64*a*b^4 - 128*a^2*b^3 + 64*a^3*b^2))/(16*(a*b + b^2))))/(4*(a*b + b^2)))*(b^2 - a^2)^(1/2))/(a*b + b^2)))*(b^2 - a^2)^(1 /2)*1i)/(2*(a*b + b^2))
\[ \int \frac {\cos ^2(x)}{a+b \cos (2 x)} \, dx=\int \frac {\cos \left (x \right )^{2}}{\cos \left (2 x \right ) b +a}d x \] Input:
int(cos(x)^2/(a+b*cos(2*x)),x)
Output:
int(cos(x)**2/(cos(2*x)*b + a),x)