3.532 \(\int \frac{A+B \cos (x)+C \sin (x)}{b \cos (x)+c \sin (x)} \, dx\)

Optimal. Leaf size=84 \[ -\frac{A \tanh ^{-1}\left (\frac{c \cos (x)-b \sin (x)}{\sqrt{b^2+c^2}}\right )}{\sqrt{b^2+c^2}}+\frac{x (b B+c C)}{b^2+c^2}+\frac{(B c-b C) \log (b \cos (x)+c \sin (x))}{b^2+c^2} \]

[Out]

((b*B + c*C)*x)/(b^2 + c^2) - (A*ArcTanh[(c*Cos[x] - b*Sin[x])/Sqrt[b^2 + c^2]])/Sqrt[b^2 + c^2] + ((B*c - b*C
)*Log[b*Cos[x] + c*Sin[x]])/(b^2 + c^2)

________________________________________________________________________________________

Rubi [A]  time = 0.0584858, antiderivative size = 84, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 22, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.136, Rules used = {3136, 3074, 206} \[ -\frac{A \tanh ^{-1}\left (\frac{c \cos (x)-b \sin (x)}{\sqrt{b^2+c^2}}\right )}{\sqrt{b^2+c^2}}+\frac{x (b B+c C)}{b^2+c^2}+\frac{(B c-b C) \log (b \cos (x)+c \sin (x))}{b^2+c^2} \]

Antiderivative was successfully verified.

[In]

Int[(A + B*Cos[x] + C*Sin[x])/(b*Cos[x] + c*Sin[x]),x]

[Out]

((b*B + c*C)*x)/(b^2 + c^2) - (A*ArcTanh[(c*Cos[x] - b*Sin[x])/Sqrt[b^2 + c^2]])/Sqrt[b^2 + c^2] + ((B*c - b*C
)*Log[b*Cos[x] + c*Sin[x]])/(b^2 + c^2)

Rule 3136

Int[((A_.) + cos[(d_.) + (e_.)*(x_)]*(B_.) + (C_.)*sin[(d_.) + (e_.)*(x_)])/((a_.) + cos[(d_.) + (e_.)*(x_)]*(
b_.) + (c_.)*sin[(d_.) + (e_.)*(x_)]), x_Symbol] :> Simp[((b*B + c*C)*x)/(b^2 + c^2), x] + (Dist[(A*(b^2 + c^2
) - a*(b*B + c*C))/(b^2 + c^2), Int[1/(a + b*Cos[d + e*x] + c*Sin[d + e*x]), x], x] + Simp[((c*B - b*C)*Log[a
+ b*Cos[d + e*x] + c*Sin[d + e*x]])/(e*(b^2 + c^2)), x]) /; FreeQ[{a, b, c, d, e, A, B, C}, x] && NeQ[b^2 + c^
2, 0] && NeQ[A*(b^2 + c^2) - a*(b*B + c*C), 0]

Rule 3074

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

Rule 206

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1*ArcTanh[(Rt[-b, 2]*x)/Rt[a, 2]])/(Rt[a, 2]*Rt[-b, 2]), x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rubi steps

\begin{align*} \int \frac{A+B \cos (x)+C \sin (x)}{b \cos (x)+c \sin (x)} \, dx &=\frac{(b B+c C) x}{b^2+c^2}+\frac{(B c-b C) \log (b \cos (x)+c \sin (x))}{b^2+c^2}+A \int \frac{1}{b \cos (x)+c \sin (x)} \, dx\\ &=\frac{(b B+c C) x}{b^2+c^2}+\frac{(B c-b C) \log (b \cos (x)+c \sin (x))}{b^2+c^2}-A \operatorname{Subst}\left (\int \frac{1}{b^2+c^2-x^2} \, dx,x,c \cos (x)-b \sin (x)\right )\\ &=\frac{(b B+c C) x}{b^2+c^2}-\frac{A \tanh ^{-1}\left (\frac{c \cos (x)-b \sin (x)}{\sqrt{b^2+c^2}}\right )}{\sqrt{b^2+c^2}}+\frac{(B c-b C) \log (b \cos (x)+c \sin (x))}{b^2+c^2}\\ \end{align*}

