https://github.com/duetosymmetry/elliptic-integrals-js
Complete elliptic integrals in javascript
https://github.com/duetosymmetry/elliptic-integrals-js
iteration-schemes javascript scientific-computing
Last synced: 11 days ago
JSON representation
Complete elliptic integrals in javascript
- Host: GitHub
- URL: https://github.com/duetosymmetry/elliptic-integrals-js
- Owner: duetosymmetry
- License: mit
- Created: 2016-02-25T00:37:46.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-01T21:54:56.000Z (about 9 years ago)
- Last Synced: 2025-04-15T08:19:51.520Z (11 days ago)
- Topics: iteration-schemes, javascript, scientific-computing
- Language: JavaScript
- Size: 3.91 KB
- Stars: 20
- Watchers: 1
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elliptic-integrals-js
Complete elliptic integrals in javascriptHere 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](http://dx.doi.org/10.1063/1.1729771), 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 kindThe 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`.