<p dir="auto">This afternoon I have been writing code that relies in both elliptic integrals (<code class="notranslate">scipy.special.ellipk</code> and <code class="notranslate">scipy.special.ellipe</code>) but I was getting completely wrong values.</p>
<p dir="auto">This has been until I realized that scipy defines the elliptic integrals in a different that wikipedia or other resources do.</p>
<p dir="auto">For example, <a href="https://en.wikipedia.org/wiki/Elliptic_integrals" rel="nofollow">wikipedia</a> and Wolfram MathWorld <a href="http://mathworld.wolfram.com/EllipticIntegraloftheFirstKind.html" rel="nofollow">First Kind</a> and <a href="http://mathworld.wolfram.com/EllipticIntegraloftheSecondKind.html" rel="nofollow">Second Kind</a> define the complete integral of first kind as:</p>
<p dir="auto">K(x) = int_0^(pi/2) dy / sqrt(1 - x^2 sin^2 y)</p>
<p dir="auto">While scipy documentation defines it as:</p>
<p dir="auto">K(x) = int_0^(pi/2) dy / sqrt(1 - x sin^2 y)</p>
<p dir="auto">Note the lack of a square in the x.</p>
<p dir="auto">So, problem:</p>
<ul dir="auto">
<li>Different definition of what an elliptic integral is from what would be expected.</li>
</ul>
<p dir="auto">Proposed fix:</p>
<ul dir="auto">
<li>Change the implementation of the functions to match that of the more usual version.</li>
<li>Improve the documentation by including a (possibly in red or some bright colour) note saying that the parameter you pass doesn't get squared, or that you are calculating the integrals of the square root of the parameter.</li>
</ul>
<p dir="auto">Dear All<br>
While working with special functions that can be defined in terms of<br>
the complete elliptic integrals of the first and second kind, provided<br>
by ellipk and ellipe I realized, that , in contrast to<br>
the definition found on wikipedia, i.e.<br>
K(k) = \int_0^{\pi/2} \frac{d\theta}{\sqrt{1-k^2 \sin^2\theta}} = \int_0^1 \frac{dt}{\sqrt{(1-t^2)(1-k^2 t^2)}},<br>
the functions provided in scipy use the parameter m = k^2 appearing in the integral<br>
as argument.<br>
This is not exactly a bug, but it should maybe discussed why this convention<br>
was chosen in contrast to the more common one in<br>
lots of references on this matter.</p>
<p dir="auto">regards</p>
<p dir="auto">Moritz Braun</p>