\(\int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)} \, dx\) [682]

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

Optimal result

Integrand size = 23, antiderivative size = 65 \[ \int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)} \, dx=\frac {b x}{d}-\frac {2 (b c-a d) \arctan \left (\frac {d+c \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c^2-d^2}}\right )}{d \sqrt {c^2-d^2} f} \] Output:

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

Mathematica [A] (verified)

Time = 0.19 (sec) , antiderivative size = 67, normalized size of antiderivative = 1.03 \[ \int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)} \, dx=\frac {b (e+f x)+\frac {(-2 b c+2 a d) \arctan \left (\frac {d+c \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c^2-d^2}}\right )}{\sqrt {c^2-d^2}}}{d f} \] Input:

Integrate[(a + b*Sin[e + f*x])/(c + d*Sin[e + f*x]),x]
 

Output:

(b*(e + f*x) + ((-2*b*c + 2*a*d)*ArcTan[(d + c*Tan[(e + f*x)/2])/Sqrt[c^2 
- d^2]])/Sqrt[c^2 - d^2])/(d*f)
 

Rubi [A] (verified)

Time = 0.33 (sec) , antiderivative size = 71, normalized size of antiderivative = 1.09, number of steps used = 7, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.261, Rules used = {3042, 3214, 3042, 3139, 1083, 217}

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 \sin (e+f x)}{c+d \sin (e+f x)} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)}dx\)

\(\Big \downarrow \) 3214

\(\displaystyle \frac {b x}{d}-\frac {(b c-a d) \int \frac {1}{c+d \sin (e+f x)}dx}{d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {b x}{d}-\frac {(b c-a d) \int \frac {1}{c+d \sin (e+f x)}dx}{d}\)

\(\Big \downarrow \) 3139

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

\(\Big \downarrow \) 1083

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

\(\Big \downarrow \) 217

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

Input:

Int[(a + b*Sin[e + f*x])/(c + d*Sin[e + f*x]),x]
 

Output:

(b*x)/d - (2*(b*c - a*d)*ArcTan[(2*d + 2*c*Tan[(e + f*x)/2])/(2*Sqrt[c^2 - 
 d^2])])/(d*Sqrt[c^2 - d^2]*f)
 

Defintions of rubi rules used

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

rule 1083
Int[((a_) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Simp[-2   Subst[I 
nt[1/Simp[b^2 - 4*a*c - x^2, x], x], x, b + 2*c*x], x] /; FreeQ[{a, b, c}, 
x]
 

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

rule 3139
Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = Fre 
eFactors[Tan[(c + d*x)/2], x]}, Simp[2*(e/d)   Subst[Int[1/(a + 2*b*e*x + a 
*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 3214
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_. 
)*(x_)]), x_Symbol] :> Simp[b*(x/d), x] - Simp[(b*c - a*d)/d   Int[1/(c + d 
*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0]
 
Maple [A] (verified)

Time = 0.68 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.17

method result size
derivativedivides \(\frac {\frac {2 \left (a d -b c \right ) \arctan \left (\frac {2 c \tan \left (\frac {f x}{2}+\frac {e}{2}\right )+2 d}{2 \sqrt {c^{2}-d^{2}}}\right )}{d \sqrt {c^{2}-d^{2}}}+\frac {2 b \arctan \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{d}}{f}\) \(76\)
default \(\frac {\frac {2 \left (a d -b c \right ) \arctan \left (\frac {2 c \tan \left (\frac {f x}{2}+\frac {e}{2}\right )+2 d}{2 \sqrt {c^{2}-d^{2}}}\right )}{d \sqrt {c^{2}-d^{2}}}+\frac {2 b \arctan \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{d}}{f}\) \(76\)
risch \(\frac {b x}{d}-\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i \sqrt {-c^{2}+d^{2}}\, c -c^{2}+d^{2}}{\sqrt {-c^{2}+d^{2}}\, d}\right ) a}{\sqrt {-c^{2}+d^{2}}\, f}+\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i \sqrt {-c^{2}+d^{2}}\, c -c^{2}+d^{2}}{\sqrt {-c^{2}+d^{2}}\, d}\right ) b c}{\sqrt {-c^{2}+d^{2}}\, f d}+\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i \sqrt {-c^{2}+d^{2}}\, c +c^{2}-d^{2}}{\sqrt {-c^{2}+d^{2}}\, d}\right ) a}{\sqrt {-c^{2}+d^{2}}\, f}-\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i \sqrt {-c^{2}+d^{2}}\, c +c^{2}-d^{2}}{\sqrt {-c^{2}+d^{2}}\, d}\right ) b c}{\sqrt {-c^{2}+d^{2}}\, f d}\) \(282\)

