# Problem with elliptic integrals

**URL:** https://discourse.julialang.org/t/problem-with-elliptic-integrals/99922
**Category:** General Usage
**Tags:** specialfunctions
**Created:** [June 6, 2023, 5:03am UTC](https://discourse.julialang.org/t/problem-with-elliptic-integrals/99922 "2023-06-06T05:03:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)
#### Post date: [June 6, 2023, 5:03am UTC](https://discourse.julialang.org/t/problem-with-elliptic-integrals/99922/1 "2023-06-06T05:03:13Z")

</div>

```julia
using Plots

using SpecialFunctions
# using Elliptic

K = ellipk # Computes Complete Elliptic Integral of 1st kind K(m)
E = ellipe # Computes Complete Elliptic Integral of 2nd kind E(m)

psi0(k) = (K(k) - E(k)) / k

@show psi0(1e-8) # psi0(1.0e-8) = 0.7853981909278218

x = range(1e-5, 0.1, length=1000)
y = psi0
plot(x, y; label = :none)

```

![psi0-plot](https://global.discourse-cdn.com/julialang/original/3X/7/e/7e6516e3b877829df6699cb5f394e262c79ed3e9.png)

The results are the same whether I use `SpecialFunctions` or `Elliptic`

Now, from [Wikipedia](https://en.wikipedia.org/wiki/Elliptic_integral),  
 ![Screenshot K(k)](https://global.discourse-cdn.com/julialang/original/3X/d/e/dea3c097dc16c9963b0bba872213bcff5ea8c636.png)  
 ![Screenshot E(k)](https://global.discourse-cdn.com/julialang/original/3X/5/c/5cfc9d1b6ee142d0d2a26a2af1307adda269a390.png)  
We neglect here the higher terms for `k` approaching zero (by cropping screenshot 😄)

Thus, for small k  
`(K(k) - E(k)) / k ≈ k * π / 4 ` which tends to zero with `k` tending to zero.  
Not to `0.785...`😲

---

<div class="post-metadata">

### Author: ![Ininterrompue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ininterrompue/32/5594_2.png) [@Ininterrompue](https://discourse.julialang.org/u/Ininterrompue)
#### Post date: [June 6, 2023, 6:09am UTC](https://discourse.julialang.org/t/problem-with-elliptic-integrals/99922/2 "2023-06-06T06:09:30Z")

</div>

From the [docs](https://specialfunctions.juliamath.org/stable/functions_list/#SpecialFunctions.ellipk) the elliptic integrals are defined using m as argument, not k, with k^{2} = m. Which means the numerator in your function is approximately m\pi/4, denominator m, hence you get a number approaching \pi/4.
