Post on 08-Oct-2018
Precise & Fast Computation of
Elliptic Functions &Elliptic Integrals
aka
How Sushi Mania became Samurai
Swordsmith
Toshio Fukushima
(Nat’l Astron. Obs. Japan)
ResearchGate Fukushima Click
Sushi
Samurai Sword
3
Sushi
� Asteroid Itokawa, Eros, Ida, Kleopatra, …
4
Why Elliptic Function/Integral?
� Samurai Sword for Astronomer� Elliptic Function: 3D Rotational Dynamics
� Elliptic Integral: Gravity Field Evaluation
� Elliptic F. = Extension of Trig./Hyp. F� sn(u|0) = sin u, cn(u|0) = cos u, dn(u|0) = 1
� sn(u|1) = tanh u, cn(u|1) = dn(u|1) = 1/cosh u
� Elliptic I. = Ext. of Inverse Trig./Hyp. F
� F(phi|0) = phi, F(phi|1) = atanh(sin phi)5
GeneralElliptic Integral
� Definition:� P: Polyn.
� Q: Degree 3 or 4 Polyn.
� Reduction Th.: Legendre (1825-1832)
� F, E, Pi: Legendre’s 1st, 2nd, & 3rd Kind Elliptic I
� R: General Rational F
� phi: Amplitude, m: Parameter, n: Characteristic
PdxG
Q≡ ∫
6
( ) ( ) ( ) ( ) ( ), | | | , | , |G n m aF m bE m c n m R n mϕ ϕ ϕ ϕ ϕ= + + Π +
1st, 2nd, & 3rd
Kind Elliptic I
� 1st
� 2nd
� 3rd
� Jacobi’s Delta F ( ) 2| 1 sinm mϕ θ∆ ≡ −
7
( ) ( )0
| |E m m dϕ
ϕ θ θ≡ ∆∫
( )( ) ( )20
, |1 sin |
dn m
n m
ϕ θϕ
θ θΠ ≡
− ∆∫
( )( )0
||
dF m
m
ϕ θϕ
θ≡
∆∫
Associate Elliptic I
( )( ) ( ) ( )2
20
| 1 |cos|
1 sin
E m m F mdB m
mm
ϕ ϕ ϕθ θϕ
θ
− −≡ =
−∫
8
( )( ) ( )2
20
| |sin|
1 sin
F m E mdD m
mm
ϕ ϕ ϕθ θϕ
θ
−≡ =
−∫
( )( )
( ) ( )2
2 20
, | |sin, |
1 sin 1 sin
n m F mdJ n m
nn m
ϕ ϕ ϕθ θϕ
θ θ
Π −≡ =
− −∫
Jacobian Elliptic F
� Gauss and Abel
� Trio: sn, cn, dn
� Amplitude F = Inv. Incompl. EI: 1st Kind
� Jacobian EF = Trig. F of Amplitude
( )am( | ) |u m u F mϕ ϕ= ↔ =
9
( ) ( ) ( ) ( )sn | sin , cn | cos , dn | |u m u m u m mϕ ϕ ϕ= = = ∆
10
Existing Methods: I
� Complete EI of 1st, 2nd Kind: K(m), E(m)
� Cody’s Chebyshev Approx.� Genius of Hastings (1955)
� Cody and Wait (1980)� “Software Manual for the
Elementary Functions”
11
( ) ( ) ( ) ( )1 0ln 1K m K m m K m= − +
Existing Methods: II
� Complete EI� Bulirsch’s cel: Precise but not-so-Fast.
� Incomplete EI� Bulirsch’s el1: Fast and Precise
� Bulirsch’s el2, el3: Fast but Imprecise
� Carlson’s RF, RD, RJ : Precise but Slow
� Jacobian EF� Bulirsch’s sncndn: Precise but not-so-Fast.
12
Bulirsch and Carlson� R.Z. Bulirsch
� Elliptic I/F, GBS Method
13
� B.C. Carlson� Symmetric Elliptic I
Necessity is Mother of Invention
14
New Methods: I
� Single Variable F: K(m), E(m), …
� “Divide & Rule”: Piecewise Minimax Appr.
� Fukushima (2009b, 2011a, 2013c, 2015)
� Estrin’s Scheme� Most Efficient Parallel Algorithm
� 2.0-3.5 times faster than Horner
if using AVX2 @ Intel Haswell CPU
15
New Methods: II
� Addition Th. of EF: Lagrange
� Double Argument Transf.
� scd2 (Fukushima, NM, 2013a)� 1. Reduce u to sufficiently small u’=u/2N
� 2. Evaluate Truncated Maclaurin Series w.r.t. u’
� 3. Apply Double Argument Transf. N times
2 2 2 2 2 2
4 4 4
2sn 2 , cn 2 , dn 2
1 1 1
scd c s d d ms cu u u
ms ms ms
− −= = =
− − −
16
Application to1st Kind Incomplete EI
� Half Arg. Formula
� y=sn2(u|m)
� elf (Fukushima, NM, 2010a)� 1. Compute y=sin2(phi)
� 2. Apply Half Arg. Formula N times to Reduce y
� 3. Evaluate F’ by Maclaurin Series w.r.t. y’
� 4. F(phi|m) = 2N F’
( )( )'
1 1 1 1
yy
y my=
+ − + −
17
Application to2nd & 3rd Kind EI
� Double Arg. Formulas of D and J
� elbdj (Fukushima, JCAM, 2011b,2012a)� 1. Compute y=sin2(phi)
� 2. Apply Half Arg. Formula N times to Reduce y
� 3. Evaluate D’ & J’ by Maclaurin Series w.r.t. y’
� 4. Apply Double Arg. Formula N times for D and J
( )2 ' , 2 ' ,D D t J J T t h= + = +
18
( )( )/ , 1t s c h n n n m= = − −
Universal ArcTangent F
� Definition
� uatan (Fukushima, JCAM, 2012a, Appendix)
( )
( ) ( )
( )
( ) ( )
1
1
tan / 0
, 0
tanh / 0
ht h h
T t h t h
ht h h
−
−
>
≡ =
− − <
19
New Methodfor J(n|m)
� Add. Th. w.r.t. n: Jacobi
� Double Charact. Transf.
� celj (Fukushima, JCAM, 2013d)
( )
( )( )
2'
1 1
c d J yKJ
c c d
+ −=
+ +
20
/y n m≡
1 , 1c y d my= − = −
CPU Time Comparison� nanosec @ PC with Intel Core i7-2675QM
21
Elliptic Integral/Function Bulirsch Carlson Cody new
K(m) 93 330 62 24
B(m), D(m) 186 922 29
B(m), D(m), J(n|m) 383 1871 159
F(phi|m) 178 313 173
B(phi|m), D(phi|m) 712 213
B(phi|m), D(phi|m), J(phi,n|m) 1426 464
sn(u|m), cn(u|m), dn(u|m) 165 116
Conclusion
� Single Var. F: Piecewise Minimax Approx.
� Multi-Var. F: Half/Double Arg. Transf.� Forward Problem: All Elliptic I/F
� Inverse Problem: General Elliptic I
� Derivatives: Recursive Computation
� 1.4-32 times Speed-Up except F(phi|m)
� Fortran 90 Software @ ResearchGate22