Integrand size = 25, antiderivative size = 92 \[ \int \frac {B \cos (x)+C \sin (x)}{a+b \cos (x)+i b \sin (x)} \, dx=-\frac {b (B+i C) x}{2 a^2}-\frac {\left (i b^2 (B+i C)+a^2 (i B+C)\right ) \log (a+b \cos (x)+i b \sin (x))}{2 a^2 b}+\frac {(i B-C) (\cos (x)-i \sin (x))}{2 a} \] Output:
-1/2*b*(B+I*C)*x/a^2-1/2*(I*b^2*(B+I*C)+a^2*(I*B+C))*ln(a+b*cos(x)+I*b*sin (x))/a^2/b+1/2*(I*B-C)*(cos(x)-I*sin(x))/a
Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(195\) vs. \(2(92)=184\).
Time = 0.48 (sec) , antiderivative size = 195, normalized size of antiderivative = 2.12 \[ \int \frac {B \cos (x)+C \sin (x)}{a+b \cos (x)+i b \sin (x)} \, dx=\frac {\left (a^2 B-b^2 B-i a^2 C-i b^2 C\right ) x}{4 a^2 b}-\frac {\left (a^2 B+b^2 B-i a^2 C+i b^2 C\right ) \arctan \left (\frac {(a+b) \cos \left (\frac {x}{2}\right )}{-a \sin \left (\frac {x}{2}\right )+b \sin \left (\frac {x}{2}\right )}\right )}{2 a^2 b}+\frac {i (B+i C) \cos (x)}{2 a}-\frac {i \left (a^2 B+b^2 B-i a^2 C+i b^2 C\right ) \log \left (a^2+b^2+2 a b \cos (x)\right )}{4 a^2 b}+\frac {(B+i C) \sin (x)}{2 a} \] Input:
Integrate[(B*Cos[x] + C*Sin[x])/(a + b*Cos[x] + I*b*Sin[x]),x]
Output:
((a^2*B - b^2*B - I*a^2*C - I*b^2*C)*x)/(4*a^2*b) - ((a^2*B + b^2*B - I*a^ 2*C + I*b^2*C)*ArcTan[((a + b)*Cos[x/2])/(-(a*Sin[x/2]) + b*Sin[x/2])])/(2 *a^2*b) + ((I/2)*(B + I*C)*Cos[x])/a - ((I/4)*(a^2*B + b^2*B - I*a^2*C + I *b^2*C)*Log[a^2 + b^2 + 2*a*b*Cos[x]])/(a^2*b) + ((B + I*C)*Sin[x])/(2*a)
Time = 0.26 (sec) , antiderivative size = 87, normalized size of antiderivative = 0.95, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.080, Rules used = {3042, 3609}
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 {B \cos (x)+C \sin (x)}{a+i b \sin (x)+b \cos (x)} \, dx\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \int \frac {B \cos (x)+C \sin (x)}{a+i b \sin (x)+b \cos (x)}dx\) |
\(\Big \downarrow \) 3609 |
\(\displaystyle -\frac {\left (\frac {i b^2 (B+i C)}{a^2}+i B+C\right ) \log (a+i b \sin (x)+b \cos (x))}{2 b}-\frac {b x (B+i C)}{2 a^2}+\frac {(-C+i B) (\cos (x)-i \sin (x))}{2 a}\) |
Input:
Int[(B*Cos[x] + C*Sin[x])/(a + b*Cos[x] + I*b*Sin[x]),x]
Output:
-1/2*(b*(B + I*C)*x)/a^2 - ((I*B + (I*b^2*(B + I*C))/a^2 + C)*Log[a + b*Co s[x] + I*b*Sin[x]])/(2*b) + ((I*B - C)*(Cos[x] - I*Sin[x]))/(2*a)
Int[((A_.) + cos[(d_.) + (e_.)*(x_)]*(B_.) + (C_.)*sin[(d_.) + (e_.)*(x_)]) /(cos[(d_.) + (e_.)*(x_)]*(b_.) + (a_) + (c_.)*sin[(d_.) + (e_.)*(x_)]), x_ Symbol] :> Simp[(2*a*A - b*B - c*C)*(x/(2*a^2)), x] + (-Simp[(b*B + c*C)*(( b*Cos[d + e*x] - c*Sin[d + e*x])/(2*a*b*c*e)), x] + Simp[(a^2*(b*B - c*C) - 2*a*A*b^2 + b^2*(b*B + c*C))*(Log[RemoveContent[a + b*Cos[d + e*x] + c*Sin [d + e*x], x]]/(2*a^2*b*c*e)), x]) /; FreeQ[{a, b, c, d, e, A, B, C}, x] && EqQ[b^2 + c^2, 0]
Time = 0.29 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.28
method | result | size |
risch | \(-\frac {C \,{\mathrm e}^{-i x}}{2 a}+\frac {i B \,{\mathrm e}^{-i x}}{2 a}-\frac {i b x C}{2 a^{2}}-\frac {b x B}{2 a^{2}}-\frac {\ln \left ({\mathrm e}^{i x}+\frac {a}{b}\right ) C}{2 b}+\frac {b \ln \left ({\mathrm e}^{i x}+\frac {a}{b}\right ) C}{2 a^{2}}-\frac {i \ln \left ({\mathrm e}^{i x}+\frac {a}{b}\right ) B}{2 b}-\frac {i b \ln \left ({\mathrm e}^{i x}+\frac {a}{b}\right ) B}{2 a^{2}}\) | \(118\) |
default | \(\frac {i \left (-i C +B \right ) \ln \left (\tan \left (\frac {x}{2}\right )+i\right )}{2 b}+\frac {b \left (i B -C \right ) \ln \left (-i+\tan \left (\frac {x}{2}\right )\right )}{2 a^{2}}-\frac {-i C -B}{a \left (-i+\tan \left (\frac {x}{2}\right )\right )}-\frac {i \left (-i C \,a^{2}+i C \,b^{2}+B \,a^{2}+B \,b^{2}\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}\) | \(123\) |
Input:
int((B*cos(x)+C*sin(x))/(a+b*cos(x)+I*b*sin(x)),x,method=_RETURNVERBOSE)
Output:
-1/2*C/a*exp(-I*x)+1/2*I*B/a*exp(-I*x)-1/2*I/a^2*b*x*C-1/2/a^2*b*x*B-1/2/b *ln(exp(I*x)+a/b)*C+1/2/a^2*b*ln(exp(I*x)+a/b)*C-1/2*I/b*ln(exp(I*x)+a/b)* B-1/2*I/a^2*b*ln(exp(I*x)+a/b)*B
Time = 0.07 (sec) , antiderivative size = 78, normalized size of antiderivative = 0.85 \[ \int \frac {B \cos (x)+C \sin (x)}{a+b \cos (x)+i b \sin (x)} \, dx=-\frac {{\left ({\left (B + i \, C\right )} b^{2} x e^{\left (i \, x\right )} - {\left (i \, B - C\right )} a b - {\left ({\left (-i \, B - C\right )} a^{2} + {\left (-i \, B + C\right )} b^{2}\right )} e^{\left (i \, x\right )} \log \left (\frac {b e^{\left (i \, x\right )} + a}{b}\right )\right )} e^{\left (-i \, x\right )}}{2 \, a^{2} b} \] Input:
integrate((B*cos(x)+C*sin(x))/(a+b*cos(x)+I*b*sin(x)),x, algorithm="fricas ")
Output:
-1/2*((B + I*C)*b^2*x*e^(I*x) - (I*B - C)*a*b - ((-I*B - C)*a^2 + (-I*B + C)*b^2)*e^(I*x)*log((b*e^(I*x) + a)/b))*e^(-I*x)/(a^2*b)
Time = 0.44 (sec) , antiderivative size = 110, normalized size of antiderivative = 1.20 \[ \int \frac {B \cos (x)+C \sin (x)}{a+b \cos (x)+i b \sin (x)} \, dx=\begin {cases} \frac {\left (i B - C\right ) e^{- i x}}{2 a} & \text {for}\: a \neq 0 \\x \left (- \frac {- B b - i C b}{2 a^{2}} + \frac {B a - B b + i C a - i C b}{2 a^{2}}\right ) & \text {otherwise} \end {cases} + \frac {x \left (- B b - i C b\right )}{2 a^{2}} - \frac {i \left (B a^{2} + B b^{2} - i C a^{2} + i C b^{2}\right ) \log {\left (\frac {a}{b} + e^{i x} \right )}}{2 a^{2} b} \] Input:
integrate((B*cos(x)+C*sin(x))/(a+b*cos(x)+I*b*sin(x)),x)
Output:
Piecewise(((I*B - C)*exp(-I*x)/(2*a), Ne(a, 0)), (x*(-(-B*b - I*C*b)/(2*a* *2) + (B*a - B*b + I*C*a - I*C*b)/(2*a**2)), True)) + x*(-B*b - I*C*b)/(2* a**2) - I*(B*a**2 + B*b**2 - I*C*a**2 + I*C*b**2)*log(a/b + exp(I*x))/(2*a **2*b)
Exception generated. \[ \int \frac {B \cos (x)+C \sin (x)}{a+b \cos (x)+i b \sin (x)} \, dx=\text {Exception raised: RuntimeError} \] Input:
integrate((B*cos(x)+C*sin(x))/(a+b*cos(x)+I*b*sin(x)),x, algorithm="maxima ")
Output:
Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negati ve exponent.
Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 178 vs. \(2 (70) = 140\).
Time = 0.27 (sec) , antiderivative size = 178, normalized size of antiderivative = 1.93 \[ \int \frac {B \cos (x)+C \sin (x)}{a+b \cos (x)+i b \sin (x)} \, dx=-\frac {{\left (i \, B b - C 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 (-i \, B b + C b\right )} \log \left (\tan \left (\frac {1}{2} \, x\right ) - i\right )}{2 \, a^{2}} + \frac {{\left (2 \, B a^{2} - 2 i \, C a^{2} + B b^{2} + i \, C 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 {i \, B b \tan \left (\frac {1}{2} \, x\right ) - C b \tan \left (\frac {1}{2} \, x\right ) - 2 \, B a - 2 i \, C a + B b + i \, C b}{2 \, a^{2} {\left (\tan \left (\frac {1}{2} \, x\right ) - i\right )}} \] Input:
integrate((B*cos(x)+C*sin(x))/(a+b*cos(x)+I*b*sin(x)),x, algorithm="giac")
Output:
-1/4*(I*B*b - C*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*(-I*B*b + C*b)*log(tan(1/2*x) - I)/a^2 + 1/4*(2*B*a^2 - 2*I*C*a^2 + B*b^2 + I*C*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*(I*B*b*tan(1/2*x) - C* b*tan(1/2*x) - 2*B*a - 2*I*C*a + B*b + I*C*b)/(a^2*(tan(1/2*x) - I))
Time = 18.88 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.28 \[ \int \frac {B \cos (x)+C \sin (x)}{a+b \cos (x)+i b \sin (x)} \, dx=-\ln \left (a+b-a\,\mathrm {tan}\left (\frac {x}{2}\right )\,1{}\mathrm {i}+b\,\mathrm {tan}\left (\frac {x}{2}\right )\,1{}\mathrm {i}\right )\,\left (\frac {\frac {C}{2}+\frac {B\,1{}\mathrm {i}}{2}}{b}+\frac {-\frac {C\,b^2}{2}+\frac {B\,b^2\,1{}\mathrm {i}}{2}}{a^2\,b}\right )+\frac {B+C\,1{}\mathrm {i}}{a\,\left (\mathrm {tan}\left (\frac {x}{2}\right )-\mathrm {i}\right )}+\frac {\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )+1{}\mathrm {i}\right )\,\left (C+B\,1{}\mathrm {i}\right )}{2\,b}+\frac {\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )-\mathrm {i}\right )\,\left (-C\,b+B\,b\,1{}\mathrm {i}\right )}{2\,a^2} \] Input:
int((B*cos(x) + C*sin(x))/(a + b*cos(x) + b*sin(x)*1i),x)
Output:
(B + C*1i)/(a*(tan(x/2) - 1i)) - log(a + b - a*tan(x/2)*1i + b*tan(x/2)*1i )*(((B*1i)/2 + C/2)/b + ((B*b^2*1i)/2 - (C*b^2)/2)/(a^2*b)) + (log(tan(x/2 ) + 1i)*(B*1i + C))/(2*b) + (log(tan(x/2) - 1i)*(B*b*1i - C*b))/(2*a^2)
\[ \int \frac {B \cos (x)+C \sin (x)}{a+b \cos (x)+i b \sin (x)} \, dx=\frac {2 \left (\int \frac {1}{\tan \left (\frac {x}{2}\right )^{2} a -\tan \left (\frac {x}{2}\right )^{2} b +2 \tan \left (\frac {x}{2}\right ) b i +a +b}d x \right ) a \,b^{2}+2 \left (\int \frac {1}{\tan \left (\frac {x}{2}\right )^{2} a -\tan \left (\frac {x}{2}\right )^{2} b +2 \tan \left (\frac {x}{2}\right ) b i +a +b}d x \right ) a b c i +\mathrm {log}\left (\tan \left (\frac {x}{2}\right )^{2}+1\right ) a c +\mathrm {log}\left (\tan \left (\frac {x}{2}\right )^{2}+1\right ) b^{2} i -\mathrm {log}\left (\tan \left (\frac {x}{2}\right )^{2}+1\right ) b c -\mathrm {log}\left (\tan \left (\frac {x}{2}\right )^{2} a -\tan \left (\frac {x}{2}\right )^{2} b +2 \tan \left (\frac {x}{2}\right ) b i +a +b \right ) a c -\mathrm {log}\left (\tan \left (\frac {x}{2}\right )^{2} a -\tan \left (\frac {x}{2}\right )^{2} b +2 \tan \left (\frac {x}{2}\right ) b i +a +b \right ) b^{2} i +\mathrm {log}\left (\tan \left (\frac {x}{2}\right )^{2} a -\tan \left (\frac {x}{2}\right )^{2} b +2 \tan \left (\frac {x}{2}\right ) b i +a +b \right ) b c -b^{2} x -b c i x}{a b} \] Input:
int((B*cos(x)+C*sin(x))/(a+b*cos(x)+I*b*sin(x)),x)
Output:
(2*int(1/(tan(x/2)**2*a - tan(x/2)**2*b + 2*tan(x/2)*b*i + a + b),x)*a*b** 2 + 2*int(1/(tan(x/2)**2*a - tan(x/2)**2*b + 2*tan(x/2)*b*i + a + b),x)*a* b*c*i + log(tan(x/2)**2 + 1)*a*c + log(tan(x/2)**2 + 1)*b**2*i - log(tan(x /2)**2 + 1)*b*c - log(tan(x/2)**2*a - tan(x/2)**2*b + 2*tan(x/2)*b*i + a + b)*a*c - log(tan(x/2)**2*a - tan(x/2)**2*b + 2*tan(x/2)*b*i + a + b)*b**2 *i + log(tan(x/2)**2*a - tan(x/2)**2*b + 2*tan(x/2)*b*i + a + b)*b*c - b** 2*x - b*c*i*x)/(a*b)