Skip to content

duetosymmetry/elliptic-integrals-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

elliptic-integrals-js

Complete elliptic integrals in javascript

Here I've implemented complete elliptic integrals of the first, second, and third kind in javascript. The implementation follows an iteration scheme based on the convergence of the arithmetic-geometric mean, which converges at least quadratically with number of iterations---therefore effectively doubling the number of digits each iteration. These iteration schemes come from Garrett, Milan Wayne, Journal of Applied Physics 34.9 (1963): 2567-2573, Eqs. (18)-(21).

The functions extend the Math object with:

  • Math.agm(a,g): arithmetic-geometric mean of two non-negative numbers
  • Math.EllipticK(m): Complete elliptic integral of the first kind
  • Math.EllipticE(m): Complete elliptic integral of the second kind
  • Math.EllipticPi(n,m): Complete elliptic integral of the third kind

The arguments are the parameter m, which is related to the modulus k via m=k^2; and the characteristic n. The algorithms are valid for m<1, n<1.

To be completely clear, the functions are computing the following integrals:

  • $ K(m) = \int_0^{\pi/2} \frac{d\theta}{\sqrt{1 - m (\sin\theta)^2}} $
  • $ E(m) = \int_0^{\pi/2} \sqrt{1 - m (\sin\theta)^2} d\theta $
  • $ Pi(n,m) = \int_0^{\pi/2} \frac{1}{(1-n(\sin\theta)^2)\sqrt{1 - m (\sin\theta)^2}} d\theta $

This agrees with the conventions of Mathematica.

About

Complete elliptic integrals in javascript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published