EllipKE
Version 1.0.0 (3.15 KB) by
Didier Clamond
Complete Elliptic Integrals of the first and second kind.
EllipKE: Complete Elliptic Integrals of the first and second kind of parameter M.
Similar to Matlab's ellipke, but extended to complex parameters.
The accuracy of K and E is around 15 digits, unless M is huge.
[K,E] = EllipKE(M) returns the value of the complete elliptic integrals of the first and second kind, evaluated for each element of the parameter M, the latter being real or complex, (i.e. it is not necessary that 0<=M<=1).
[K,E] = EllipKE(M,TOL) computes the complete elliptic integrals to the tolerance TOL instead of the default TOL = EPS(CLASS(M)).
[K,E] = EllipKE(M,TOL,M1) computes the complete elliptic integrals to the tolerance TOL with given M1 = 1 - M. Useful for increased accuracy when M is very closed to 1 (default, M1=1-M).
WARNING: Make sure that | M + M1 - 1 | < eps.
EXAMPLES 1:
K = EllipKE(1-1e-12)
K = 15.201815980070121 (accuracy = 6.14)
K = EllipKE(1-1e-300)
K = Inf
K = EllipKE(1-1e-12,[],1e-12)
K = 15.201804919087715 (accuracy = 15.95)
K = EllipKE(1-1e-300,[],1e-300)
K = 3.467740583102267e+02 (accuracy = 15.65)
Accuracy being defined by -log10(abs( 1 - approx/exact )).
EXAMPLE 2:
[K,E] = EllipKE(100+10i)
K = 0.170347954620372 + 0.360811870675761i (accuracy = 14.95)
E = 0.585677115900498 - 9.807284913933772i (accuracy = 14.88)
EXAMPLES 3:
[K,E] = EllipKE(-16^10)
K = 1.454280659896426e-05 (accuracy = 15.48)
E = 1.048576000007509e+06 (accuracy = 14.95)
[K,E] = EllipKE( 16^10)
K = 1.498028113169910e-06 - 1.454280659897045e-05i (accuracy = 15.89)
E = 7.220369298011065e-07 + 1.048575999992466e+06i (accuracy = 13.46)
[K,E] = EllipKE(-10^100)
K = 1.165155490108222e-48 (accuracy = 15.95)
E = 9.999999999999907e+49 (accuracy = 14.03)
EXAMPLE 4:
m = rand(10000,10000);
tic; EllipKE(m); toc
Elapsed time is 4.815462 seconds.
About 25% faster than Matlab's builtin ellipke function, and orders of magnitude faster than ellipticK from Matlab's symbolic toolbox, i.e.
tic; ellipke(m); toc
Elapsed time is 6.121154 seconds.
tic; ellipticK(m); toc
Computation aborted after 2 hours.
Cite As
Didier Clamond (2025). EllipKE (https://se.mathworks.com/matlabcentral/fileexchange/182506-ellipke), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2025b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
