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

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

Optimal result

Integrand size = 20, antiderivative size = 367 \[ \int \frac {(c+d x)^2}{a+b \sin (e+f x)} \, dx=-\frac {i (c+d x)^2 \log \left (1-\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2} f}+\frac {i (c+d x)^2 \log \left (1-\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2} f}-\frac {2 d (c+d x) \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2} f^2}+\frac {2 d (c+d x) \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2} f^2}-\frac {2 i d^2 \operatorname {PolyLog}\left (3,\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2} f^3}+\frac {2 i d^2 \operatorname {PolyLog}\left (3,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2} f^3} \] Output:

-I*(d*x+c)^2*ln(1-I*b*exp(I*(f*x+e))/(a-(a^2-b^2)^(1/2)))/(a^2-b^2)^(1/2)/ 
f+I*(d*x+c)^2*ln(1-I*b*exp(I*(f*x+e))/(a+(a^2-b^2)^(1/2)))/(a^2-b^2)^(1/2) 
/f-2*d*(d*x+c)*polylog(2,I*b*exp(I*(f*x+e))/(a-(a^2-b^2)^(1/2)))/(a^2-b^2) 
^(1/2)/f^2+2*d*(d*x+c)*polylog(2,I*b*exp(I*(f*x+e))/(a+(a^2-b^2)^(1/2)))/( 
a^2-b^2)^(1/2)/f^2-2*I*d^2*polylog(3,I*b*exp(I*(f*x+e))/(a-(a^2-b^2)^(1/2) 
))/(a^2-b^2)^(1/2)/f^3+2*I*d^2*polylog(3,I*b*exp(I*(f*x+e))/(a+(a^2-b^2)^( 
1/2)))/(a^2-b^2)^(1/2)/f^3
 

Mathematica [A] (verified)

Time = 0.23 (sec) , antiderivative size = 296, normalized size of antiderivative = 0.81 \[ \int \frac {(c+d x)^2}{a+b \sin (e+f x)} \, dx=-\frac {i \left ((c+d x)^2 \log \left (1+\frac {i b e^{i (e+f x)}}{-a+\sqrt {a^2-b^2}}\right )-(c+d x)^2 \log \left (1-\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )+\frac {2 d \left (-i f (c+d x) \operatorname {PolyLog}\left (2,-\frac {i b e^{i (e+f x)}}{-a+\sqrt {a^2-b^2}}\right )+d \operatorname {PolyLog}\left (3,\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )\right )}{f^2}+\frac {2 i d \left (f (c+d x) \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )+i d \operatorname {PolyLog}\left (3,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )\right )}{f^2}\right )}{\sqrt {a^2-b^2} f} \] Input:

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

Output:

((-I)*((c + d*x)^2*Log[1 + (I*b*E^(I*(e + f*x)))/(-a + Sqrt[a^2 - b^2])] - 
 (c + d*x)^2*Log[1 - (I*b*E^(I*(e + f*x)))/(a + Sqrt[a^2 - b^2])] + (2*d*( 
(-I)*f*(c + d*x)*PolyLog[2, ((-I)*b*E^(I*(e + f*x)))/(-a + Sqrt[a^2 - b^2] 
)] + d*PolyLog[3, (I*b*E^(I*(e + f*x)))/(a - Sqrt[a^2 - b^2])]))/f^2 + ((2 
*I)*d*(f*(c + d*x)*PolyLog[2, (I*b*E^(I*(e + f*x)))/(a + Sqrt[a^2 - b^2])] 
 + I*d*PolyLog[3, (I*b*E^(I*(e + f*x)))/(a + Sqrt[a^2 - b^2])]))/f^2))/(Sq 
rt[a^2 - b^2]*f)
 

Rubi [A] (verified)

Time = 1.40 (sec) , antiderivative size = 347, normalized size of antiderivative = 0.95, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.400, Rules used = {3042, 3804, 2694, 27, 2620, 3011, 2720, 7143}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3804

\(\displaystyle 2 \int \frac {e^{i (e+f x)} (c+d x)^2}{2 e^{i (e+f x)} a-i b e^{2 i (e+f x)}+i b}dx\)

\(\Big \downarrow \) 2694

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

\(\Big \downarrow \) 27

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

\(\Big \downarrow \) 2620

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

\(\Big \downarrow \) 3011

