\(\int \sqrt {(2-x) x (4-2 x+x^2)} \, dx\) [56]

Optimal result
Mathematica [C] (warning: unable to verify)
Rubi [A] (verified)
Maple [B] (verified)
Fricas [A] (verification not implemented)
Sympy [F]
Maxima [F]
Giac [F]
Mupad [F(-1)]
Reduce [F]

Optimal result

Integrand size = 19, antiderivative size = 68 \[ \int \sqrt {(2-x) x \left (4-2 x+x^2\right )} \, dx=-\frac {1}{3} \sqrt {3-2 (1-x)^2-(1-x)^4} (1-x)+\frac {2 E\left (\arcsin (1-x)\left |-\frac {1}{3}\right .\right )}{\sqrt {3}}-\frac {4 \operatorname {EllipticF}\left (\arcsin (1-x),-\frac {1}{3}\right )}{\sqrt {3}} \] Output:

-1/3*(3-2*(1-x)^2-(1-x)^4)^(1/2)*(1-x)-2/3*3^(1/2)*EllipticE(-1+x,1/3*I*3^ 
(1/2))+4/3*3^(1/2)*EllipticF(-1+x,1/3*I*3^(1/2))
 

Mathematica [C] (warning: unable to verify)

Result contains complex when optimal does not.

Time = 20.86 (sec) , antiderivative size = 256, normalized size of antiderivative = 3.76 \[ \int \sqrt {(2-x) x \left (4-2 x+x^2\right )} \, dx=\frac {\sqrt {-x \left (-8+8 x-4 x^2+x^3\right )} \left (\sqrt {\frac {4-2 x+x^2}{x^2}} \left (-4+4 x-3 x^2+x^3\right )+2 \sqrt {2} \left (-i+\sqrt {3}\right ) \sqrt {-\frac {i (-2+x)}{\left (-i+\sqrt {3}\right ) x}} E\left (\arcsin \left (\frac {\sqrt {i+\sqrt {3}-\frac {4 i}{x}}}{\sqrt {2} \sqrt [4]{3}}\right )|\frac {2 \sqrt {3}}{-i+\sqrt {3}}\right )+8 i \sqrt {2} \sqrt {-\frac {i (-2+x)}{\left (-i+\sqrt {3}\right ) x}} \operatorname {EllipticF}\left (\arcsin \left (\frac {\sqrt {i+\sqrt {3}-\frac {4 i}{x}}}{\sqrt {2} \sqrt [4]{3}}\right ),\frac {2 \sqrt {3}}{-i+\sqrt {3}}\right )\right )}{3 (-2+x) x \sqrt {\frac {4-2 x+x^2}{x^2}}} \] Input:

Integrate[Sqrt[(2 - x)*x*(4 - 2*x + x^2)],x]
 

Output:

(Sqrt[-(x*(-8 + 8*x - 4*x^2 + x^3))]*(Sqrt[(4 - 2*x + x^2)/x^2]*(-4 + 4*x 
- 3*x^2 + x^3) + 2*Sqrt[2]*(-I + Sqrt[3])*Sqrt[((-I)*(-2 + x))/((-I + Sqrt 
[3])*x)]*EllipticE[ArcSin[Sqrt[I + Sqrt[3] - (4*I)/x]/(Sqrt[2]*3^(1/4))], 
(2*Sqrt[3])/(-I + Sqrt[3])] + (8*I)*Sqrt[2]*Sqrt[((-I)*(-2 + x))/((-I + Sq 
rt[3])*x)]*EllipticF[ArcSin[Sqrt[I + Sqrt[3] - (4*I)/x]/(Sqrt[2]*3^(1/4))] 
, (2*Sqrt[3])/(-I + Sqrt[3])]))/(3*(-2 + x)*x*Sqrt[(4 - 2*x + x^2)/x^2])
 

Rubi [A] (verified)

Time = 0.22 (sec) , antiderivative size = 66, normalized size of antiderivative = 0.97, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.421, Rules used = {2458, 1404, 27, 1494, 27, 399, 321, 327}

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 \sqrt {(2-x) x \left (x^2-2 x+4\right )} \, dx\)

\(\Big \downarrow \) 2458

\(\displaystyle \int \sqrt {-(x-1)^4-2 (x-1)^2+3}d(x-1)\)

\(\Big \downarrow \) 1404

