Integrand size = 22, antiderivative size = 84 \[ \int \frac {A+B \cos (x)}{a+b \cos (x)-i b \sin (x)} \, dx=\frac {(2 a A-b B) x}{2 a^2}-\frac {i B \cos (x)}{2 a}-\frac {i \left (2 a A b-a^2 B-b^2 B\right ) \log (a+b \cos (x)-i b \sin (x))}{2 a^2 b}+\frac {B \sin (x)}{2 a} \]
1/2*(2*A*a-B*b)*x/a^2-1/2*I*B*cos(x)/a-1/2*I*(2*A*a*b-B*a^2-B*b^2)*ln(a+b* cos(x)-I*b*sin(x))/a^2/b+1/2*B*sin(x)/a
Time = 0.19 (sec) , antiderivative size = 147, normalized size of antiderivative = 1.75 \[ \int \frac {A+B \cos (x)}{a+b \cos (x)-i b \sin (x)} \, dx=\frac {2 a A b x+a^2 B x-b^2 B x+2 \left (-2 a A b+a^2 B+b^2 B\right ) \arctan \left (\frac {(a+b) \cot \left (\frac {x}{2}\right )}{a-b}\right )-2 i a b B \cos (x)-2 i a A b \log \left (a^2+b^2+2 a b \cos (x)\right )+i a^2 B \log \left (a^2+b^2+2 a b \cos (x)\right )+i b^2 B \log \left (a^2+b^2+2 a b \cos (x)\right )+2 a b B \sin (x)}{4 a^2 b} \]
(2*a*A*b*x + a^2*B*x - b^2*B*x + 2*(-2*a*A*b + a^2*B + b^2*B)*ArcTan[((a + b)*Cot[x/2])/(a - b)] - (2*I)*a*b*B*Cos[x] - (2*I)*a*A*b*Log[a^2 + b^2 + 2*a*b*Cos[x]] + I*a^2*B*Log[a^2 + b^2 + 2*a*b*Cos[x]] + I*b^2*B*Log[a^2 + b^2 + 2*a*b*Cos[x]] + 2*a*b*B*Sin[x])/(4*a^2*b)
Time = 0.23 (sec) , antiderivative size = 84, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.091, Rules used = {3042, 3611}
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 {A+B \cos (x)}{a-i b \sin (x)+b \cos (x)} \, dx\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \int \frac {A+B \cos (x)}{a-i b \sin (x)+b \cos (x)}dx\) |
\(\Big \downarrow \) 3611 |
\(\displaystyle -\frac {i \left (a^2 (-B)+2 a A b-b^2 B\right ) \log (a-i b \sin (x)+b \cos (x))}{2 a^2 b}+\frac {x (2 a A-b B)}{2 a^2}+\frac {B \sin (x)}{2 a}-\frac {i B \cos (x)}{2 a}\) |
((2*a*A - b*B)*x)/(2*a^2) - ((I/2)*B*Cos[x])/a - ((I/2)*(2*a*A*b - a^2*B - b^2*B)*Log[a + b*Cos[x] - I*b*Sin[x]])/(a^2*b) + (B*Sin[x])/(2*a)
3.6.39.3.1 Defintions of rubi rules used
Int[((A_.) + cos[(d_.) + (e_.)*(x_)]*(B_.))/(cos[(d_.) + (e_.)*(x_)]*(b_.) + (a_) + (c_.)*sin[(d_.) + (e_.)*(x_)]), x_Symbol] :> Simp[(2*a*A - b*B)*(x /(2*a^2)), x] + (Simp[B*(Sin[d + e*x]/(2*a*e)), x] - Simp[b*B*(Cos[d + e*x] /(2*a*c*e)), x] + Simp[(a^2*B - 2*a*b*A + b^2*B)*(Log[RemoveContent[a + b*C os[d + e*x] + c*Sin[d + e*x], x]]/(2*a^2*c*e)), x]) /; FreeQ[{a, b, c, d, e , A, B}, x] && EqQ[b^2 + c^2, 0]
Time = 1.19 (sec) , antiderivative size = 79, normalized size of antiderivative = 0.94
method | result | size |
risch | \(-\frac {i B \,{\mathrm e}^{i x}}{2 a}+\frac {B x}{2 b}-\frac {i \ln \left ({\mathrm e}^{i x}+\frac {b}{a}\right ) A}{a}+\frac {i \ln \left ({\mathrm e}^{i x}+\frac {b}{a}\right ) B}{2 b}+\frac {i b \ln \left ({\mathrm e}^{i x}+\frac {b}{a}\right ) B}{2 a^{2}}\) | \(79\) |
default | \(-\frac {i B \ln \left (-i+\tan \left (\frac {x}{2}\right )\right )}{2 b}+\frac {i \left (2 A a -B b \right ) \ln \left (\tan \left (\frac {x}{2}\right )+i\right )}{2 a^{2}}+\frac {B}{a \left (\tan \left (\frac {x}{2}\right )+i\right )}+\frac {i \left (2 A a b -B \,a^{2}-B \,b^{2}\right ) \left (a -b \right ) \ln \left (i a +i b -a \tan \left (\frac {x}{2}\right )+b \tan \left (\frac {x}{2}\right )\right )}{2 a^{2} b \left (-a +b \right )}\) | \(116\) |
-1/2*I*B/a*exp(I*x)+1/2*B*x/b-I/a*ln(exp(I*x)+b/a)*A+1/2*I/b*ln(exp(I*x)+b /a)*B+1/2*I/a^2*b*ln(exp(I*x)+b/a)*B
Time = 0.25 (sec) , antiderivative size = 56, normalized size of antiderivative = 0.67 \[ \int \frac {A+B \cos (x)}{a+b \cos (x)-i b \sin (x)} \, dx=\frac {B a^{2} x - i \, B a b e^{\left (i \, x\right )} + {\left (i \, B a^{2} - 2 i \, A a b + i \, B b^{2}\right )} \log \left (\frac {a e^{\left (i \, x\right )} + b}{a}\right )}{2 \, a^{2} b} \]
1/2*(B*a^2*x - I*B*a*b*e^(I*x) + (I*B*a^2 - 2*I*A*a*b + I*B*b^2)*log((a*e^ (I*x) + b)/a))/(a^2*b)
Time = 0.31 (sec) , antiderivative size = 73, normalized size of antiderivative = 0.87 \[ \int \frac {A+B \cos (x)}{a+b \cos (x)-i b \sin (x)} \, dx=\frac {B x}{2 b} + \begin {cases} - \frac {i B e^{i x}}{2 a} & \text {for}\: a \neq 0 \\x \left (- \frac {B}{2 b} + \frac {B a + B b}{2 a b}\right ) & \text {otherwise} \end {cases} + \frac {i \left (- 2 A a b + B a^{2} + B b^{2}\right ) \log {\left (e^{i x} + \frac {b}{a} \right )}}{2 a^{2} b} \]
B*x/(2*b) + Piecewise((-I*B*exp(I*x)/(2*a), Ne(a, 0)), (x*(-B/(2*b) + (B*a + B*b)/(2*a*b)), True)) + I*(-2*A*a*b + B*a**2 + B*b**2)*log(exp(I*x) + b /a)/(2*a**2*b)
Exception generated. \[ \int \frac {A+B \cos (x)}{a+b \cos (x)-i b \sin (x)} \, dx=\text {Exception raised: RuntimeError} \]
Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 168 vs. \(2 (70) = 140\).
Time = 0.28 (sec) , antiderivative size = 168, normalized size of antiderivative = 2.00 \[ \int \frac {A+B \cos (x)}{a+b \cos (x)-i b \sin (x)} \, dx=-\frac {{\left (2 i \, A a - i \, B b\right )} \log \left (-a \tan \left (\frac {1}{2} \, x\right )^{2} + b \tan \left (\frac {1}{2} \, x\right )^{2} + 2 i \, a \tan \left (\frac {1}{2} \, x\right ) + a + b\right )}{4 \, a^{2}} - \frac {{\left (-2 i \, A a + i \, B b\right )} \log \left (\tan \left (\frac {1}{2} \, x\right ) + i\right )}{2 \, a^{2}} + \frac {{\left (2 \, B a^{2} - 2 \, A a b + B b^{2}\right )} {\left (x + 2 \, \arctan \left (\frac {i \, a \cos \left (x\right ) - a \sin \left (x\right ) + i \, a}{a \cos \left (x\right ) + i \, a \sin \left (x\right ) - a + 2 \, b}\right )\right )}}{4 \, a^{2} b} - \frac {2 i \, A a \tan \left (\frac {1}{2} \, x\right ) - i \, B b \tan \left (\frac {1}{2} \, x\right ) - 2 \, A a - 2 \, B a + B b}{2 \, a^{2} {\left (\tan \left (\frac {1}{2} \, x\right ) + i\right )}} \]
-1/4*(2*I*A*a - I*B*b)*log(-a*tan(1/2*x)^2 + b*tan(1/2*x)^2 + 2*I*a*tan(1/ 2*x) + a + b)/a^2 - 1/2*(-2*I*A*a + I*B*b)*log(tan(1/2*x) + I)/a^2 + 1/4*( 2*B*a^2 - 2*A*a*b + B*b^2)*(x + 2*arctan((I*a*cos(x) - a*sin(x) + I*a)/(a* cos(x) + I*a*sin(x) - a + 2*b)))/(a^2*b) - 1/2*(2*I*A*a*tan(1/2*x) - I*B*b *tan(1/2*x) - 2*A*a - 2*B*a + B*b)/(a^2*(tan(1/2*x) + I))
Time = 33.71 (sec) , antiderivative size = 584, normalized size of antiderivative = 6.95 \[ \int \frac {A+B \cos (x)}{a+b \cos (x)-i b \sin (x)} \, dx=\left (\sum _{k=1}^3\ln \left (-{\left (a-b\right )}^2\,\left (4\,A^2\,a^2-4\,A\,B\,a\,b-B^2\,a^2+B^2\,b^2\right )\,1{}\mathrm {i}-\mathrm {root}\left (a^4\,b^2\,d^3\,64{}\mathrm {i}-A\,B\,a\,b^3\,d\,64{}\mathrm {i}-A\,B\,a^3\,b\,d\,32{}\mathrm {i}+B^2\,a^2\,b^2\,d\,16{}\mathrm {i}+A^2\,a^2\,b^2\,d\,64{}\mathrm {i}+B^2\,b^4\,d\,16{}\mathrm {i}+B^2\,a^4\,d\,16{}\mathrm {i}-32\,A^2\,B\,a^2\,b+32\,A\,B^2\,a\,b^2-8\,B^3\,a^2\,b+16\,A\,B^2\,a^3-8\,B^3\,b^3,d,k\right )\,\left (4\,A\,a^3\,{\left (a-b\right )}^2-\mathrm {root}\left (a^4\,b^2\,d^3\,64{}\mathrm {i}-A\,B\,a\,b^3\,d\,64{}\mathrm {i}-A\,B\,a^3\,b\,d\,32{}\mathrm {i}+B^2\,a^2\,b^2\,d\,16{}\mathrm {i}+A^2\,a^2\,b^2\,d\,64{}\mathrm {i}+B^2\,b^4\,d\,16{}\mathrm {i}+B^2\,a^4\,d\,16{}\mathrm {i}-32\,A^2\,B\,a^2\,b+32\,A\,B^2\,a\,b^2-8\,B^3\,a^2\,b+16\,A\,B^2\,a^3-8\,B^3\,b^3,d,k\right )\,a^2\,{\left (a-b\right )}^2\,\left (a^2\,\mathrm {tan}\left (\frac {x}{2}\right )+b^2\,\mathrm {tan}\left (\frac {x}{2}\right )-a\,b\,\mathrm {tan}\left (\frac {x}{2}\right )-a^2\,1{}\mathrm {i}+b^2\,1{}\mathrm {i}\right )\,8+4\,a\,\mathrm {tan}\left (\frac {x}{2}\right )\,{\left (a-b\right )}^2\,\left (A\,a^2\,1{}\mathrm {i}+B\,a^2\,1{}\mathrm {i}+B\,b^2\,1{}\mathrm {i}-A\,a\,b\,2{}\mathrm {i}-B\,a\,b\,1{}\mathrm {i}\right )\right )+\mathrm {tan}\left (\frac {x}{2}\right )\,{\left (a-b\right )}^2\,{\left (B\,a-2\,A\,a+B\,b\right )}^2\right )\,\mathrm {root}\left (a^4\,b^2\,d^3\,64{}\mathrm {i}-A\,B\,a\,b^3\,d\,64{}\mathrm {i}-A\,B\,a^3\,b\,d\,32{}\mathrm {i}+B^2\,a^2\,b^2\,d\,16{}\mathrm {i}+A^2\,a^2\,b^2\,d\,64{}\mathrm {i}+B^2\,b^4\,d\,16{}\mathrm {i}+B^2\,a^4\,d\,16{}\mathrm {i}-32\,A^2\,B\,a^2\,b+32\,A\,B^2\,a\,b^2-8\,B^3\,a^2\,b+16\,A\,B^2\,a^3-8\,B^3\,b^3,d,k\right )\right )+\frac {B}{a\,\left (\mathrm {tan}\left (\frac {x}{2}\right )+1{}\mathrm {i}\right )} \]
symsum(log(tan(x/2)*(a - b)^2*(B*a - 2*A*a + B*b)^2 - root(a^4*b^2*d^3*64i - A*B*a*b^3*d*64i - A*B*a^3*b*d*32i + B^2*a^2*b^2*d*16i + A^2*a^2*b^2*d*6 4i + B^2*b^4*d*16i + B^2*a^4*d*16i - 32*A^2*B*a^2*b + 32*A*B^2*a*b^2 - 8*B ^3*a^2*b + 16*A*B^2*a^3 - 8*B^3*b^3, d, k)*(4*A*a^3*(a - b)^2 - 8*root(a^4 *b^2*d^3*64i - A*B*a*b^3*d*64i - A*B*a^3*b*d*32i + B^2*a^2*b^2*d*16i + A^2 *a^2*b^2*d*64i + B^2*b^4*d*16i + B^2*a^4*d*16i - 32*A^2*B*a^2*b + 32*A*B^2 *a*b^2 - 8*B^3*a^2*b + 16*A*B^2*a^3 - 8*B^3*b^3, d, k)*a^2*(a - b)^2*(a^2* tan(x/2) + b^2*tan(x/2) - a^2*1i + b^2*1i - a*b*tan(x/2)) + 4*a*tan(x/2)*( a - b)^2*(A*a^2*1i + B*a^2*1i + B*b^2*1i - A*a*b*2i - B*a*b*1i)) - (a - b) ^2*(4*A^2*a^2 - B^2*a^2 + B^2*b^2 - 4*A*B*a*b)*1i)*root(a^4*b^2*d^3*64i - A*B*a*b^3*d*64i - A*B*a^3*b*d*32i + B^2*a^2*b^2*d*16i + A^2*a^2*b^2*d*64i + B^2*b^4*d*16i + B^2*a^4*d*16i - 32*A^2*B*a^2*b + 32*A*B^2*a*b^2 - 8*B^3* a^2*b + 16*A*B^2*a^3 - 8*B^3*b^3, d, k), k, 1, 3) + B/(a*(tan(x/2) + 1i))