\(\displaystyle 2 \left (\frac {i b \left (\frac {(c+d x)^2 \log \left (1-\frac {i b e^{i (e+f x)}}{\sqrt {a^2-b^2}+a}\right )}{b f}-\frac {2 d \left (\frac {i (c+d x) \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )}{f}-\frac {i d \int \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )dx}{f}\right )}{b f}\right )}{2 \sqrt {a^2-b^2}}-\frac {i b \left (\frac {(c+d x)^2 \log \left (1-\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{b f}-\frac {2 d \left (\frac {i (c+d x) \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{f}-\frac {i d \int \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )dx}{f}\right )}{b f}\right )}{2 \sqrt {a^2-b^2}}\right )\)

\(\Big \downarrow \) 2720

\(\displaystyle 2 \left (\frac {i b \left (\frac {(c+d x)^2 \log \left (1-\frac {i b e^{i (e+f x)}}{\sqrt {a^2-b^2}+a}\right )}{b f}-\frac {2 d \left (\frac {i (c+d x) \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )}{f}-\frac {d \int e^{-i (e+f x)} \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )de^{i (e+f x)}}{f^2}\right )}{b f}\right )}{2 \sqrt {a^2-b^2}}-\frac {i b \left (\frac {(c+d x)^2 \log \left (1-\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{b f}-\frac {2 d \left (\frac {i (c+d x) \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{f}-\frac {d \int e^{-i (e+f x)} \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )de^{i (e+f x)}}{f^2}\right )}{b f}\right )}{2 \sqrt {a^2-b^2}}\right )\)

\(\Big \downarrow \) 7143

