\(\int \frac {1}{\sqrt {(b-x) (-a+x)}} \, dx\) [105]

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

Optimal result

Integrand size = 15, antiderivative size = 32 \[ \int \frac {1}{\sqrt {(b-x) (-a+x)}} \, dx=-\arctan \left (\frac {a+b-2 x}{2 \sqrt {-a b+(a+b) x-x^2}}\right ) \]

[Out]

-arctan(1/2*(a+b-2*x)/(-a*b+(a+b)*x-x^2)^(1/2))

Rubi [A] (verified)

Time = 0.01 (sec) , antiderivative size = 32, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.200, Rules used = {1976, 635, 210} \[ \int \frac {1}{\sqrt {(b-x) (-a+x)}} \, dx=-\arctan \left (\frac {a+b-2 x}{2 \sqrt {x (a+b)-a b-x^2}}\right ) \]

[In]

Int[1/Sqrt[(b - x)*(-a + x)],x]

[Out]

-ArcTan[(a + b - 2*x)/(2*Sqrt[-(a*b) + (a + b)*x - x^2])]

Rule 210

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 635

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

Rule 1976

Int[(u_.)*((e_.)*((a_.) + (b_.)*(x_)^(n_.))*((c_) + (d_.)*(x_)^(n_.)))^(p_), x_Symbol] :> Int[u*(a*c*e + (b*c
+ a*d)*e*x^n + b*d*e*x^(2*n))^p, x] /; FreeQ[{a, b, c, d, e, n, p}, x]

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

Mathematica [A] (verified)

Time = 0.03 (sec) , antiderivative size = 55, normalized size of antiderivative = 1.72 \[ \int \frac {1}{\sqrt {(b-x) (-a+x)}} \, dx=\frac {2 \sqrt {b-x} \sqrt {-a+x} \arctan \left (\frac {\sqrt {-a+x}}{\sqrt {b-x}}\right )}{\sqrt {(a-x) (-b+x)}} \]

[In]

Integrate[1/Sqrt[(b - x)*(-a + x)],x]

[Out]

(2*Sqrt[b - x]*Sqrt[-a + x]*ArcTan[Sqrt[-a + x]/Sqrt[b - x]])/Sqrt[(a - x)*(-b + x)]

Maple [A] (verified)

Time = 0.11 (sec) , antiderivative size = 28, normalized size of antiderivative = 0.88

method result size
default \(\arctan \left (\frac {x -\frac {b}{2}-\frac {a}{2}}{\sqrt {-a b +\left (a +b \right ) x -x^{2}}}\right )\) \(28\)

[In]

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

[Out]

arctan((x-1/2*b-1/2*a)/(-a*b+(a+b)*x-x^2)^(1/2))

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 43, normalized size of antiderivative = 1.34 \[ \int \frac {1}{\sqrt {(b-x) (-a+x)}} \, dx=-\arctan \left (-\frac {\sqrt {-a b + {\left (a + b\right )} x - x^{2}} {\left (a + b - 2 \, x\right )}}{2 \, {\left (a b - {\left (a + b\right )} x + x^{2}\right )}}\right ) \]

[In]

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

[Out]

-arctan(-1/2*sqrt(-a*b + (a + b)*x - x^2)*(a + b - 2*x)/(a*b - (a + b)*x + x^2))

Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 0.90 (sec) , antiderivative size = 71, normalized size of antiderivative = 2.22 \[ \int \frac {1}{\sqrt {(b-x) (-a+x)}} \, dx=\begin {cases} - i \log {\left (a + b - 2 x + 2 i \sqrt {- a b - x^{2} + x \left (a + b\right )} \right )} & \text {for}\: a b - \frac {\left (a + b\right )^{2}}{4} \neq 0 \\\frac {\left (- \frac {a}{2} - \frac {b}{2} + x\right ) \log {\left (- \frac {a}{2} - \frac {b}{2} + x \right )}}{\sqrt {- \left (- \frac {a}{2} - \frac {b}{2} + x\right )^{2}}} & \text {otherwise} \end {cases} \]

[In]

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

[Out]

Piecewise((-I*log(a + b - 2*x + 2*I*sqrt(-a*b - x**2 + x*(a + b))), Ne(a*b - (a + b)**2/4, 0)), ((-a/2 - b/2 +
 x)*log(-a/2 - b/2 + x)/sqrt(-(-a/2 - b/2 + x)**2), True))

Maxima [F(-2)]

Exception generated. \[ \int \frac {1}{\sqrt {(b-x) (-a+x)}} \, dx=\text {Exception raised: ValueError} \]

[In]

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

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(b-a>0)', see `assume?` for mor
e details)Is

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 61 vs. \(2 (28) = 56\).

Time = 0.31 (sec) , antiderivative size = 61, normalized size of antiderivative = 1.91 \[ \int \frac {1}{\sqrt {(b-x) (-a+x)}} \, dx=\frac {1}{8} \, {\left (a^{2} - 2 \, a b + b^{2}\right )} \arcsin \left (\frac {a + b - 2 \, x}{a - b}\right ) \mathrm {sgn}\left (-a + b\right ) - \frac {1}{4} \, \sqrt {-a b + a x + b x - x^{2}} {\left (a + b - 2 \, x\right )} \]

[In]

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

[Out]

1/8*(a^2 - 2*a*b + b^2)*arcsin((a + b - 2*x)/(a - b))*sgn(-a + b) - 1/4*sqrt(-a*b + a*x + b*x - x^2)*(a + b -
2*x)

Mupad [F(-1)]

Timed out. \[ \int \frac {1}{\sqrt {(b-x) (-a+x)}} \, dx=\int \frac {1}{\sqrt {-\left (a-x\right )\,\left (b-x\right )}} \,d x \]

[In]

int(1/(-(a - x)*(b - x))^(1/2),x)

[Out]

int(1/(-(a - x)*(b - x))^(1/2), x)