Input:

int((a+b*sin(f*x+e))/(c+d*sin(f*x+e)),x,method=_RETURNVERBOSE)
 

Output:

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

Fricas [A] (verification not implemented)

Time = 0.10 (sec) , antiderivative size = 255, normalized size of antiderivative = 3.92 \[ \int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)} \, dx=\left [\frac {2 \, {\left (b c^{2} - b d^{2}\right )} f x + {\left (b c - a d\right )} \sqrt {-c^{2} + d^{2}} \log \left (\frac {{\left (2 \, c^{2} - d^{2}\right )} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2} + 2 \, {\left (c \cos \left (f x + e\right ) \sin \left (f x + e\right ) + d \cos \left (f x + e\right )\right )} \sqrt {-c^{2} + d^{2}}}{d^{2} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2}}\right )}{2 \, {\left (c^{2} d - d^{3}\right )} f}, \frac {{\left (b c^{2} - b d^{2}\right )} f x + {\left (b c - a d\right )} \sqrt {c^{2} - d^{2}} \arctan \left (-\frac {c \sin \left (f x + e\right ) + d}{\sqrt {c^{2} - d^{2}} \cos \left (f x + e\right )}\right )}{{\left (c^{2} d - d^{3}\right )} f}\right ] \] Input:

integrate((a+b*sin(f*x+e))/(c+d*sin(f*x+e)),x, algorithm="fricas")
 

Output:

[1/2*(2*(b*c^2 - b*d^2)*f*x + (b*c - a*d)*sqrt(-c^2 + d^2)*log(((2*c^2 - d 
^2)*cos(f*x + e)^2 - 2*c*d*sin(f*x + e) - c^2 - d^2 + 2*(c*cos(f*x + e)*si 
n(f*x + e) + d*cos(f*x + e))*sqrt(-c^2 + d^2))/(d^2*cos(f*x + e)^2 - 2*c*d 
*sin(f*x + e) - c^2 - d^2)))/((c^2*d - d^3)*f), ((b*c^2 - b*d^2)*f*x + (b* 
c - a*d)*sqrt(c^2 - d^2)*arctan(-(c*sin(f*x + e) + d)/(sqrt(c^2 - d^2)*cos 
(f*x + e))))/((c^2*d - d^3)*f)]
                                                                                    
                                                                                    
 

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 425 vs. \(2 (53) = 106\).