\(\displaystyle 2 \left (\frac {i b \left (\frac {(c+d x)^2 \log \left (1-\frac {i b e^{i (e+f x)}}{\sqrt {a^2-b^2}+a}\right )}{b f}-\frac {2 d \left (\frac {i (c+d x) \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )}{f}-\frac {d \operatorname {PolyLog}\left (3,\frac {i b e^{i (e+f x)}}{a+\sqrt {a^2-b^2}}\right )}{f^2}\right )}{b f}\right )}{2 \sqrt {a^2-b^2}}-\frac {i b \left (\frac {(c+d x)^2 \log \left (1-\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{b f}-\frac {2 d \left (\frac {i (c+d x) \operatorname {PolyLog}\left (2,\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{f}-\frac {d \operatorname {PolyLog}\left (3,\frac {i b e^{i (e+f x)}}{a-\sqrt {a^2-b^2}}\right )}{f^2}\right )}{b f}\right )}{2 \sqrt {a^2-b^2}}\right )\)

Input:

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

Output:

2*(((-1/2*I)*b*(((c + d*x)^2*Log[1 - (I*b*E^(I*(e + f*x)))/(a - Sqrt[a^2 - 
 b^2])])/(b*f) - (2*d*((I*(c + d*x)*PolyLog[2, (I*b*E^(I*(e + f*x)))/(a - 
Sqrt[a^2 - b^2])])/f - (d*PolyLog[3, (I*b*E^(I*(e + f*x)))/(a - Sqrt[a^2 - 
 b^2])])/f^2))/(b*f)))/Sqrt[a^2 - b^2] + ((I/2)*b*(((c + d*x)^2*Log[1 - (I 
*b*E^(I*(e + f*x)))/(a + Sqrt[a^2 - b^2])])/(b*f) - (2*d*((I*(c + d*x)*Pol 
yLog[2, (I*b*E^(I*(e + f*x)))/(a + Sqrt[a^2 - b^2])])/f - (d*PolyLog[3, (I 
*b*E^(I*(e + f*x)))/(a + Sqrt[a^2 - b^2])])/f^2))/(b*f)))/Sqrt[a^2 - b^2])
 

Defintions of rubi rules used

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

rule 2620
Int[(((F_)^((g_.)*((e_.) + (f_.)*(x_))))^(n_.)*((c_.) + (d_.)*(x_))^(m_.))/ 
((a_) + (b_.)*((F_)^((g_.)*((e_.) + (f_.)*(x_))))^(n_.)), x_Symbol] :> Simp 
[((c + d*x)^m/(b*f*g*n*Log[F]))*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x] - Si 
mp[d*(m/(b*f*g*n*Log[F]))   Int[(c + d*x)^(m - 1)*Log[1 + b*((F^(g*(e + f*x 
)))^n/a)], x], x] /; FreeQ[{F, a, b, c, d, e, f, g, n}, x] && IGtQ[m, 0]
 

rule 2694
Int[((F_)^(u_)*((f_.) + (g_.)*(x_))^(m_.))/((a_.) + (b_.)*(F_)^(u_) + (c_.) 
*(F_)^(v_)), x_Symbol] :> With[{q = Rt[b^2 - 4*a*c, 2]}, Simp[2*(c/q)   Int 
[(f + g*x)^m*(F^u/(b - q + 2*c*F^u)), x], x] - Simp[2*(c/q)   Int[(f + g*x) 
^m*(F^u/(b + q + 2*c*F^u)), x], x]] /; FreeQ[{F, a, b, c, f, g}, x] && EqQ[ 
v, 2*u] && LinearQ[u, x] && NeQ[b^2 - 4*a*c, 0] && IGtQ[m, 0]
 

rule 2720
Int[u_, x_Symbol] :> With[{v = FunctionOfExponential[u, x]}, Simp[v/D[v, x] 
   Subst[Int[FunctionOfExponentialFunction[u, x]/x, x], x, v], x]] /; Funct 
ionOfExponentialQ[u, x] &&  !MatchQ[u, (w_)*((a_.)*(v_)^(n_))^(m_) /; FreeQ 
[{a, m, n}, x] && IntegerQ[m*n]] &&  !MatchQ[u, E^((c_.)*((a_.) + (b_.)*x)) 
*(F_)[v_] /; FreeQ[{a, b, c}, x] && InverseFunctionQ[F[x]]]
 

rule 3011
Int[Log[1 + (e_.)*((F_)^((c_.)*((a_.) + (b_.)*(x_))))^(n_.)]*((f_.) + (g_.) 
*(x_))^(m_.), x_Symbol] :> Simp[(-(f + g*x)^m)*(PolyLog[2, (-e)*(F^(c*(a + 
b*x)))^n]/(b*c*n*Log[F])), x] + Simp[g*(m/(b*c*n*Log[F]))   Int[(f + g*x)^( 
m - 1)*PolyLog[2, (-e)*(F^(c*(a + b*x)))^n], x], x] /; FreeQ[{F, a, b, c, e 
, f, g, n}, x] && GtQ[m, 0]
 

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

rule 3804
Int[((c_.) + (d_.)*(x_))^(m_.)/((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]), x_Sy 
mbol] :> Simp[2   Int[(c + d*x)^m*(E^(I*(e + f*x))/(I*b + 2*a*E^(I*(e + f*x 
)) - I*b*E^(2*I*(e + f*x)))), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ 
[a^2 - b^2, 0] && IGtQ[m, 0]
 

rule 7143
Int[PolyLog[n_, (c_.)*((a_.) + (b_.)*(x_))^(p_.)]/((d_.) + (e_.)*(x_)), x_S 
ymbol] :> Simp[PolyLog[n + 1, c*(a + b*x)^p]/(e*p), x] /; FreeQ[{a, b, c, d 
, e, n, p}, x] && EqQ[b*d, a*e]
 
Maple [F]

\[\int \frac {\left (d x +c \right )^{2}}{a +b \sin \left (f x +e \right )}d x\]

Input:

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

Output:

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

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 1543 vs. \(2 (309) = 618\).

Time = 0.24 (sec) , antiderivative size = 1543, normalized size of antiderivative = 4.20 \[ \int \frac {(c+d x)^2}{a+b \sin (e+f x)} \, dx=\text {Too large to display} \] Input:

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

Output:

1/2*(2*b*d^2*sqrt(-(a^2 - b^2)/b^2)*polylog(3, -(I*a*cos(f*x + e) + a*sin( 
f*x + e) + (b*cos(f*x + e) - I*b*sin(f*x + e))*sqrt(-(a^2 - b^2)/b^2))/b) 
- 2*b*d^2*sqrt(-(a^2 - b^2)/b^2)*polylog(3, -(I*a*cos(f*x + e) + a*sin(f*x 
 + e) - (b*cos(f*x + e) - I*b*sin(f*x + e))*sqrt(-(a^2 - b^2)/b^2))/b) + 2 
*b*d^2*sqrt(-(a^2 - b^2)/b^2)*polylog(3, -(-I*a*cos(f*x + e) + a*sin(f*x + 
 e) + (b*cos(f*x + e) + I*b*sin(f*x + e))*sqrt(-(a^2 - b^2)/b^2))/b) - 2*b 
*d^2*sqrt(-(a^2 - b^2)/b^2)*polylog(3, -(-I*a*cos(f*x + e) + a*sin(f*x + e 
) - (b*cos(f*x + e) + I*b*sin(f*x + e))*sqrt(-(a^2 - b^2)/b^2))/b) + 2*(I* 
b*d^2*f*x + I*b*c*d*f)*sqrt(-(a^2 - b^2)/b^2)*dilog((I*a*cos(f*x + e) - a* 
sin(f*x + e) + (b*cos(f*x + e) + I*b*sin(f*x + e))*sqrt(-(a^2 - b^2)/b^2) 
- b)/b + 1) + 2*(-I*b*d^2*f*x - I*b*c*d*f)*sqrt(-(a^2 - b^2)/b^2)*dilog((I 
*a*cos(f*x + e) - a*sin(f*x + e) - (b*cos(f*x + e) + I*b*sin(f*x + e))*sqr 
t(-(a^2 - b^2)/b^2) - b)/b + 1) + 2*(-I*b*d^2*f*x - I*b*c*d*f)*sqrt(-(a^2 
- b^2)/b^2)*dilog((-I*a*cos(f*x + e) - a*sin(f*x + e) + (b*cos(f*x + e) - 
I*b*sin(f*x + e))*sqrt(-(a^2 - b^2)/b^2) - b)/b + 1) + 2*(I*b*d^2*f*x + I* 
b*c*d*f)*sqrt(-(a^2 - b^2)/b^2)*dilog((-I*a*cos(f*x + e) - a*sin(f*x + e) 
- (b*cos(f*x + e) - I*b*sin(f*x + e))*sqrt(-(a^2 - b^2)/b^2) - b)/b + 1) + 
 (b*d^2*e^2 - 2*b*c*d*e*f + b*c^2*f^2)*sqrt(-(a^2 - b^2)/b^2)*log(2*b*cos( 
f*x + e) + 2*I*b*sin(f*x + e) + 2*b*sqrt(-(a^2 - b^2)/b^2) + 2*I*a) + (b*d 
^2*e^2 - 2*b*c*d*e*f + b*c^2*f^2)*sqrt(-(a^2 - b^2)/b^2)*log(2*b*cos(f*...
 

Sympy [F]

\[ \int \frac {(c+d x)^2}{a+b \sin (e+f x)} \, dx=\int \frac {\left (c + d x\right )^{2}}{a + b \sin {\left (e + f x \right )}}\, dx \] Input:

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

Output:

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

Maxima [F(-2)]

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

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

Giac [F]

\[ \int \frac {(c+d x)^2}{a+b \sin (e+f x)} \, dx=\int { \frac {{\left (d x + c\right )}^{2}}{b \sin \left (f x + e\right ) + a} \,d x } \] Input:

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

Output:

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

Mupad [F(-1)]

Timed out. \[ \int \frac {(c+d x)^2}{a+b \sin (e+f x)} \, dx=\int \frac {{\left (c+d\,x\right )}^2}{a+b\,\sin \left (e+f\,x\right )} \,d x \] Input:

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

Output:

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

Reduce [F]

\[ \int \frac {(c+d x)^2}{a+b \sin (e+f x)} \, dx=\frac {2 \sqrt {a^{2}-b^{2}}\, \mathit {atan} \left (\frac {\tan \left (\frac {f x}{2}+\frac {e}{2}\right ) a +b}{\sqrt {a^{2}-b^{2}}}\right ) c^{2}+\left (\int \frac {x^{2}}{\sin \left (f x +e \right ) b +a}d x \right ) a^{2} d^{2} f -\left (\int \frac {x^{2}}{\sin \left (f x +e \right ) b +a}d x \right ) b^{2} d^{2} f +2 \left (\int \frac {x}{\sin \left (f x +e \right ) b +a}d x \right ) a^{2} c d f -2 \left (\int \frac {x}{\sin \left (f x +e \right ) b +a}d x \right ) b^{2} c d f}{f \left (a^{2}-b^{2}\right )} \] Input:

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

Output:

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