Hipparchus-Math / hipparchus

An efficient, general-purpose mathematics components library in the Java programming language
Apache License 2.0
144 stars 43 forks source link

Incomplete elliptic integral of the third kind Π(n, Φ, m) sometimes selects the wrong sheet of the Riemann surface in the complex plane #152

Closed maisonobe closed 1 year ago

maisonobe commented 3 years ago

The incomplete elliptic integral of the third kind Π(n, Φ, m) has currently two implementations in the complex case: one based on Carlson transforms, very fast and one based on numerical integration, very slow and with lots of convergence issues and inaccuracy.

The one based on Carlson transforms sometimes selects the wrong sheet in the Riemann surface that corresponds to the integral definition. This is just as if for some points and the neighborhood the integration instead of being performed along a straight line from 0 to φ were done along a path that bypasses the pole when going from 0 to φ

See this discussion in the forum: Incomplete elliptic integral of the third kind Π(n, Φ, m) sometimes selects the wrong sheet of the Riemann surface in the complex plane

Serrof commented 1 year ago

Hi @maisonobe Should we keep this and #151 in milestone 3.0? I believe nobody is working on it unfortunately and it is kind of blocking the release isn't it?

maisonobe commented 1 year ago

I am more and more inclined to say… it is an unsolvable problem. Indeed, from a mathematical standpoint, all these functions are multivalued and selecting a Riemann sheet is a convention. As the computation of these integrals is done using a (very fast) iterative method that changes the problem, it jumps all the way through the complex plane (well, not really all the way, but you get the point), and so it may change from sheet to sheet. If we look at the table in forum discussion, we see even other implementations like Wolfram Alpha have similar issues, in fact it even seems to have more discontinuities than us.

So I would suggest to close this with the Wontfix label.

axkr commented 1 year ago

So I would suggest to close this with the Wontfix label.

Maybe writing a warning in the Javadoc similar to this one:

Warning: incomplete elliptic integrals have very complicated branch structure when extended to complex variables. For some functions in this module, branch cuts may be artifacts of the evaluation algorithm rather than having a natural mathematical justification. The user should, accordingly, watch out for edge cases where the functions implemented here may differ from other systems or literature. There may also exist points where a function should be well-defined but the implemented algorithm fails to produce a finite result due to artificial internal singularities.

maisonobe commented 1 year ago

Thanks for the link. I have updated the documentation, both the javadoc and the user guide.