\(\int \frac {(1-\sqrt {x}+x)^2}{x^2} \, dx\) [24]

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

Optimal result

Integrand size = 16, antiderivative size = 25 \[ \int \frac {\left (1-\sqrt {x}+x\right )^2}{x^2} \, dx=-\frac {1}{x}+\frac {4}{\sqrt {x}}-4 \sqrt {x}+x+3 \log (x) \]

[Out]

-1/x+x+3*ln(x)+4/x^(1/2)-4*x^(1/2)

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 25, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.125, Rules used = {1371, 712} \[ \int \frac {\left (1-\sqrt {x}+x\right )^2}{x^2} \, dx=x-4 \sqrt {x}+\frac {4}{\sqrt {x}}-\frac {1}{x}+3 \log (x) \]

[In]

Int[(1 - Sqrt[x] + x)^2/x^2,x]

[Out]

-x^(-1) + 4/Sqrt[x] - 4*Sqrt[x] + x + 3*Log[x]

Rule 712

Int[((d_.) + (e_.)*(x_))^(m_)*((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIntegrand[(d +
 e*x)^m*(a + b*x + c*x^2)^p, x], x] /; FreeQ[{a, b, c, d, e, m}, x] && NeQ[b^2 - 4*a*c, 0] && NeQ[c*d^2 - b*d*
e + a*e^2, 0] && NeQ[2*c*d - b*e, 0] && IntegerQ[p] && (GtQ[p, 0] || (EqQ[a, 0] && IntegerQ[m]))

Rule 1371

Int[(x_)^(m_.)*((a_) + (c_.)*(x_)^(n2_.) + (b_.)*(x_)^(n_))^(p_.), x_Symbol] :> Dist[1/n, Subst[Int[x^(Simplif
y[(m + 1)/n] - 1)*(a + b*x + c*x^2)^p, x], x, x^n], x] /; FreeQ[{a, b, c, m, n, p}, x] && EqQ[n2, 2*n] && NeQ[
b^2 - 4*a*c, 0] && IntegerQ[Simplify[(m + 1)/n]]

Rubi steps \begin{align*} \text {integral}& = 2 \text {Subst}\left (\int \frac {\left (1-x+x^2\right )^2}{x^3} \, dx,x,\sqrt {x}\right ) \\ & = 2 \text {Subst}\left (\int \left (-2+\frac {1}{x^3}-\frac {2}{x^2}+\frac {3}{x}+x\right ) \, dx,x,\sqrt {x}\right ) \\ & = -\frac {1}{x}+\frac {4}{\sqrt {x}}-4 \sqrt {x}+x+3 \log (x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.03 (sec) , antiderivative size = 25, normalized size of antiderivative = 1.00 \[ \int \frac {\left (1-\sqrt {x}+x\right )^2}{x^2} \, dx=-\frac {1}{x}+\frac {4}{\sqrt {x}}-4 \sqrt {x}+x+3 \log (x) \]

[In]

Integrate[(1 - Sqrt[x] + x)^2/x^2,x]

[Out]

-x^(-1) + 4/Sqrt[x] - 4*Sqrt[x] + x + 3*Log[x]

Maple [A] (verified)

Time = 0.07 (sec) , antiderivative size = 22, normalized size of antiderivative = 0.88

method result size
derivativedivides \(-\frac {1}{x}+x +3 \ln \left (x \right )+\frac {4}{\sqrt {x}}-4 \sqrt {x}\) \(22\)
default \(-\frac {1}{x}+x +3 \ln \left (x \right )+\frac {4}{\sqrt {x}}-4 \sqrt {x}\) \(22\)
trager \(\frac {\left (-1+x \right ) \left (1+x \right )}{x}-\frac {4 \left (-1+x \right )}{\sqrt {x}}-3 \ln \left (\frac {1}{x}\right )\) \(26\)

[In]

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

[Out]

-1/x+x+3*ln(x)+4/x^(1/2)-4*x^(1/2)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 24, normalized size of antiderivative = 0.96 \[ \int \frac {\left (1-\sqrt {x}+x\right )^2}{x^2} \, dx=\frac {x^{2} + 6 \, x \log \left (\sqrt {x}\right ) - 4 \, {\left (x - 1\right )} \sqrt {x} - 1}{x} \]

[In]

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

[Out]

(x^2 + 6*x*log(sqrt(x)) - 4*(x - 1)*sqrt(x) - 1)/x

Sympy [A] (verification not implemented)

Time = 0.15 (sec) , antiderivative size = 22, normalized size of antiderivative = 0.88 \[ \int \frac {\left (1-\sqrt {x}+x\right )^2}{x^2} \, dx=- 4 \sqrt {x} + x + 3 \log {\left (x \right )} - \frac {1}{x} + \frac {4}{\sqrt {x}} \]

[In]

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

[Out]

-4*sqrt(x) + x + 3*log(x) - 1/x + 4/sqrt(x)

Maxima [A] (verification not implemented)

none

Time = 0.21 (sec) , antiderivative size = 22, normalized size of antiderivative = 0.88 \[ \int \frac {\left (1-\sqrt {x}+x\right )^2}{x^2} \, dx=x - 4 \, \sqrt {x} + \frac {4 \, \sqrt {x} - 1}{x} + 3 \, \log \left (x\right ) \]

[In]

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

[Out]

x - 4*sqrt(x) + (4*sqrt(x) - 1)/x + 3*log(x)

Giac [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 23, normalized size of antiderivative = 0.92 \[ \int \frac {\left (1-\sqrt {x}+x\right )^2}{x^2} \, dx=x - 4 \, \sqrt {x} + \frac {4 \, \sqrt {x} - 1}{x} + 3 \, \log \left ({\left | x \right |}\right ) \]

[In]

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

[Out]

x - 4*sqrt(x) + (4*sqrt(x) - 1)/x + 3*log(abs(x))

Mupad [B] (verification not implemented)

Time = 0.05 (sec) , antiderivative size = 24, normalized size of antiderivative = 0.96 \[ \int \frac {\left (1-\sqrt {x}+x\right )^2}{x^2} \, dx=x+6\,\ln \left (\sqrt {x}\right )+\frac {4\,\sqrt {x}-1}{x}-4\,\sqrt {x} \]

[In]

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

[Out]

x + 6*log(x^(1/2)) + (4*x^(1/2) - 1)/x - 4*x^(1/2)