Mathematica [A]  time = 0.219391, size = 78, normalized size = 0.93 \[ \frac{2 A \sqrt{b^2+c^2} \tanh ^{-1}\left (\frac{b \tan \left (\frac{x}{2}\right )-c}{\sqrt{b^2+c^2}}\right )+x (b B+c C)+(B c-b C) \log (b \cos (x)+c \sin (x))}{b^2+c^2} \]

Antiderivative was successfully verified.

[In]

Integrate[(A + B*Cos[x] + C*Sin[x])/(b*Cos[x] + c*Sin[x]),x]

[Out]

((b*B + c*C)*x + 2*A*Sqrt[b^2 + c^2]*ArcTanh[(-c + b*Tan[x/2])/Sqrt[b^2 + c^2]] + (B*c - b*C)*Log[b*Cos[x] + c
*Sin[x]])/(b^2 + c^2)

________________________________________________________________________________________

Maple [B]  time = 0.06, size = 222, normalized size = 2.6 \begin{align*}{\frac{Bc}{{b}^{2}+{c}^{2}}\ln \left ( b \left ( \tan \left ({\frac{x}{2}} \right ) \right ) ^{2}-2\,c\tan \left ( x/2 \right ) -b \right ) }-{\frac{bC}{{b}^{2}+{c}^{2}}\ln \left ( b \left ( \tan \left ({\frac{x}{2}} \right ) \right ) ^{2}-2\,c\tan \left ( x/2 \right ) -b \right ) }+2\,{\frac{A{b}^{2}}{ \left ({b}^{2}+{c}^{2} \right ) ^{3/2}}{\it Artanh} \left ( 1/2\,{\frac{2\,b\tan \left ( x/2 \right ) -2\,c}{\sqrt{{b}^{2}+{c}^{2}}}} \right ) }+2\,{\frac{A{c}^{2}}{ \left ({b}^{2}+{c}^{2} \right ) ^{3/2}}{\it Artanh} \left ( 1/2\,{\frac{2\,b\tan \left ( x/2 \right ) -2\,c}{\sqrt{{b}^{2}+{c}^{2}}}} \right ) }-{\frac{Bc}{{b}^{2}+{c}^{2}}\ln \left ( 1+ \left ( \tan \left ({\frac{x}{2}} \right ) \right ) ^{2} \right ) }+{\frac{bC}{{b}^{2}+{c}^{2}}\ln \left ( 1+ \left ( \tan \left ({\frac{x}{2}} \right ) \right ) ^{2} \right ) }+2\,{\frac{bB\arctan \left ( \tan \left ( x/2 \right ) \right ) }{{b}^{2}+{c}^{2}}}+2\,{\frac{Cc\arctan \left ( \tan \left ( x/2 \right ) \right ) }{{b}^{2}+{c}^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A+B*cos(x)+C*sin(x))/(b*cos(x)+c*sin(x)),x)

[Out]

