nolta / Elliptic.jl

Elliptic integral and Jacobi elliptic special functions
MIT License
31 stars 16 forks source link

extend domain to negative m #19

Closed giovact closed 4 years ago

giovact commented 5 years ago

I encountered a problem in computing complete elliptic integrals for negative values of m while I was working on my PhD project. The function K(m) can be actually computed also for m<0. This is equivalent to the so-called 'imaginary modulus transformation' for this kind of integrals (http://analyticphysics.com/Mathematical%20Methods/A%20Miscellany%20of%20Elliptic%20Integrals.htm): K(-m)=(1/\sqrt(1+m))K(m/m+1) In this way, K(m) is well-defined for -\infty<m<1. I simply removed the if condition on 'm<0': the routine computes the correct values of the integral for negative m (I compared it to the mathematica implementation of this function and numerical integration). I expect the same problem to hold also for the incomplete integral F(\phi,m).

abraunst commented 5 years ago

I encountered a problem in computing complete elliptic integrals for negative values of m while I was working on my PhD project. The function K(m) can be actually computed also for m<0. This is equivalent to the so-called 'imaginary modulus transformation' for this kind of integrals (http://analyticphysics.com/Mathematical%20Methods/A%20Miscellany%20of%20Elliptic%20Integrals.htm): K(-m)=(1/\sqrt(1+m))K(m/m+1) In this way, K(m) is well-defined for -\infty<m<1. I simply removed the if condition on 'm<0': the routine computes the correct values of the integral for negative m (I compared it to the mathematica implementation of this function and numerical integration). I expect the same problem to hold also for the incomplete integral F(\phi,m).

Fixes #12

hamzaelsaawy commented 5 years ago

K still remains the same in the code, and only E is changed? I thought K was the focus.

giovact commented 5 years ago

@hamzaelsaawy you are right, I wanted to fix the domain for the function K(m) and I did it for the function E. The new commit fixes this mistake: K(m) can be computed for negative values of m and the function E was restored. Actually, I expect that all elliptic functions (both first or second order) can be extended to negative domain of their argument (I refer again to the link http://analyticphysics.com/Mathematical%20Methods/A%20Miscellany%20of%20Elliptic%20Integrals.htm). I have to check carefully, eventually I will fix the other functions.

hamzaelsaawy commented 5 years ago

I agree, all three integrals should (in most cases) handle negative moduli. The core algorithms should be able to handle negative (and complex) moduli -- with some edge cases. For K, 1-m > 0 so m < 1 is all we need. (This comes from RF(0, 1-m, 1), https://dlmf.nist.gov/19.16. It is more complicated for the incomplete cases though https://dlmf.nist.gov/19.25)

hamzaelsaawy commented 5 years ago

@nolta, did you have any thoughts on this?

nolta commented 5 years ago

Needs tests.

roiholtzman commented 4 years ago

I am also in the need for negative values of m.

nolta commented 4 years ago

I'd still like to have some tests for this, but i'm going to go ahead and merge.