Design and Implementation of a Modern Algebraic Manipulator for Celestial Mechanics
Total Page:16
File Type:pdf, Size:1020Kb
Design and implementation of a modern algebraic manipulator for Celestial Mechanics Francesco Biscani January 30, 2008 “Design and implementation of a modern algebraic manipulator for Celestial Me- chanics”, by Francesco Biscani ([email protected]), is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License (http://creativecommons.org/licenses/by/3.0/). Copyright © 2007 by Francesco Biscani. Created with LYX and X TE EX. Dedicata alla memoria di Elisa. Summary¹ e goals of this research are the design and implementation of a modern and efficient algebraic manipulator specialised for Celestial Mechanics. Specialised algebraic manipulators are funda- mental tools both in classical Celestial Mechanics and in modern studies on the behaviour of dynamical systems, and they are routinely employed in such diverse tasks as the elaboration of theories of motion of celestial bodies, geodetical and terrestrial orientation studies, perturbation theories for artificial satellites and studies about the long-term evolution of the Solar System. Specialised manipulators for Celestial Mechanics are usually concerned with mathematical objects known as Poisson series (see Danby et al. [1966]), which are defined as multivariate Fourier series with multivariate Laurent series as coefficients: X ( ) cos P (i1y1 + i2y2 + ... + inyn) , i sin i where the Pi are multivariate polynomials. Poisson series manipulators have been developed continuously since the ’60s and today there are many different packages available (an incomplete list includes Herget and Musen [1959], Broucke and Garthwaite [1969], Jefferys [1970, 1972], Rom [1970], Bourne and Horton [1971], Babaev et al. [1980], Dasenbrock [1982], Richardson [1989], Abad and San-Juan [1994], Ivanova [1996], Chapront [2003b,a] and Gastineau and Laskar [2005]). General manipulators, like Mathematica and Maple, are unsuitable for use in actual problems because their genericity implies a very high impact on performance (for many operations this slowdown can be estimated in three or four orders of magnitude). Many of the existing specialised manipulators, on the other hand, are much too focused on specific problems, and the general unavailability of the source code makes it hard to reuse and adapt existing ma- nipulators for other problems. Besides, not always the data structures and the algorithms used in existing computer algebra systems are fast, leading to sub-optimal performance. We propose here Piranha, a Poisson series manipulation framework designed to be extended and adapted for different purposes. It is written in C++ using template programming techniques (see Vandevoorde and Josuttis [2002]), it is object-oriented and uses paradigms like multiple inheritance, iterators, static polymorphism and operator overloading. Piranha is based on generic programming techniques, which means that it is possible to use arbitrary classes to represent the elements of Poisson series, as long as those classes behave in a predefined way (i.e., as long as they provide a defined set of methods). In generic programming language we can say that Piranha defines concept classes and that the actual implementation of such concepts are models (see Gregor et al. [2006]). Piranha uses modern data structures for the representation of Poisson series. In particular hashing techniques are widely employed. e main hash function used in Piranha was con- ceived originally to operate on strings in databases (see Ramakrishna and Zobel [1997]), and has proved to be very effective for the representation of Poisson series. Piranha employs also the multi_index_container class from the Boost C++ libraries, which provides a flexible and efficient container class to store and order the terms of a series in multiple ways. Many other facilities provided by the Boost libraries are used. ¹is section is intended just as a condensed summary, for a more thorough introduction please see Chapter 1. v Piranha introduces also a new methodology for the computation of cosines and sines of Pois- son series, based on a expansion into Bessel functions of the first kind known as Jacobi-Anger development (see Brown and Churchill [1993]). is kind of development allows to compute cosines and sines of a wide class of Poisson series, whereas the Taylor expansions commonly employed for this task in other manipulators are effective only for specific Poisson series. Another original contribution, to the best of our knowledge, is the approach devised for the multiplication of Poisson series, which is based on a technique derived from the Kronecker al- gorithm and that we have called coded arithmetics, and which allows to speed up considerably the manipulation of trigonometric multipliers during multiplication. We then introduce Pyranha, a set of bindings to use Piranha from the Python programming language (see Python). With Pyranha it is possible to leverage Piranha’s capabilities from a com- fortable and easy to use interpreted language. is way, by means of enhanced Python interfaces (like IPython), it is also possible to use Piranha interactively à la Mathematica or Maple, without the need to code in C++ but retaining the speed of a compiled language. We also present some examples of use cases for a Poisson series manipulator. We show how Piranha can be used for the transformation of theories of motion and for the computation of the harmonic development of the tide-generating potential. Finally, we briefly discuss Piranha’s performance by comparing it to the well-known manipu- lators TRIP and PARI. e benchmarks are encouraging and show that Piranha is on the right track performance-wise. Optimizations and improvements for Piranha are then discussed, with particular focus on cache memory optimizations and memory allocation, in light of the fact that presently Piranha employs data structure implementations and memory allocators available in the C++ standard library (which are hence not optimized for the specific tasks of the manipula- tor). Beside performance improvements, also functionality extensions are also discussed, such as the implementation of still missing manipulation capabilities. vi Riassunto Introduzione Gli scopi di questa ricerca sono il design e l’implementazione di un manipolatore algebrico spe- cializzato per la Meccanica Celeste moderno ed efficiente. I manipolatori algebrici specializ- zati sono strumenti fondamentali sia nella Meccanica Celeste classica che nei moderni studi sui sistemi dinamici, e sono impiegati abitualmente in diversi campi: teorie del moto di corpi ce- lesti, studi geodetici e di orientazione planetaria, teorie perturbative per satelliti artificiali e studi riguardanti l’evoluzione a lungo termine del Sistema Solare. Serie di Poisson I manipolatori algebrici specifici per la Meccanica Celeste solitamente si occupano di oggetti matematici noti come serie di Poisson (Danby et al. [1966]). Le serie di Poisson sono definite come serie di Fourier multivariate con serie di Laurent mul- tivariate come coefficienti: X ( ) cos P (x1, x2,..., xm) (i1y1 + i2y2 + ... + inyn) , i sin i dove le Pi (x1, x2,..., xm) sono polinomi multivariati a coefficienti complessi. In Meccanica Celeste le serie di Poisson con coefficienti puramente numerici sono note anche come serie di Fourier: X ( ) cos C (i1y1 + i2y2 + ... + inyn) . i sin i Le serie di Poisson formano un gruppo abeliano sotto le operazioni di addizione e sottrazione, ma non sotto l’operazione di moltiplicazione. Non è infatti possibile, in generale, calcolare in forma finita l’operazione di inversione di una serie di Poisson. La moltiplicazione di serie di Poisson è svolta con l’ausilio delle elementari formule trigonometriche di Werner: AB AB A cos α · B cos β = cos (α - β) + cos (α + β) , 2 2 AB AB A cos α · B sin β = sin (α + β) - sin (α - β) , 2 2 AB AB A sin α · B cos β = sin (α - β) + sin (α + β) , 2 2 AB AB A sin α · B sin β = cos (α - β) - cos (α + β) . 2 2 Le serie di Poisson sono inoltre caratterizzate da una forma canonica che assicura la rappre- sentabilità in maniera univoca con il numero minimo di termini. Le serie di Poisson in Meccanica Celeste solitamente appaiono negli ambiti delle teorie per- turbative, dove la loro introduzione permette di applicare i metodi standard della dinamica per- turbativa, quali ad esempio il metodo di averaging. Tipicamente la forma di serie di Poisson è vii mantenuta in tutte le fasi dell’elaborazione di una teoria del moto, e anche le soluzioni finali sono espresse in forma di serie di Poisson o serie di Fourier. L’operazione di gran lunga più dispendiosa nella manipolazione di serie di Poisson, sia in ter- mini di potenza di calcolo che di utilizzo( ) della memoria, è la moltiplicazione. La complessità di questa operazione è quadratica, O n2 (mentre addizione e sottrazione hanno complessità lin- eare, O(n)), e pertanto si rende necessaria l’adozione di metodologie di troncamento delle serie per evitare la crescita esplosiva del numero di termini durante le moltiplicazioni. Operazioni avanzate sulle serie di Poisson In Meccanica Celeste tipicamente sono necessarie manipolazioni sulle serie di Poisson più com- plicate rispetto alle operazioni fondamentali di somma e moltiplicazione. In particolare è neces- sario poter calcolare l’inversione e la radice quadrata di serie di Poisson. Queste due operazioni possono essere affrontate in maniera unificata ricorrendo al teorema binomiale generalizzato di Newton (Arfken and Weber [2005]), che permette di ricondurre l’elevamento di una serie di Poisson ad una potenza reale ad uno sviluppo in