\(\displaystyle \frac {1}{3} \int \frac {2 \left (3-(x-1)^2\right )}{\sqrt {-(x-1)^4-2 (x-1)^2+3}}d(x-1)+\frac {1}{3} \sqrt {-(x-1)^4-2 (x-1)^2+3} (x-1)\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {2}{3} \int \frac {3-(x-1)^2}{\sqrt {-(x-1)^4-2 (x-1)^2+3}}d(x-1)+\frac {1}{3} \sqrt {-(x-1)^4-2 (x-1)^2+3} (x-1)\)

\(\Big \downarrow \) 1494

\(\displaystyle \frac {4}{3} \int \frac {3-(x-1)^2}{2 \sqrt {1-(x-1)^2} \sqrt {(x-1)^2+3}}d(x-1)+\frac {1}{3} \sqrt {-(x-1)^4-2 (x-1)^2+3} (x-1)\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {2}{3} \int \frac {3-(x-1)^2}{\sqrt {1-(x-1)^2} \sqrt {(x-1)^2+3}}d(x-1)+\frac {1}{3} \sqrt {-(x-1)^4-2 (x-1)^2+3} (x-1)\)

\(\Big \downarrow \) 399

\(\displaystyle \frac {2}{3} \left (6 \int \frac {1}{\sqrt {1-(x-1)^2} \sqrt {(x-1)^2+3}}d(x-1)-\int \frac {\sqrt {(x-1)^2+3}}{\sqrt {1-(x-1)^2}}d(x-1)\right )+\frac {1}{3} \sqrt {-(x-1)^4-2 (x-1)^2+3} (x-1)\)

\(\Big \downarrow \) 321

\(\displaystyle \frac {2}{3} \left (-\int \frac {\sqrt {(x-1)^2+3}}{\sqrt {1-(x-1)^2}}d(x-1)-2 \sqrt {3} \operatorname {EllipticF}\left (\arcsin (1-x),-\frac {1}{3}\right )\right )+\frac {1}{3} \sqrt {-(x-1)^4-2 (x-1)^2+3} (x-1)\)

\(\Big \downarrow \) 327

\(\displaystyle \frac {2}{3} \left (\sqrt {3} E\left (\arcsin (1-x)\left |-\frac {1}{3}\right .\right )-2 \sqrt {3} \operatorname {EllipticF}\left (\arcsin (1-x),-\frac {1}{3}\right )\right )+\frac {1}{3} \sqrt {-(x-1)^4-2 (x-1)^2+3} (x-1)\)

Input:

Int[Sqrt[(2 - x)*x*(4 - 2*x + x^2)],x]
 

Output:

(Sqrt[3 - 2*(-1 + x)^2 - (-1 + x)^4]*(-1 + x))/3 + (2*(Sqrt[3]*EllipticE[A 
rcSin[1 - x], -1/3] - 2*Sqrt[3]*EllipticF[ArcSin[1 - x], -1/3]))/3
 

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 321
Int[1/(Sqrt[(a_) + (b_.)*(x_)^2]*Sqrt[(c_) + (d_.)*(x_)^2]), x_Symbol] :> S 
imp[(1/(Sqrt[a]*Sqrt[c]*Rt[-d/c, 2]))*EllipticF[ArcSin[Rt[-d/c, 2]*x], b*(c 
/(a*d))], x] /; FreeQ[{a, b, c, d}, x] && NegQ[d/c] && GtQ[c, 0] && GtQ[a, 
0] &&  !(NegQ[b/a] && SimplerSqrtQ[-b/a, -d/c])
 

rule 327
Int[Sqrt[(a_) + (b_.)*(x_)^2]/Sqrt[(c_) + (d_.)*(x_)^2], x_Symbol] :> Simp[ 
(Sqrt[a]/(Sqrt[c]*Rt[-d/c, 2]))*EllipticE[ArcSin[Rt[-d/c, 2]*x], b*(c/(a*d) 
)], x] /; FreeQ[{a, b, c, d}, x] && NegQ[d/c] && GtQ[c, 0] && GtQ[a, 0]
 

rule 399
Int[((e_) + (f_.)*(x_)^2)/(Sqrt[(a_) + (b_.)*(x_)^2]*Sqrt[(c_) + (d_.)*(x_) 
^2]), x_Symbol] :> Simp[f/b   Int[Sqrt[a + b*x^2]/Sqrt[c + d*x^2], x], x] + 
 Simp[(b*e - a*f)/b   Int[1/(Sqrt[a + b*x^2]*Sqrt[c + d*x^2]), x], x] /; Fr 
