Mathematica Asked by user45146 on March 21, 2021
When I feed Mathematica the following integral:
Integrate[Sqrt[(A - x) (B - x)/x], {x, 0, B}]
it spits it back out without evaluating it. However, it can evaluate the integral
Integrate[Sqrt[(2 - x) (1 - x)/x], {x, 0, 1}]
just fine. From reading other questions, I think the problem is that I need to add more assumptions. I tried every assumption I know about:
Integrate[Sqrt[(A - x) (B - x)/x], {x, 0, B},
Assumptions -> {A > 0, B > 0, A > B, x ∈ Reals, A ∈ Reals, B ∈ Reals}]
but Mathematica still won’t do the integral. I know it has to be able to do the integral, since it can do it for definite values of $A$ and $B$ just fine! What other assumptions do I need to add to make it work?
There are two different issues:
suboptimal handling of elliptic integrals in Mathematica, this is why Integrate
with appropriate assumptions doesn't provide satisfactory results.
unsatisfactory feedback of assumptions on the results
Before of playing with assumptions let's slightly reformulate the problem by changing the integration variable (x -> z == x/b
):
$$ int_{0}^{b} sqrt{ frac{(a-x)(b-x)}{x}} dx = b^{3/2} int_{0}^{1} sqrt{ frac{(frac{a}{b}-z)(1-z)}{z}} dz$$
Now the integral can be simply calculated with the appropriate assumption (a/b == c > 1
):
b^(3/2) Integrate[ Sqrt[(c - x) (1 - x)/x], {x, 0, 1}, Assumptions -> c > 1]
(1/(3 (-1 + c))) b^(3/2) (2 Sqrt[-1 + c] (-1 + c^2) EllipticE[1/(1 - c)] - 2 c (Sqrt[-1 + c] (1 + c) EllipticK[1/(1 - c)] - 2 I (-1 + c) (EllipticK[1 - c] - I EllipticK[c])))
Ad.1
The result is not manifestly real ( see also this answer) however it can be easily checked by choosing various constants, e.g. in the OP we had a == 2
and b == 1
, therefore
% /. c -> 2
1/3 (6 EllipticE[-1] - 4 (3 EllipticK[-1] - 2 I (EllipticK[-1] - I EllipticK[2])))
which is the same numerically as the exact integral
Chop @ N @ %
2.07216
Plot[ ReIm[(1/(3 (-1 + c))) (2 Sqrt[-1 + c] (-1 + c^2) EllipticE[
1/(1 - c)] - 2 c (Sqrt[-1 + c] (1 + c) EllipticK[1/(1 - c)]
- 2 I (-1 + c) (EllipticK[1 - c] - I EllipticK[c])))],
{c, 0, 5}, Evaluated -> True, Exclusions -> c == 1, PlotStyle -> Thick]
This plot demonstrates that the integral is real for c > 1
:
Mathematica 10 cannot simplify the result asssuming c > 1
,
one should play further with special functions or exploit capabilities of
MathematicalFunctionData
(new in version 11 ), which could help in providing manifestly real symbolic result.
Ad.2
The integral with a/b
instead of c
does not yield the result, evaluate e.g.
b^(3/2) Integrate[Sqrt[(a/b - x) (1 - x)/x], {x, 0, 1}, Assumptions -> a > b]
Answered by Artes on March 21, 2021
Since Artes has already pointed to my previous answer, and my opinion remains unchanged to this very day, let me supply the closed form for your integral, obtained using formula 233.07 in Byrd and Friedman:
With[{A = 2, B = 1},
{NIntegrate[Sqrt[(A - x) (B - x)/x], {x, 0, B}, WorkingPrecision -> 20],
N[2/3 (A/B)^(3/2) ((1 + B/A) EllipticE[B/A] - (1 - B/A) EllipticK[B/A]), 20]}]
{2.0721594194996321471, 2.0721594194996321443}
Answered by J. M.'s ennui on March 21, 2021
With (0 <= x <= b <= a) the result of
Integrate[(Sqrt[a - x]*Sqrt[b - x])/Sqrt[x], x]
can be transformed into the simple form
(2/3)*(Sqrt[a - x]*Sqrt[b - x]*Sqrt[x] +
Sqrt[a]*(a + b)*EllipticE[ArcTan[Sqrt[x]/Sqrt[b - x]], b/a] -
Sqrt[a]*(a - b)*EllipticF[ArcTan[Sqrt[x]/Sqrt[b - x]], b/a])
which can be verified by calculating the derivative w.r.t. x. The transformation involves a shift of Pi/2 of the argument and an expansion of the elliptic integrals of complex argument into real part and imaginary constant (disposable). Within the above range of parameters it may be plotted without difficulty:
a = 4; b = 2; Plot[{NIntegrate[(Sqrt[a - y]*Sqrt[b - y])/Sqrt[y], {y, 0, x}],
(2/3)*(Sqrt[a - x]*Sqrt[b - x]*Sqrt[x] +
Sqrt[a]*(a + b)*EllipticE[ArcTan[Sqrt[x]/Sqrt[b - x]], b/a] -
Sqrt[a]*(a - b)*EllipticF[ArcTan[Sqrt[x]/Sqrt[b - x]], b/a])}, {x, 0, b},
PlotStyle -> {Blue, {Dashed, Orange}}]
The value at x=b
corresponds to the one obtained above with Byrd and Friedman.
Answered by Andreas on March 21, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP