Class EllipticIntegral
- Author:
- ilb The elliptic integral of the first kind is defined by F(k, phi) = Integral from 0 to phi of
d(theta)/sqrt(1 - k*k*sin(theta)*sin(theta)) where k is the modulus Letting t = sin(theta), the elliptic
integral of the first kind can be written as F(k, x) = Integral from 0 to x of dt/sqrt((1-t*t)(1-k*k*t*t))
where x = sin(phi)
The elliptic integral of the second kind is defined by E(k, phi) = Integral from 0 to phi of sqrt(1 - k*k*sin(theta)*sin(theta))d(theta) where k is the modulus Letting t = sin(theta), the elliptic integral of the second kind can be written as E(k, x) = Integral from 0 to x of (sqrt(1 - k*k*t*t)/sqrt(1 - t*t))dt where x = sin(phi)
The elliptic integral of the third kind is defined by Pi(k, c, phi) = Integral from 0 to phi of d(theta)/((1 - c*sin(theta)*sin(theta))*sqrt(1 - k*k*sin(theta)*sin(theta))) Letting t = sin(theta), the elliptic integral of the third kind can be written as Pi(k, c, x) = Integral from 0 to x of dt/((1 - c*t*t)*sqrt((1 - t*t)*(1 - k*k*t*t))) where x = sin(phi)
When phi = PI/2 (x = 1), the elliptic integrals defined above are called complete elliptic integrals When phi is not equal to PI/2, the elliptic integrals are often referred to as incomplete elliptic integrals The complete elliptic integral of the first kind is: K(k) = Integral from 0 to PI/2 of d(theta)/sqrt(1 - k*k*sin(theta)*sin(theta)) where k is the modulus = Integral from 0 to 1 of dt/sqrt((1-t*t)(1-k*k*t*t)) The complete elliptic integral of the second kind is: E(k, phi) = Integral from 0 to PI/2 of sqrt(1 - k*k*sin(theta)*sin(theta))d(theta) where k is the modulus = Integral from 0 to 1 of (sqrt(1 - k*k*t*t)/sqrt(1 - t*t))dt The comlplete elliptic integral of the third kind is: Pi(k, c, phi) = Integral from 0 to PI/2 of d(theta)/((1 - c*sin(theta)*sin(theta))*sqrt(1 - k*k*sin(theta)*sin(theta))) = Integral from 0 to 1 of dt/((1 - c*t*t)*sqrt((1 - t*t)*(1 - k*k*t*t)))
The code for EllipticIntegralType = COMPLETE1, COMPLETE2, INCOMPLETE1, and INCOMPLETE2 is ported from a C++ program in Figures 1 and 2 of "Numerical Calculation of the Elliptic Integrals of the First and Second Kinds with Complex Modulus" by Tohru Morita, Interdisciplinary Information Sciences, Vol. 6, No. 1, 2000, pp. 67-74.
How to doublecheck? Use: 1.) Port of FORTRAN code for complete and incomplete elliptic integrals of the first kind with real arguments from Computation of Special Functions by Shanjie Zhang and Jianming Jin, John Wiley invalid input: '&' Sons, Inc., 1996, Chapter 18, Elliptic Integrals and Jacobian Elliptic Functions, pp. 654-679.
Test results: For complete elliptic integrals of the first and second kind with real arguments, the Morita arithmetic-geometric mean, Morita Carlson's, ZHANG comelp, and ZHANG elit all give the same answer.
For incomplete elliptic integrals of the first and second kind with real arguemnts, both Morita Carlson's and ZHANG elit give the same answer.
On 2016/04/09 0:05, Gandler, William (NIH/CIT) [E] wrote: > Dear Interdisciplinary Information Sciences: > I am a computer programmer at the National Institutes of Health in Bethesda, Maryland, USA. I would like to incorporate elliptic integral calculation routines into the MIPAV software package. These routines are in Figures 1 and 2 of "Numerical Calculation of the Elliptic Integrals of the First and Second Kind with Complex Modulus" by Tohru Morita, Interdisciplinary Information Sciences, Vol. 6, No. 1, 2000, pp. 67-74. Who should I ask for permission? > > Sincerely, > > William Gandler Dear Dr William Gandler, Thank you very much for your inquiry. You may use the calculation routines published in our journal with clear statement of attribution. Sincerely, Nobuaki Obata Editor-in-Chief IIS
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double[]DOCUMENT ME!private double[]DOCUMENT ME!private booleanIf false, function used If true, analytic continuation of function used.private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleprivate double BIG = 3.0E137; // 3.0E37.private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private booleank is the modulus k', the complementary modulus = sqrt(1 - k*k).private booleanDOCUMENT ME!private int[]DOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private doublemodulus, 0 invalid input: '<'= mod invalid input: '<'= 1.private doubleImaginary part of modulus or complementary modulus.private doubleReal part of modulus or complementary modulus.private static final intF(k, phi) INCOMPLETE1 E(k, phi) INCOMPLETE2 K(k) COMPLETE1 E(k) COMPLETE2 Complex arguments for first and second complete and incomplete elliptic integrals.private intDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleFor complete integrals phir = PI/2, phii = 0.private doubleDOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private doubleDOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private booleanDOCUMENT ME!private booleanDOCUMENT ME!private booleanDOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private static final intCompare outputs of different modules for self-testing.private double[]DOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private ViewUserInterfaceDOCUMENT ME!private booleanDOCUMENT ME!private static final intReal arguments for first and second complete and incomplete elliptic integrals. -
Constructor Summary
ConstructorsConstructorDescription~ Constructors ---------------------------------------------------------------------------------------------------EllipticIntegral(boolean complete, double modr, double modi, boolean complementaryModulusUsed, boolean analyticContinuationUsed, double phir, double phii, double[] firstr, double[] firsti, double[] secondr, double[] secondi, boolean useStandardMethod, int[] errorFlag) When calculating the complete integrals K(k) and E(K), we can make complete true or false, except when abs(k') invalid input: '<'= 1.0E-10, in which case complete must be true and the complementary modulus must be used The only merit of the alternative method over the standard method is that the code is simpler Both methods are based on modifications of Carlson's algortihm.EllipticIntegral(double mod, double[] first, double[] second) Used for complete elliptic integrals of first and second kind with real modulus 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus.EllipticIntegral(double modr, double modi, boolean complementaryModulusUsed, boolean analyticContinuationUsed, double[] firstr, double[] firsti, double[] secondr, double[] secondi, int[] errorFlag) Constructor only for complete integrals with phi = PI/2.EllipticIntegral(double mod, double phi, double[] first, double[] second) Used for complete and incomplete elliptic integrals of first and second kind with real modulus and argument 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus phi, argument in radians.EllipticIntegral(double mod, double phi, double c, double[] third) Used for complete and incomplete elliptic integrals of the third kind with real modulus, real argument phi, and real parameter c 0 invalid input: '<'= mod invalid input: '<'= 1 phi, argument in radians c parameter, 0 invalid input: '<'= c invalid input: '<'=1. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcel12(double ckr, double cki) Routine cel12 only calculates complete integrals of the first and second kind with complex arguments Based on the arithmetic-geometric mean procedure Ported from Tohru Morita article.private voidcomelp(double mod) Ported from Computation of Special Functions by Shanjie Zhang and Jianming Jin Computes complete first and second elliptic integrals with a real modulus 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus.private doublecosh(double x) DOCUMENT ME!private voidelit(double mod, double phi) Ported from Computation of Special Functions by Shanjie Zhang and Jianming Jin Computes complete and incomplete first and second elliptic integrals with a real modulus and real argument 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus arg is the argument in radians.private voidelit3(double mod, double phi, double c) Ported from Computation of Special Functions by Shanjie Zhang and Jianming Jin Computes complete and incomplete elliptic integrals of the third kind with a real modulus real argument, and real parameter 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus arg is the argument in radians c is the parameter, 0 invalid input: '<'= c invalid input: '<'= 1.private voidell12(double phir, double phii, double akr, double aki, double ckr, double cki, int sgnck) Calculates complete and incomplete elliptic integrals of the first and second kind with complex arguments Ported from the Tohru Morita article.private voidrfrd(double xrtr, double xrti, double yrtr, double yrti) Ported from Tohru Morita article.private voidrfrdb(double xrtr, double xrti, double yrtr, double yrti) Ported from Tohru Morita article.voidrun()DOCUMENT ME!private voidrunTest()DOCUMENT ME!private doublesinh(double x) DOCUMENT ME!private voidsqrtc(double zinr, double zini, double[] zsqr, double[] zsqi) Ported from Tohru Morita article Performs square root of complex argument.private doublezabs(double zr, double zi) zabs computes the absolute value or magnitude of a double precision complex variable zr + j*zi.private voidzcos(double inr, double ini, double[] outr, double[] outi) DOCUMENT ME!private voidzdiv(double ar, double ai, double br, double bi, double[] cr, double[] ci) complex divide c = a/b.private voidzmlt(double ar, double ai, double br, double bi, double[] cr, double[] ci) complex multiply c = a * b.private voidzsin(double inr, double ini, double[] outr, double[] outi) DOCUMENT ME!
-
Field Details
-
MORITA_SOURCE
private static final int MORITA_SOURCEF(k, phi) INCOMPLETE1 E(k, phi) INCOMPLETE2 K(k) COMPLETE1 E(k) COMPLETE2 Complex arguments for first and second complete and incomplete elliptic integrals.- See Also:
-
ZHANG_SOURCE
private static final int ZHANG_SOURCEReal arguments for first and second complete and incomplete elliptic integrals.- See Also:
-
TEST_SOURCE
private static final int TEST_SOURCECompare outputs of different modules for self-testing.- See Also:
-
aki
private double[] akiDOCUMENT ME! -
akr
private double[] akrDOCUMENT ME! -
analyticContinuationUsed
private boolean analyticContinuationUsedIf false, function used If true, analytic continuation of function used. -
BIGd
private double BIGdDOCUMENT ME! -
c
private double cDOCUMENT ME! -
C1
private double C1private double BIG = 3.0E137; // 3.0E37. -
C1d
private double C1dDOCUMENT ME! -
C2
private double C2DOCUMENT ME! -
C2d
private double C2dDOCUMENT ME! -
C3
private double C3DOCUMENT ME! -
C3d
private double C3dDOCUMENT ME! -
C4
private double C4DOCUMENT ME! -
C4d
private double C4dDOCUMENT ME! -
C5d
private double C5dDOCUMENT ME! -
C6d
private double C6dDOCUMENT ME! -
cki
private double[] ckiDOCUMENT ME! -
ckr
private double[] ckrDOCUMENT ME! -
complementaryModulusUsed
private boolean complementaryModulusUsedk is the modulus k', the complementary modulus = sqrt(1 - k*k). -
complete
private boolean completeDOCUMENT ME! -
errorFlag
private int[] errorFlagDOCUMENT ME! -
ERRTOL
private double ERRTOLDOCUMENT ME! -
ERRTOLb
private double ERRTOLbDOCUMENT ME! -
first
private double[] firstDOCUMENT ME! -
firsti
private double[] firstiDOCUMENT ME! -
firstr
private double[] firstrDOCUMENT ME! -
mod
private double modmodulus, 0 invalid input: '<'= mod invalid input: '<'= 1. -
modi
private double modiImaginary part of modulus or complementary modulus. -
modr
private double modrReal part of modulus or complementary modulus. -
nrep
private int nrepDOCUMENT ME! -
phi
private double phiDOCUMENT ME! -
phii
private double phiiDOCUMENT ME! -
phir
private double phirFor complete integrals phir = PI/2, phii = 0. -
pihf
private double pihfDOCUMENT ME! -
rdi
private double[] rdiDOCUMENT ME! -
rdr
private double[] rdrDOCUMENT ME! -
RERR
private double RERRDOCUMENT ME! -
rfi
private double[] rfiDOCUMENT ME! -
rfr
private double[] rfrDOCUMENT ME! -
runcel12
private boolean runcel12DOCUMENT ME! -
runcomelp
private boolean runcomelpDOCUMENT ME! -
runelit
private boolean runelitDOCUMENT ME! -
second
private double[] secondDOCUMENT ME! -
secondi
private double[] secondiDOCUMENT ME! -
secondr
private double[] secondrDOCUMENT ME! -
sgnck
private int sgnckDOCUMENT ME! -
source
private int sourceDOCUMENT ME! -
third
private double[] thirdDOCUMENT ME! -
TINY
private double TINYDOCUMENT ME! -
TINYd
private double TINYdDOCUMENT ME! -
UI
DOCUMENT ME! -
useStandardMethod
private boolean useStandardMethodDOCUMENT ME!
-
-
Constructor Details
-
EllipticIntegral
public EllipticIntegral()~ Constructors --------------------------------------------------------------------------------------------------- -
EllipticIntegral
public EllipticIntegral(double mod, double[] first, double[] second) Used for complete elliptic integrals of first and second kind with real modulus 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus.- Parameters:
mod- DOCUMENT ME!first- DOCUMENT ME!second- DOCUMENT ME!
-
EllipticIntegral
public EllipticIntegral(double mod, double phi, double[] first, double[] second) Used for complete and incomplete elliptic integrals of first and second kind with real modulus and argument 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus phi, argument in radians.- Parameters:
mod- DOCUMENT ME!phi- DOCUMENT ME!first- DOCUMENT ME!second- DOCUMENT ME!
-
EllipticIntegral
public EllipticIntegral(double mod, double phi, double c, double[] third) Used for complete and incomplete elliptic integrals of the third kind with real modulus, real argument phi, and real parameter c 0 invalid input: '<'= mod invalid input: '<'= 1 phi, argument in radians c parameter, 0 invalid input: '<'= c invalid input: '<'=1.- Parameters:
mod- DOCUMENT ME!phi- DOCUMENT ME!c- DOCUMENT ME!third- DOCUMENT ME!
-
EllipticIntegral
public EllipticIntegral(double modr, double modi, boolean complementaryModulusUsed, boolean analyticContinuationUsed, double[] firstr, double[] firsti, double[] secondr, double[] secondi, int[] errorFlag) Constructor only for complete integrals with phi = PI/2. The method called is based on the arithmetic-geometric mean procedure If only the complete integrals are calculated, the arithmetic-geometric mean procdure is superior to the 2 methods based on Carlson's algorithm- Parameters:
modr- DOCUMENT ME!modi- DOCUMENT ME!complementaryModulusUsed- DOCUMENT ME!analyticContinuationUsed- DOCUMENT ME!firstr- DOCUMENT ME!firsti- DOCUMENT ME!secondr- DOCUMENT ME!secondi- DOCUMENT ME!errorFlag- DOCUMENT ME!
-
EllipticIntegral
public EllipticIntegral(boolean complete, double modr, double modi, boolean complementaryModulusUsed, boolean analyticContinuationUsed, double phir, double phii, double[] firstr, double[] firsti, double[] secondr, double[] secondi, boolean useStandardMethod, int[] errorFlag) When calculating the complete integrals K(k) and E(K), we can make complete true or false, except when abs(k') invalid input: '<'= 1.0E-10, in which case complete must be true and the complementary modulus must be used The only merit of the alternative method over the standard method is that the code is simpler Both methods are based on modifications of Carlson's algortihm.- Parameters:
complete- DOCUMENT ME!modr- DOCUMENT ME!modi- DOCUMENT ME!complementaryModulusUsed- DOCUMENT ME!analyticContinuationUsed- DOCUMENT ME!phir- DOCUMENT ME!phii- DOCUMENT ME!firstr- DOCUMENT ME!firsti- DOCUMENT ME!secondr- DOCUMENT ME!secondi- DOCUMENT ME!useStandardMethod- DOCUMENT ME!errorFlag- DOCUMENT ME!
-
-
Method Details
-
run
public void run()DOCUMENT ME! -
cel12
private void cel12(double ckr, double cki) Routine cel12 only calculates complete integrals of the first and second kind with complex arguments Based on the arithmetic-geometric mean procedure Ported from Tohru Morita article.- Parameters:
ckr- DOCUMENT ME!cki- DOCUMENT ME!
-
comelp
private void comelp(double mod) Ported from Computation of Special Functions by Shanjie Zhang and Jianming Jin Computes complete first and second elliptic integrals with a real modulus 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus.- Parameters:
mod- DOCUMENT ME!
-
cosh
private double cosh(double x) DOCUMENT ME!- Parameters:
x- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
elit
private void elit(double mod, double phi) Ported from Computation of Special Functions by Shanjie Zhang and Jianming Jin Computes complete and incomplete first and second elliptic integrals with a real modulus and real argument 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus arg is the argument in radians.- Parameters:
mod- DOCUMENT ME!phi- DOCUMENT ME!
-
elit3
private void elit3(double mod, double phi, double c) Ported from Computation of Special Functions by Shanjie Zhang and Jianming Jin Computes complete and incomplete elliptic integrals of the third kind with a real modulus real argument, and real parameter 0 invalid input: '<'= mod invalid input: '<'= 1, mod is the modulus arg is the argument in radians c is the parameter, 0 invalid input: '<'= c invalid input: '<'= 1.- Parameters:
mod- DOCUMENT ME!phi- DOCUMENT ME!c- DOCUMENT ME!
-
ell12
private void ell12(double phir, double phii, double akr, double aki, double ckr, double cki, int sgnck) Calculates complete and incomplete elliptic integrals of the first and second kind with complex arguments Ported from the Tohru Morita article.- Parameters:
phir- DOCUMENT ME!phii- DOCUMENT ME!akr- DOCUMENT ME!aki- DOCUMENT ME!ckr- DOCUMENT ME!cki- DOCUMENT ME!sgnck- DOCUMENT ME!
-
rfrd
private void rfrd(double xrtr, double xrti, double yrtr, double yrti) Ported from Tohru Morita article.- Parameters:
xrtr- DOCUMENT ME!xrti- DOCUMENT ME!yrtr- DOCUMENT ME!yrti- DOCUMENT ME!
-
rfrdb
private void rfrdb(double xrtr, double xrti, double yrtr, double yrti) Ported from Tohru Morita article.- Parameters:
xrtr- DOCUMENT ME!xrti- DOCUMENT ME!yrtr- DOCUMENT ME!yrti- DOCUMENT ME!
-
runTest
private void runTest()DOCUMENT ME! -
sinh
private double sinh(double x) DOCUMENT ME!- Parameters:
x- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
sqrtc
private void sqrtc(double zinr, double zini, double[] zsqr, double[] zsqi) Ported from Tohru Morita article Performs square root of complex argument.- Parameters:
zinr- DOCUMENT ME!zini- DOCUMENT ME!zsqr- DOCUMENT ME!zsqi- DOCUMENT ME!
-
zabs
private double zabs(double zr, double zi) zabs computes the absolute value or magnitude of a double precision complex variable zr + j*zi.- Parameters:
zr- doublezi- double- Returns:
- double
-
zcos
private void zcos(double inr, double ini, double[] outr, double[] outi) DOCUMENT ME!- Parameters:
inr- DOCUMENT ME!ini- DOCUMENT ME!outr- DOCUMENT ME!outi- DOCUMENT ME!
-
zdiv
private void zdiv(double ar, double ai, double br, double bi, double[] cr, double[] ci) complex divide c = a/b.- Parameters:
ar- doubleai- doublebr- doublebi- doublecr- double[]ci- double[]
-
zmlt
private void zmlt(double ar, double ai, double br, double bi, double[] cr, double[] ci) complex multiply c = a * b.- Parameters:
ar- doubleai- doublebr- doublebi- doublecr- double[]ci- double[]
-
zsin
private void zsin(double inr, double ini, double[] outr, double[] outi) DOCUMENT ME!- Parameters:
inr- DOCUMENT ME!ini- DOCUMENT ME!outr- DOCUMENT ME!outi- DOCUMENT ME!
-