Time = 16.52 (sec) , antiderivative size = 425, normalized size of antiderivative = 6.54 \[ \int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)} \, dx=\begin {cases} \frac {\tilde {\infty } x \left (a + b \sin {\left (e \right )}\right )}{\sin {\left (e \right )}} & \text {for}\: c = 0 \wedge d = 0 \wedge f = 0 \\\frac {\frac {a \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} \right )}}{f} + b x}{d} & \text {for}\: c = 0 \\\frac {a x - \frac {b \cos {\left (e + f x \right )}}{f}}{c} & \text {for}\: d = 0 \\\frac {x \left (a + b \sin {\left (e \right )}\right )}{c + d \sin {\left (e \right )}} & \text {for}\: f = 0 \\\frac {2 a}{d f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} - d f} + \frac {b f x \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )}}{d f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} - d f} - \frac {b f x}{d f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} - d f} + \frac {2 b}{d f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} - d f} & \text {for}\: c = - d \\- \frac {2 a}{d f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + d f} + \frac {b f x \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )}}{d f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + d f} + \frac {b f x}{d f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + d f} + \frac {2 b}{d f \tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + d f} & \text {for}\: c = d \\\frac {a \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + \frac {d}{c} - \frac {\sqrt {- c^{2} + d^{2}}}{c} \right )}}{f \sqrt {- c^{2} + d^{2}}} - \frac {a \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + \frac {d}{c} + \frac {\sqrt {- c^{2} + d^{2}}}{c} \right )}}{f \sqrt {- c^{2} + d^{2}}} - \frac {b c \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + \frac {d}{c} - \frac {\sqrt {- c^{2} + d^{2}}}{c} \right )}}{d f \sqrt {- c^{2} + d^{2}}} + \frac {b c \log {\left (\tan {\left (\frac {e}{2} + \frac {f x}{2} \right )} + \frac {d}{c} + \frac {\sqrt {- c^{2} + d^{2}}}{c} \right )}}{d f \sqrt {- c^{2} + d^{2}}} + \frac {b x}{d} & \text {otherwise} \end {cases} \] Input:

integrate((a+b*sin(f*x+e))/(c+d*sin(f*x+e)),x)
 

Output:

Piecewise((zoo*x*(a + b*sin(e))/sin(e), Eq(c, 0) & Eq(d, 0) & Eq(f, 0)), ( 
(a*log(tan(e/2 + f*x/2))/f + b*x)/d, Eq(c, 0)), ((a*x - b*cos(e + f*x)/f)/ 
c, Eq(d, 0)), (x*(a + b*sin(e))/(c + d*sin(e)), Eq(f, 0)), (2*a/(d*f*tan(e 
/2 + f*x/2) - d*f) + b*f*x*tan(e/2 + f*x/2)/(d*f*tan(e/2 + f*x/2) - d*f) - 
 b*f*x/(d*f*tan(e/2 + f*x/2) - d*f) + 2*b/(d*f*tan(e/2 + f*x/2) - d*f), Eq 
(c, -d)), (-2*a/(d*f*tan(e/2 + f*x/2) + d*f) + b*f*x*tan(e/2 + f*x/2)/(d*f 
*tan(e/2 + f*x/2) + d*f) + b*f*x/(d*f*tan(e/2 + f*x/2) + d*f) + 2*b/(d*f*t 
an(e/2 + f*x/2) + d*f), Eq(c, d)), (a*log(tan(e/2 + f*x/2) + d/c - sqrt(-c 
**2 + d**2)/c)/(f*sqrt(-c**2 + d**2)) - a*log(tan(e/2 + f*x/2) + d/c + sqr 
t(-c**2 + d**2)/c)/(f*sqrt(-c**2 + d**2)) - b*c*log(tan(e/2 + f*x/2) + d/c 
 - sqrt(-c**2 + d**2)/c)/(d*f*sqrt(-c**2 + d**2)) + b*c*log(tan(e/2 + f*x/ 
2) + d/c + sqrt(-c**2 + d**2)/c)/(d*f*sqrt(-c**2 + d**2)) + b*x/d, True))
 

Maxima [F(-2)]

Exception generated. \[ \int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)} \, dx=\text {Exception raised: ValueError} \] Input:

integrate((a+b*sin(f*x+e))/(c+d*sin(f*x+e)),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*d^2-4*c^2>0)', see `assume?` f 
or more de
 

Giac [A] (verification not implemented)

Time = 0.14 (sec) , antiderivative size = 83, normalized size of antiderivative = 1.28 \[ \int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)} \, dx=\frac {\frac {{\left (f x + e\right )} b}{d} - \frac {2 \, {\left (\pi \left \lfloor \frac {f x + e}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (c\right ) + \arctan \left (\frac {c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + d}{\sqrt {c^{2} - d^{2}}}\right )\right )} {\left (b c - a d\right )}}{\sqrt {c^{2} - d^{2}} d}}{f} \] Input:

integrate((a+b*sin(f*x+e))/(c+d*sin(f*x+e)),x, algorithm="giac")
 

Output:

