Solving Kepler's Equation with CORDIC Double Iterations

Solving Kepler's Equation with CORDIC Double Iterations

MNRAS 000, 1–?? (2020) Preprint 10 August 2020 Compiled using MNRAS LATEX style file v3.0 Solving Kepler’s equation with CORDIC double iterations⋆ M. Zechmeister⋆⋆ Institut für Astrophysik, Georg-August-Universität, Friedrich-Hund-Platz 1, 37077 Göttingen, Germany Accepted 2020 August 6. Received 2020 August 5; in original form 2020 May 11. ABSTRACT In a previous work, we developed the idea to solve Kepler’s equation with a CORDIC-like algorithm, which does not require any division, but still multiplications in each iteration. Here we overcome this major shortcoming and solve Kepler’s equation using only bitshifts, addi- tions, and one initial multiplication. We prescale the initial vector with the eccentricity and the scale correction factor. The rotation direction is decided without correction for the changing scale. We find that double CORDIC iterations are self-correcting and compensate possible wrong rotations in subsequent iterations. The algorithm needs 75% more iterations and deliv- ers the eccentric anomaly and its sine and cosine terms times the eccentricity. The algorithm can be adopted for the hyperbolic case, too. The new shift-and-add algorithm brings Kepler’s equationclose to hardwareand allows to solve it with cheap and simple hardware components. Key words: celestial mechanics – methods: numerical 1 INTRODUCTION discuss an implementation (Sect. 5) and evaluate the performance of the algorithm (Sect. 6). Kepler’s equation (KE) is fundamental in many fields of astro- physics. It relates mean anomaly M and eccentric anomaly E via the equation E e sin E = M(E) (1) 2 CORDIC ALGORITHM FOR ELEMENTARY − FUNCTIONS t where M(t) = τ P with time t and orbital period P. In practice we often need to solve the inverse the problem A complex number can be expressed in Cartesian coordinates E(M). For instance, in orbit fitting, observing times t are given and z = x+iy (2) then the location or velocity of an object must be predicted, which then requires to compute E. as well as in polar coordinates Many methods have been proposed to solve KE, such as New- ton iterations, Halley’s method, table interpolation, or inverse series z = r exp iϕ (3) (Colwell 1993). In Zechmeister (2018, hereafter Ze18), we pro- where x = r cos ϕ and y = r sin ϕ. posed to use a CORDIC-like algorithm. CORDIC (Coordinate Ro- When we represent this number z by a sequence of rotations arXiv:2008.02894v1 [astro-ph.IM] 6 Aug 2020 tation Digital Computer) was invented by Volder (1959) and can with angles θn, these are simple additions in the exponent in the po- compute many elementary functions (e.g. cosine, sine, multiplica- lar representation or complex multiplications in the Cartesian rep- 1 tion) and needs only additions and bitshifts. We will briefly review resentation the CORDIC concept in Sect. 2. In Ze18, the rotation directions are set accurately. However, al- rei θn = z = r (cos θ +i sin θ ). (4) P Y n n ready this step requires a multiplication in each iteration. To over- n come this shortcoming, we study here the idea to simply ignore Additions are very easy to perform for computers, while multipli- the scale change in the direction decision, still hoping for a correct cations are usually more expensive, in particular with simple hard- convergence (Sect. 3). We will demonstrate that this approach is ware as years ago. Therefore, Volder (1959) sought to simplify the indeed purposeful given some appropriate adjustments. Finally, we product in Eq. (4). He factored the term cos θn z = r cos θ (1+i tan θ ) (5) Y n Y n n n ⋆ Code available at https://github.com/mzechmeister/ke/. ⋆⋆ E-mail: [email protected] and allowed only angles of the form 1 We provide an online demo at https://raw.githack.com/ mzechmeister/ke/master/cordic/js/cordic.html. θn = σnαn (6) c 2020 The Authors 2 M. Zechmeister π with 1 tan α = and σ 1, 1 (7) n 2n 1 n ∈{− } − 3−π for n 1. So the first angle is α = 45◦ and the next rotation angles 4 ≥ 1 αn are almost halved in each iteration and the rotation can be clock- or counter-clockwise (positive or negative). Now, Eq. (5) can be π written as − 2 σ z = rK 1+i n (8) N Y 2n −π n 4 single CORDIC iterations double CORDIC iterations where the term eccentric anomaly E [rad] (E - e sin E = M) 1 1 KN = cos αn = = (9) 0 Y Y + 2 Y √1 + 4 n π π 3π n n 1 tan αn n − 0 − − − π p 4 2 4 is called scale correction. The factor KN can be pre-computed, be- mean anomaly M [rad] cause the cos-function is symmetric and therefore independent of σn and the absolute values of the rotation angles θn = αn are pre- Figure 1. CORDIC on KE (for e = 1) with single iterations (red, 2 | | defined (Kc K 0.607 253) . shift sequence kn = 0, 1, 2, 3, 4,...) and with double iterations (blue, kn = ≡ ∞ ≈ Due to the angle choice in Eq. (7), the remaining product term 1, 1, 2, 2, 3, 3,...). can be computed efficiently. This is easier to explain when explic- itly writing an adjacent rotation for the real and imaginary part of z as Walther (1971) generalised the CORDIC algorithm with a lin- ear and hyperbolic mode allowing to compute multiplication, di- σn+1yn xn+1 = xn m (10) vision and the functions exp, ln, atanh, and square root. Table A1 − 2kn+1 σn+1 xn gives an overview of the different modes and Table A2 lists the yn+1 = yn + , (11) 2kn+1 required input and the corresponding output to obtain various el- ementary functions. This diversity demonstrates the capability of where the coordinate parameter m is 1 for the circular case ( 1 for this simple algorithm. the hyperbolic and 0 for the linear case). − However, it must be noted that the hyperbolic mode needs spe- The multiplication with σn is just a negation in case σn = 1. 3 n − cific iterations to be done twice for The multiplication by an integer power of two (2− ) is also very easy for a computer. It is a simple bit shift in binary system; very 3m+2 1 k 4, 13, 40, 121, ..., K, 3K + 1 = − . (13) similar in a decimal system a division by ten is just a left shift n ∈ 2 of the decimal point. Therefore, all multiplications are eliminated. This compensates the accumulating problem that subsequent ro- Only the one multiplication rKN in Eq. (8) remains; and in case tation angles are a little smaller than half, 2αn+1 < αn (while the r = 1 even this multiplication can be saved (Walther 1971); the start circular modes has here some redundancy 2αn+1 > αn, and the lin- vector is initialised with (x0, y0) = (KN , 0). ear mode is exact 2αn+1 = αn). With this sequence the convergence With these basic equations, the CORDIC algorithm can com- is overall. From now on, we use the variable name n for iteration pute the sine and cosine function. Given an input angle ϕ, we can number and kn for the shift sequence. approach it in each iteration with the condition +1 θn <ϕ σn+1 = P (12) 1 else. 3 CORDIC DOUBLE ITERATIONS FOR KEPLER’S − EQUATION The Cartesian representation is propagated simultaneously with the same rotation directions σn via Eqn. 10 and 11. So when To apply CORDIC to Kepler’s equation, we proposed in Ze18 the θ ϕ, then x cos ϕ and y sin ϕ. Figure A1 illustrates this modified condition for the rotation direction4 n → n → n → process.P +1 En e sin En < M The convergence range can be derived when performing only σn+1 = − (14) N (n 1) 1 else. positive rotations resulting in = θn = n atan 2− − 1.7433 = n 1 | | → − 99.88◦ for N . An initialP rotation withP 90◦, which needs no →∞ For readability and with respect to Eq. (1), we renamed θn with scale correction, can extend the range to 189.88◦. En and ϕ with M compared to Sect. 2. P It is also possible to calculate atan(x, y). So given x and y, the The decision in Eq. (14) is exact within the working precision. angle ϕ of this vector is wanted. In this mode, called vectoring, the However, the term sin En is not accessible in true CORDIC, be- component yn is driven towards zero. cause of the scale change. And a simultaneous compensation would require a multiplication in every iteration. When the start vector 2 n k The q-Pochhammer symbol is defined as (a; q)n = (1 aq ). Thus k=0 − − 2 ∞ k Q 1 3 the product series Kc = = (1+4− ) is the special case ( 1; ) The sequence is related to http://oeis.org/A003462. k 0 − 4 ∞ ≈ 2.71182. Likewise, in hyperbolicQ mode there occurs ∞ (1 4 k) = 4 For reasons of uniformity with code implementation, we list the positive k=1 − − ( 1 ; 1 ) 0.68854, which is also a special case of the EulerQ product. case first compared to Ze18. 4 4 ∞ ≈ MNRAS 000, 1–?? (2020) Solving KE with CORDIC double iterations 3 M the subsequent rotations. In case of single rotations, all subsequent E4 rotations α 2α can recover α . But the small redundancy E E5 n+1 n n+1 n M3 ≈ E3 in single rotationsP (in m = 1) is generally insufficient to compensate E2 3 y 3 M - 5 E yet the initiating departure. Double rotations, however, introduce 3 E sin M redundancy, which is the key to overcome the convergence prob- e 4 - M 3 E1 2 E lem, but also the price to be paid for the approximation.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us