eeQ[{a, b, c, d, e, f}, x] &&  !((PosQ[b/a] && PosQ[d/c]) || (NegQ[b/a] && 
(PosQ[d/c] || (GtQ[a, 0] && ( !GtQ[c, 0] || SimplerSqrtQ[-b/a, -d/c])))))
 

rule 1404
Int[((a_.) + (b_.)*(x_)^2 + (c_.)*(x_)^4)^(p_), x_Symbol] :> Simp[x*((a + b 
*x^2 + c*x^4)^p/(4*p + 1)), x] + Simp[2*(p/(4*p + 1))   Int[(2*a + b*x^2)*( 
a + b*x^2 + c*x^4)^(p - 1), x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a* 
c, 0] && GtQ[p, 0] && IntegerQ[2*p]
 

rule 1494
Int[((d_) + (e_.)*(x_)^2)/Sqrt[(a_) + (b_.)*(x_)^2 + (c_.)*(x_)^4], x_Symbo 
l] :> With[{q = Rt[b^2 - 4*a*c, 2]}, Simp[2*Sqrt[-c]   Int[(d + e*x^2)/(Sqr 
t[b + q + 2*c*x^2]*Sqrt[-b + q - 2*c*x^2]), x], x]] /; FreeQ[{a, b, c, d, e 
}, x] && GtQ[b^2 - 4*a*c, 0] && LtQ[c, 0]
 

rule 2458
Int[(Pn_)^(p_.), x_Symbol] :> With[{S = Coeff[Pn, x, Expon[Pn, x] - 1]/(Exp 
on[Pn, x]*Coeff[Pn, x, Expon[Pn, x]])}, Subst[Int[ExpandToSum[Pn /. x -> x 
- S, x]^p, x], x, x + S] /; BinomialQ[Pn /. x -> x - S, x] || (IntegerQ[Exp 
on[Pn, x]/2] && TrinomialQ[Pn /. x -> x - S, x])] /; FreeQ[p, x] && PolyQ[P 
n, x] && GtQ[Expon[Pn, x], 2] && NeQ[Coeff[Pn, x, Expon[Pn, x] - 1], 0]
 
Maple [B] (verified)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 931 vs. \(2 (60 ) = 120\).

Time = 1.27 (sec) , antiderivative size = 932, normalized size of antiderivative = 13.71

method result size
risch \(\text {Expression too large to display}\) \(932\)
default \(\text {Expression too large to display}\) \(946\)
elliptic \(\text {Expression too large to display}\) \(946\)

Input:

int(((2-x)*x*(x^2-2*x+4))^(1/2),x,method=_RETURNVERBOSE)
 

Output:

-1/3*(x-1)*x*(x-2)*(x^2-2*x+4)/(-x*(x-2)*(x^2-2*x+4))^(1/2)-2/3*(x*(x-1+I* 
3^(1/2))*(x-1-I*3^(1/2))+2*(-1-I*3^(1/2))*((-1+I*3^(1/2))*x/(1+I*3^(1/2))/ 
(x-2))^(1/2)*(x-2)^2*((x-1+I*3^(1/2))/(1-I*3^(1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*3^(1/2))/(-x*(x-2)*(x-1+I*3^(1/2))*(x-1-I*3^ 
(1/2)))^(1/2)*(2*EllipticF(((-1+I*3^(1/2))*x/(1+I*3^(1/2))/(x-2))^(1/2),(( 
1+I*3^(1/2))*(-1-I*3^(1/2))/(-1+I*3^(1/2))/(1-I*3^(1/2)))^(1/2))-2*Elli...
 

Fricas [A] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 69, normalized size of antiderivative = 1.01 \[ \int \sqrt {(2-x) x \left (4-2 x+x^2\right )} \, dx=-\frac {2 \, {\left (-i \, x + i\right )} E(\arcsin \left (\frac {1}{x - 1}\right )\,|\,-3) + 4 \, {\left (-i \, x + i\right )} F(\arcsin \left (\frac {1}{x - 1}\right )\,|\,-3) - \sqrt {-x^{4} + 4 \, x^{3} - 8 \, x^{2} + 8 \, x} {\left (x^{2} - 2 \, x + 3\right )}}{3 \, {\left (x - 1\right )}} \] Input:

integrate(((2-x)*x*(x^2-2*x+4))^(1/2),x, algorithm="fricas")
 

Output:

-1/3*(2*(-I*x + I)*elliptic_e(arcsin(1/(x - 1)), -3) + 4*(-I*x + I)*ellipt 
ic_f(arcsin(1/(x - 1)), -3) - sqrt(-x^4 + 4*x^3 - 8*x^2 + 8*x)*(x^2 - 2*x 
+ 3))/(x - 1)
 

Sympy [F]

\[ \int \sqrt {(2-x) x \left (4-2 x+x^2\right )} \, dx=\int \sqrt {x \left (2 - x\right ) \left (x^{2} - 2 x + 4\right )}\, dx \] Input:

integrate(((2-x)*x*(x**2-2*x+4))**(1/2),x)
 

Output:

Integral(sqrt(x*(2 - x)*(x**2 - 2*x + 4)), x)
 

Maxima [F]

\[ \int \sqrt {(2-x) x \left (4-2 x+x^2\right )} \, dx=\int { \sqrt {-{\left (x^{2} - 2 \, x + 4\right )} {\left (x - 2\right )} x} \,d x } \] Input:

integrate(((2-x)*x*(x^2-2*x+4))^(1/2),x, algorithm="maxima")
 

Output:

integrate(sqrt(-(x^2 - 2*x + 4)*(x - 2)*x), x)
 

Giac [F]

\[ \int \sqrt {(2-x) x \left (4-2 x+x^2\right )} \, dx=\int { \sqrt {-{\left (x^{2} - 2 \, x + 4\right )} {\left (x - 2\right )} x} \,d x } \] Input:

integrate(((2-x)*x*(x^2-2*x+4))^(1/2),x, algorithm="giac")
 

Output:

integrate(sqrt(-(x^2 - 2*x + 4)*(x - 2)*x), x)
 

Mupad [F(-1)]

Timed out. \[ \int \sqrt {(2-x) x \left (4-2 x+x^2\right )} \, dx=\int \sqrt {-x\,\left (x-2\right )\,\left (x^2-2\,x+4\right )} \,d x \] Input:

int((-x*(x - 2)*(x^2 - 2*x + 4))^(1/2),x)
                                                                                    
                                                                                    
 

Output:

int((-x*(x - 2)*(x^2 - 2*x + 4))^(1/2), x)
 

Reduce [F]

\[ \int \sqrt {(2-x) x \left (4-2 x+x^2\right )} \, dx=\frac {\sqrt {x}\, \sqrt {-x^{3}+4 x^{2}-8 x +8}\, x}{3}-\frac {4 \sqrt {x}\, \sqrt {-x^{3}+4 x^{2}-8 x +8}}{9}+\frac {2 \left (\int \frac {\sqrt {x}\, \sqrt {-x^{3}+4 x^{2}-8 x +8}\, x^{2}}{x^{3}-4 x^{2}+8 x -8}d x \right )}{9}-\frac {16 \left (\int \frac {\sqrt {x}\, \sqrt {-x^{3}+4 x^{2}-8 x +8}}{x^{4}-4 x^{3}+8 x^{2}-8 x}d x \right )}{9}-\frac {4 \left (\int \frac {\sqrt {x}\, \sqrt {-x^{3}+4 x^{2}-8 x +8}}{x^{3}-4 x^{2}+8 x -8}d x \right )}{9} \] Input:

int(((2-x)*x*(x^2-2*x+4))^(1/2),x)
 

Output:

(3*sqrt(x)*sqrt( - x**3 + 4*x**2 - 8*x + 8)*x - 4*sqrt(x)*sqrt( - x**3 + 4 
*x**2 - 8*x + 8) + 2*int((sqrt(x)*sqrt( - x**3 + 4*x**2 - 8*x + 8)*x**2)/( 
x**3 - 4*x**2 + 8*x - 8),x) - 16*int((sqrt(x)*sqrt( - x**3 + 4*x**2 - 8*x 
+ 8))/(x**4 - 4*x**3 + 8*x**2 - 8*x),x) - 4*int((sqrt(x)*sqrt( - x**3 + 4* 
x**2 - 8*x + 8))/(x**3 - 4*x**2 + 8*x - 8),x))/9