((f*x + e)*b/d - 2*(pi*floor(1/2*(f*x + e)/pi + 1/2)*sgn(c) + arctan((c*ta 
n(1/2*f*x + 1/2*e) + d)/sqrt(c^2 - d^2)))*(b*c - a*d)/(sqrt(c^2 - d^2)*d)) 
/f
 

Mupad [B] (verification not implemented)

Time = 18.87 (sec) , antiderivative size = 342, normalized size of antiderivative = 5.26 \[ \int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)} \, dx=\frac {2\,b\,\mathrm {atan}\left (\frac {\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )}{d\,f}+\frac {c\,\left (b\,\ln \left (\frac {d\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )+c\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )-\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )\,\sqrt {-\left (c+d\right )\,\left (c-d\right )}-b\,\ln \left (\frac {d\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )+c\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )+\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )\,\sqrt {d^2-c^2}\right )-a\,d\,\ln \left (\frac {d\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )+c\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )-\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )\,\sqrt {-\left (c+d\right )\,\left (c-d\right )}+a\,d\,\ln \left (\frac {d\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )+c\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )+\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {d^2-c^2}}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )\,\sqrt {d^2-c^2}}{d\,f\,\left (c^2-d^2\right )} \] Input:

int((a + b*sin(e + f*x))/(c + d*sin(e + f*x)),x)
 

Output:

(2*b*atan(sin(e/2 + (f*x)/2)/cos(e/2 + (f*x)/2)))/(d*f) + (c*(b*log((d*cos 
(e/2 + (f*x)/2) + c*sin(e/2 + (f*x)/2) - cos(e/2 + (f*x)/2)*(d^2 - c^2)^(1 
/2))/cos(e/2 + (f*x)/2))*(-(c + d)*(c - d))^(1/2) - b*log((d*cos(e/2 + (f* 
x)/2) + c*sin(e/2 + (f*x)/2) + cos(e/2 + (f*x)/2)*(d^2 - c^2)^(1/2))/cos(e 
/2 + (f*x)/2))*(d^2 - c^2)^(1/2)) - a*d*log((d*cos(e/2 + (f*x)/2) + c*sin( 
e/2 + (f*x)/2) - cos(e/2 + (f*x)/2)*(d^2 - c^2)^(1/2))/cos(e/2 + (f*x)/2)) 
*(-(c + d)*(c - d))^(1/2) + a*d*log((d*cos(e/2 + (f*x)/2) + c*sin(e/2 + (f 
*x)/2) + cos(e/2 + (f*x)/2)*(d^2 - c^2)^(1/2))/cos(e/2 + (f*x)/2))*(d^2 - 
c^2)^(1/2))/(d*f*(c^2 - d^2))
 

Reduce [B] (verification not implemented)

Time = 0.20 (sec) , antiderivative size = 116, normalized size of antiderivative = 1.78 \[ \int \frac {a+b \sin (e+f x)}{c+d \sin (e+f x)} \, dx=\frac {2 \sqrt {c^{2}-d^{2}}\, \mathit {atan} \left (\frac {\tan \left (\frac {f x}{2}+\frac {e}{2}\right ) c +d}{\sqrt {c^{2}-d^{2}}}\right ) a d -2 \sqrt {c^{2}-d^{2}}\, \mathit {atan} \left (\frac {\tan \left (\frac {f x}{2}+\frac {e}{2}\right ) c +d}{\sqrt {c^{2}-d^{2}}}\right ) b c +b \,c^{2} f x -b \,d^{2} f x}{d f \left (c^{2}-d^{2}\right )} \] Input:

int((a+b*sin(f*x+e))/(c+d*sin(f*x+e)),x)
 

Output:

(2*sqrt(c**2 - d**2)*atan((tan((e + f*x)/2)*c + d)/sqrt(c**2 - d**2))*a*d 
- 2*sqrt(c**2 - d**2)*atan((tan((e + f*x)/2)*c + d)/sqrt(c**2 - d**2))*b*c 
 + b*c**2*f*x - b*d**2*f*x)/(d*f*(c**2 - d**2))