1/(b^2+c^2)*B*c*ln(b*tan(1/2*x)^2-2*c*tan(1/2*x)-b)-1/(b^2+c^2)*b*C*ln(b*tan(1/2*x)^2-2*c*tan(1/2*x)-b)+2/(b^2
+c^2)^(3/2)*arctanh(1/2*(2*b*tan(1/2*x)-2*c)/(b^2+c^2)^(1/2))*A*b^2+2/(b^2+c^2)^(3/2)*arctanh(1/2*(2*b*tan(1/2
*x)-2*c)/(b^2+c^2)^(1/2))*A*c^2-B/(b^2+c^2)*c*ln(1+tan(1/2*x)^2)+C/(b^2+c^2)*b*ln(1+tan(1/2*x)^2)+2*B/(b^2+c^2
)*b*arctan(tan(1/2*x))+2*C/(b^2+c^2)*c*arctan(tan(1/2*x))

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*cos(x)+C*sin(x))/(b*cos(x)+c*sin(x)),x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [A]  time = 2.13355, size = 379, normalized size = 4.51 \begin{align*} \frac{\sqrt{b^{2} + c^{2}} A \log \left (-\frac{2 \, b c \cos \left (x\right ) \sin \left (x\right ) +{\left (b^{2} - c^{2}\right )} \cos \left (x\right )^{2} - 2 \, b^{2} - c^{2} + 2 \, \sqrt{b^{2} + c^{2}}{\left (c \cos \left (x\right ) - b \sin \left (x\right )\right )}}{2 \, b c \cos \left (x\right ) \sin \left (x\right ) +{\left (b^{2} - c^{2}\right )} \cos \left (x\right )^{2} + c^{2}}\right ) + 2 \,{\left (B b + C c\right )} x -{\left (C b - B c\right )} \log \left (2 \, b c \cos \left (x\right ) \sin \left (x\right ) +{\left (b^{2} - c^{2}\right )} \cos \left (x\right )^{2} + c^{2}\right )}{2 \,{\left (b^{2} + c^{2}\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*cos(x)+C*sin(x))/(b*cos(x)+c*sin(x)),x, algorithm="fricas")

[Out]

1/2*(sqrt(b^2 + c^2)*A*log(-(2*b*c*cos(x)*sin(x) + (b^2 - c^2)*cos(x)^2 - 2*b^2 - c^2 + 2*sqrt(b^2 + c^2)*(c*c
os(x) - b*sin(x)))/(2*b*c*cos(x)*sin(x) + (b^2 - c^2)*cos(x)^2 + c^2)) + 2*(B*b + C*c)*x - (C*b - B*c)*log(2*b
*c*cos(x)*sin(x) + (b^2 - c^2)*cos(x)^2 + c^2))/(b^2 + c^2)

________________________________________________________________________________________

Sympy [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*cos(x)+C*sin(x))/(b*cos(x)+c*sin(x)),x)

[Out]

Exception raised: AttributeError

________________________________________________________________________________________

Giac [A]  time = 1.29173, size = 200, normalized size = 2.38 \begin{align*} -\frac{A \log \left (\frac{{\left | 2 \, b \tan \left (\frac{1}{2} \, x\right ) - 2 \, c - 2 \, \sqrt{b^{2} + c^{2}} \right |}}{{\left | 2 \, b \tan \left (\frac{1}{2} \, x\right ) - 2 \, c + 2 \, \sqrt{b^{2} + c^{2}} \right |}}\right )}{\sqrt{b^{2} + c^{2}}} + \frac{{\left (B b + C c\right )} x}{b^{2} + c^{2}} + \frac{{\left (C b - B c\right )} \log \left (\tan \left (\frac{1}{2} \, x\right )^{2} + 1\right )}{b^{2} + c^{2}} - \frac{{\left (C b - B c\right )} \log \left ({\left | b \tan \left (\frac{1}{2} \, x\right )^{2} - 2 \, c \tan \left (\frac{1}{2} \, x\right ) - b \right |}\right )}{b^{2} + c^{2}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*cos(x)+C*sin(x))/(b*cos(x)+c*sin(x)),x, algorithm="giac")

[Out]

-A*log(abs(2*b*tan(1/2*x) - 2*c - 2*sqrt(b^2 + c^2))/abs(2*b*tan(1/2*x) - 2*c + 2*sqrt(b^2 + c^2)))/sqrt(b^2 +
 c^2) + (B*b + C*c)*x/(b^2 + c^2) + (C*b - B*c)*log(tan(1/2*x)^2 + 1)/(b^2 + c^2) - (C*b - B*c)*log(abs(b*tan(
1/2*x)^2 - 2*c*tan(1/2*x) - b))/(b^2 + c^2)