<<

51st IEEE Conference on Decision and Control December 10-13, 2012. Maui, Hawaii, USA

Hamel’s Formalism and Variational Integrators on a Sphere

Dmitry V. Zenkov, Melvin Leok, and Anthony M. Bloch

Abstract— This paper discusses Hamel’s formalism and its The paper is organized as follows. Hamel’s formalism applications to structure-preserving integration of mechanical and its discretization are briefly discussed in Sections II systems. It utilizes redundant coordinates in order to elim- and III. The dynamics of a spherical is reviewed inate multiple charts on the configuration space as well as nonphysical artificial singularities induced by local coordinates, in Section IV. The discrete model for the pendulum based on while keeping the minimal possible degree of redundancy and Hamel’s formalism, its comparison to some other discretiza- avoiding integration of differential-algebraic equations. tion techniques, and simulations are given in Sections V, VI, and VII. I.INTRODUCTION This paper introduces a new variational integrator for a II.LAGRANGIANMECHANICS spherical pendulum. The configuration space for this pendu- A. The Euler–Lagrange Equations lum is a two-dimensional sphere. Calculations in spherical A Lagrangian mechanical system is specified by a smooth coordinates are not a good option because of unavoidable manifold Q called the configuration space and a function artificial singularities introduced by these coordinates at the L : TQ → R called the Lagrangian. In many cases, poles. In addition, the topology of a sphere makes it impos- the Lagrangian is the kinetic minus potential energy of the sible to use global singularity-free intrinsic coordinates. system, with the kinetic energy defined by a Riemannian In order to avoid the issues mentioned above, an integrator metric and the potential energy being a smooth function on that utilizes the interpretation of a sphere as a homogeneous the configuration manifold Q. If necessary, non-conservative space was introduced in [15]. This integrator performs very can be introduced (e.g., gyroscopic forces that are well, but has a somewhat large degree of redundancy. This represented by terms in L that are linear in the velocity), but paper targets the development of an integrator whose perfor- this is not discussed in detail in this paper. mance is similar to that of the integrator in [15] and whose In local coordinates q = (q1, . . . , qn) on the configuration redundancy is the minimum possible. space Q we write L = L(q, q˙). The dynamics is given by Both the present paper and [15] interpret the pendulum the Euler–Lagrange equations as a rotating rigid body. The algorithm introduced in [15] is d ∂L ∂L based on the evaluation of the rotation matrix that represents = , i = 1, . . . , n. (1) the attitude for this body. The key feature of the dynamics dt ∂q˙i ∂qi utilized in the present paper is that, in order to capture the These equations were originally derived by Lagrange [14] orientation of a rigid body, it is sufficient to evaluate just in 1788 by requiring that simple balance F = ma one column of that rotation matrix. The resulting equations be covariant, i.e. expressible in arbitrary generalized coordi- of motion are interpreted as Hamel’s equations written in nates. A variational derivation of the Euler–Lagrange equa- redundant coordinates. tions, namely Hamilton’s principle (also called the principle The general exposition of discrete Hamel’s formalism will of critical action), came later in the work of Hamilton [12] be a subject of a future publication. Here we demonstrate and [13] in 1834/35. For more details, see [4], [18], and the usefulness of some of this formalism by constructing Theorem 2.1 below. an integrator for a spherical pendulum that is energy- and momentum-preserving. The calculations are carried out in B. The Hamel Equations the Cartesian coordinates of the three-dimensional Euclidean In this paragraph we briefly discuss the Hamel equations. space. This allows one to avoid singularities and/or multiple The exposition follows paper [5]. coordinate charts that are inevitable for calculations on a In many cases the Lagrangian and the equations of motion sphere. Hamel’s approach allows one, among other things, have a simpler structure when written using velocity compo- to represent the dynamics in such a way that the length nents measured against a frame that is unrelated to system’s constraint becomes unnecessary. Thus, one avoids the well- local configuration coordinates. An example of such a system known difficulty of numerically solving differential-algebraic is the rigid body. equations. Let q = (q1, . . . , qn) be local coordinates on the config- uration space Q and ui ∈ TQ, i = 1, . . . , n, be smooth D. V. Zenkov is with the Department of Mathematics, North Carolina independent local vector fields defined in the same coordi- [email protected] State University, Raleigh, NC 27695, USA, 1 M. Leok is with the Department of Mathematics, University of California nate neighborhood. The components of ui relative to the San Diego, La Jolla, CA 92093, USA, [email protected] 1 A. M. Bloch is with the Department of Mathematics, University of In certain cases, some or all of ui can be chosen to be global vector Michigan, Ann Arbor, MI 48109, USA, [email protected] fields on Q.

978-1-4673-2064-1/12/$31.00 ©2012 IEEE 7504 j j basis ∂/∂q will be denoted ψi ; that is, on the space of curves in Q connecting qa to qb on the ∂ interval [a, b], where we choose variations of the curve u (q) = ψj(q) , q(t) that satisfy δq(a) = δq(b) = 0. i i ∂qj (ii) The curve q(t) satisfies the Euler–Lagrange equa- where i, j = 1, . . . , n and where summation on j is under- tions (1). stood. (iii) The curve (q(t), ξ(t)) is a critical point of the functional Let ξ = (ξ1, . . . , ξn) ∈ n be the components of the R Z b velocity vector q˙ ∈ TQ relative to the basis u1, . . . , un, i.e., l(q, ξ) dt (7) a q˙ = ξiu (q); (2) i with respect to variations δξ, induced by the variations i then δq = η ui(q), and given by i l(q, ξ) := L(q, ξ ui(q)) (3) k k k i j δξ =η ˙ + cij(q)ξ η . (8) is the Lagrangian of the system written in the local coor- The curve (q(t), ξ(t)) satisfies the Hamel equations dinates (q, ξ) on the tangent bundle TQ. The coordinates (iv) (5) coupled with the equations q˙ = ξiu (q). (q, ξ) are Lagrangian analogues of non-canonical variables i in Hamiltonian dynamics. For the proof of Theorem 2.1 and the early development Define the quantities cm(q) by the equations and history of these equations, as well as other variational ij structures associated with Hamel’s equations see [22], [10], m [ui(q), uj(q)] = cij (q)um(q), (4) [5], and [2]. i, j, m = 1, . . . , n. These quantities vanish if and only if III.THEDISCRETEHAMELEQUATIONS the vector fields ui(q), i = 1, . . . , n, commute. Here and A. Discrete Hamilton’s Principle elsewhere, [ · , · ] is the Jacobi–Lie bracket of vector fields A discrete analogue of can be on Q. obtained by discretizing Hamilton’s principle; this approach Viewing u as vector fields on TQ whose fiber components i underlies the construction of variational integrators. See equal 0 (that is, taking the vertical lift of these vector fields), Marsden and West [19], and references therein, for a more one defines the directional derivatives u [l] for a function i detailed discussion of discrete mechanics. l : TQ → by the formula R A key notion is that of the discrete Lagrangian, which is j ∂l a map Ld : Q×Q → that approximates the action integral ui[l] = ψ . R i ∂qj along an exact solution of the Euler–Lagrange equations The evolution of the variables (q, ξ) is governed by the joining the configurations qk, qk+1 ∈ Q, Hamel equations Z h d L (qk, qk+1) ≈ ext L(q, q˙) dt, (9) d ∂l m ∂l i q∈C([0,h],Q) 0 j = cij m ξ + uj[l]. (5) dt ∂ξ ∂ξ where C([0, h],Q) is the space of curves q : [0, h] → Q with i coupled with equations (2). If ui = ∂/∂q , equations (5) q(0) = qk, q(h) = qk+1, and ext denotes extremum. become the Euler–Lagrange equations (1). In the discrete setting, the action integral of Lagrangian Equations (5) were introduced in [10] (see also [21] for mechanics is replaced by an action sum details and some history). N−1 d X d C. Hamilton’s Principle for Hamel’s Equations S (q0, q1, . . . , qN ) = L (qk, qk+1), k=0 Let γ :[a, b] → Q be a smooth curve in the configuration where q ∈ Q, k = 0, 1,...,N, is a finite sequence space. A variation of the curve γ(t) is a smooth map β : k in the configuration space. The equations are obtained by [a, b] × [−ε, ε] → Q that satisfies the condition β(t, 0) = the discrete Hamilton’s principle, which extremizes the γ(t). This variation defines the vector field discrete action given fixed endpoints q and q . Taking 0 N ∂β(t, s) the extremum over q , . . . , q gives the discrete Euler– δγ(t) = 1 N−1 ∂s s=0 Lagrange equations d d along the curve γ(t). D1L (qk, qk+1) + D2L (qk−1, qk) = 0, Theorem 2.1: Let L : TQ → R be a Lagrangian and for k = 1,...,N −1. This implicitly defines the update map l : TQ → R be its representation in local coordinates (q, ξ). Then, the following statements are equivalent: Φ: Q × Q → Q × Q, where Φ(qk−1, qk) = (qk, qk+1) and Q × Q replaces the velocity phase space TQ of Lagrangian (i) The curve q(t), where a ≤ t ≤ b, is a critical point of mechanics. the action functional In the case that Q is a vector space, it may be convenient Z b 1 to use (qk+1/2, vk,k+1), where qk+1/2 = 2 (qk + qk+1) and L(q, q˙) dt (6) 1 a vk,k+1 = h (qk+1 − qk), as a state of a discrete mechanical

7505 system. In such a representation, the discrete Euler–Lagrange IV.THESPHERICALPENDULUM equations become Consider a spherical pendulum whose length is r and 1 d d  is m. We view the pendulum as a point mass moving on 2 D1L (qk−1/2, vk−1,k) + D1L (qk+1/2, vk,k+1) the sphere of radius r centered at the origin of 3. The + 1 D Ld(q , v ) − D Ld(q , v ) = 0. R h 2 k−1/2 k−1,k 2 k+1/2 k,k+1 development here is based on the representation These equations are equivalent to the variational principle M˙ = M × Ω + T , (13) N−1 d X d Γ˙ = Γ × Ω (14) δS = D1L (qk+1/2, vk,k+1)δqk+1/2 k=0 of the dynamics of a spherical pendulum, where the pendu- d  + D2L (qk+1/2, vk,k+1)δvk,k+1 = 0, (10) lum is viewed as a rigid body rotating about a fixed point. Here Ω is the angular velocity of the pendulum, M is its where the variations δqk+1/2 and δvk,k+1 are induced by the , Γ is the unit vertical vector (and thus variations δqk and are given by the formulae the constraint kΓk = 1 is imposed), and T is the torque 1  1  δqk+1/2 = 2 δqk+1 + δqk , δvk,k+1 = h δqk+1 − δqk . produced by a force acting on the pendulum, all written B. Discrete Hamel’s Equations relative to the body frame. Throughout the paper, boldface In order to construct the discrete Hamel equations for a characters represent three-dimensional vectors. Note that the given mechanical system, one starts by selecting the vector projection of T on Γ is zero. We assume here that the force is conservative, with potential energy U(Γ). For the pendulum, fields u1(q), . . . , un(q) and computing the Lagrangian l(q, ξ) U(Γ) = mgha, Γi = mgrΓ3, where a is the vector from the given by (3). One then discretizes this Lagrangian (we only 2 discuss the mid-point rule here) and obtains origin to the pendulum bob. Note that the potential energies for forces like are invariant with respect to rotations d l (qk+1/2, ξk,k+1) = hl(qk+1/2, ξk,k+1) (11) about Γ. Note that the discretization in (11) is carried out after writing There are two independent components in equation (13). the continuous-time Lagrangian as a function of (q, ξ). We emphasize that this representation, though redundant, One of the challenges of discretizing the Hamel equations eliminates the use of local coordinates on the sphere, such has been understanding the discrete analogue of the bracket as spherical coordinates. More details on this appear below. term in (5). Until recently, it was only known how to handle Spherical coordinates, while being a nice theoretical tool, this for systems on Lie groups (see e.g. [6] and [17]). In introduce artificial singularities at the north and south poles. the discrete model of a spherical pendulum discussed below, That is, the equations of motion written in spherical coor- these terms vanish, and we will not discuss the approach dinates have denominators vanishing at the poles, but this to discretize the bracket terms in this paper (details on this has nothing to do with the physics of the problem and is topic can be found in [3]). solely caused by the geometry of the spherical coordinates. The analogue of the variational principle (10) is obtained Thus, the use of spherical coordinates in calculations is not by setting advisable. Another important remark is that the length of the vector Γ i 1 i j j δqk+1/2 = 2 ψj(qk+1/2)(ηk+1 + ηk), is a conservation law of equations (13) and (14), δξi = 1 (ηi − ηi ) + Bi , k,k+1 h k+1 k k kΓk = const, (15) where Bk is the discrete analogue of the bracket term in (8). The discrete Hamel equations read and thus adding the constraint kΓk = 1 does not result in a system of differential-algebraic equations. The latter are 1 d d  2 Dul (qk−1/2, ξk−1,k) + Dul (qk+1/2, ξk,k+1) known to be a nontrivial object for numerical integration. ∗ 1 d Equations (13) and (14) may be interpreted in a number + Bk + h D2l (qk−1/2, ξk−1,k) of ways. For instance, one can view them as the dynamics − D ld(q , ξ ) = 0, (12) 2 k+1/2 k,k+1 of a degenerate rigid body. For this interpretation, select an d where Dul is the directional derivative given by the formula orthonormal body frame with the third vector aligned along

d the direction of the pendulum. The inertia tensor relative to Dul (qk+1/2, ξk,k+1) such a frame is I = diag{mr2, mr2, 0}, and the Lagrangian

d d reads = l (qk+1/2 + su(qk+1/2), ξk,k+1) ds 1 s=0 l(Ω, Γ) = 2 hI Ω, Ωi − U(Γ). (16) ∗ and where Bk is the discrete analogue of the bracket term With this frame selection, the third component of the angular of the continuous-time Hamel equations (5). As mentioned momentum of the body vanishes, above, this term vanishes for the spherical pendulum prob- lem, and is therefore not explicitly shown here (see [3] for ∂l 3 M3 = 3 = I3Ω = 0, details). Equations (12) along with the discrete analogue ∂Ω of equations (2) define the update map (qk−1/2, ξk−1,k) 7→ 2All frames in this paper are orthonormal, and thus the dual vectors are (qk+1/2, ξk,k+1). interpreted as regular vectors, if necessary.

7506 and thus there are only two nontrivial equations in (13). Thus, or, in components, one needs five equations to capture the pendulum dynamics. 1 2 1 1  1 2 2  This reflects the fact that rotations about the direction of the h r Ωk,k+1 − Ωk−1,k = 2 gr Γk+1/2 + Γk−1/2 , (22) 1 2 2 2  1 1 1  pendulum have no influence on the pendulum’s motion. The h r Ωk,k+1 − Ωk−1,k = − 2 gr Γk+1/2 + Γk−1/2 , (23) 3 dynamics then can be simplified by setting Ω = 0. 1 1 1  1 2 2  h Γk+1/2 − Γk−1/2 = − 4 Ωk,k+1 + Ωk−1,k Alternatively, (13) and (14) may be interpreted as the × Γ3 + Γ3 , dynamics of the Suslov problem (see [21] and [4]) for a k+1/2 k−1/2 1 2 2  1 1 1  rigid body with a rotationally-invariant inertia tensor and h Γk+1/2 − Γk−1/2 = 4 Ωk,k+1 + Ωk−1,k constraint Ω3 = 0. 3 3  × Γk+1/2 + Γk−1/2 , Using either interpretation, the dynamics is represented by 1 Γ3 − Γ3  = 1 Ω2 + Ω2  the system of five first-order differential equations h k+1/2 k−1/2 4 k,k+1 k−1,k 1 1  × Γk+1/2 + Γk−1/2 ˙ 2 ˙ 1 1 1 1  M1 = mgrΓ , M2 = −mgrΓ , (17) − 4 Ωk,k+1 + Ωk−1,k 1 2 3 2 1 3 3 2 1 1 2 2 2  Γ˙ = −Ω Γ , Γ˙ = Ω Γ , Γ˙ = Ω Γ − Ω Γ . (18) × Γk+1/2 + Γk−1/2 . (24) The latter equations are in fact Hamel’s equations written The discretization of equation (14) is constructed to be in the redundant coordinates (Γ1, Γ2, Γ3) relative to the kΓk-preserving. Indeed, using the isomorphism Ω 7→ Ω frame between the spaces of three-dimensional vectors Ω = (Ω1, Ω2, Ω3) and skew-symmetric matrices 3 ∂ 2 ∂ u = Γ − Γ ,  3 2 1 ∂Γ2 ∂Γ3 0 −Ω Ω 3 1 1 ∂ 3 ∂ Ω =  Ω 0 −Ω , u = Γ − Γ . 2 1 2 ∂Γ3 ∂Γ1 −Ω Ω 0 equation (21) becomes Recall that the length of Γ is the conservation law, so that the constraint kΓk = 1 does not need to be imposed, but −1 Γk+1/2 = (I − Ak) (I + Ak)Γk−1/2, the appropriate level set of the conservation law needs to be selected. where h  3 Our discretization will be based on this point of view, i.e., Ak = 4 Ωk,k+1 + Ωk−1,k . the discrete dynamics will be written in the form of discrete Hamel’s equations. The discrete dynamics will posses the It is straightforward to check that the matrix discrete version of the conservation law (15), so that the −1 (I − Ak) (I + Ak) algorithm should be capable, in theory, of preserving the length of Γ up to machine precision. is orthogonal (it is simply the Cayley transform of Ak), and therefore kΓk+1k = kΓkk. As expected, the discrete dynamics is momentum- V. VARIATIONAL DISCRETIZATION FOR THE preserving: SPHERICALPENDULUM 2 1 1 2 2  mr Γk+1/2Ωk,k+1 + Γk+1/2Ωk,k+1 = const, The integrator for a spherical pendulum is constructed by i.e., the vertical component of spatial momentum is con- discretizing Hamel’s equations (17) and (18). served. This can be verified either using general symmetry Let the positive real constant h be the time step. Applying arguments, or by a straightforward calculation. the mid-point rule to (16), the discrete Lagrangian is com- The discrete dynamics is energy-preserving: puted to be 1 2h 1 2 2 2i 3 2 mr Ωk,k+1 + Ωk,k+1 + mgrΓk+1/2 = const. d h l = hI Ωk,k+1, Ωk,k+1i − hU(Γk+1/2). (19) 2 This is confirmed by multiplying equations (22) and (23) by 1 1  2 2  1 2 Ωk,k+1 +Ωk−1,k and Ωk,k+1 +Ωk−1,k , respectively, and Here Ωk,k+1 = (Ωk,k+1, Ωk,k+1, 0) is the discrete analogue 1 2 adding the result to equation (24). of the angular velocity Ω = (Ω , Ω , 0) and Γk+1/2 = To recap, the proposed method preserves the symplectic 1 (Γ + Γ ). The discrete dynamics then reads 2 k+1 k structure, the length constraint, and the momentum, so by a result due to Ge and Marsden [9], the proposed method 1  h I Ωk,k+1 − Ωk−1,k = Tk+1/2, (20) recovers the exact trajectory, up to a possible time reparam- 1  1  eterization. h Γk+1/2 − Γk−1/2 = 2 Γk+1/2 + Γk−1/2 1  × Ωk,k+1 + Ωk−1,k , (21) 3 2 The matrix I − Ak is invertible if h is sufficiently small.

7507 VI.COMPARISONWITHOTHERMETHODS Differential-Algebraic Equation Solvers The proposed discrete Hamel integrator can be easily The proposed method takes advantage of the homogeneous scaled to an arbitrary number of copies of the sphere, space structure of S2, which has a transitive Lie group action possibly chained together in a n-spherical pendulum. Such by SO(3). In particular, the vector Γ ∈ S2 is updated by the multi-body systems however pose significant challenges for left action of a rotation matrix, given by the Cayley trans- differential-algebraic equation solvers, since they are exam- formation of a skew-symmetric matrix A that approximates k ples of what are referred to as high-index DAEs, for which the angular momentum Ω integrated over a half-timestep. the theory and numerical methods are much less developed. Interestingly, this falls out naturally from discretizing the It is possible to perform index reduction on the system of Hamel formulation of the spherical pendulum, and it would differential-algebraic equations, but this involves significant be interesting to see what general choices of coordinate effort, and the numerical results can be mixed. frames in the Hamel formulation lead to similar methods for more general flows on homogeneous spaces. We will now Numerical Comparisons discuss some alternative methods of simulating the spherical Since the method is a second-order accurate symplectic pendulum equations. method, it is natural to compare it to the Stormer–Verlet¨ method, as well as the RATTLE method (which is a gen- Homogeneous Space Variational Integrators eralization of Stormer–Verlet¨ for constrained Hamiltonian If one were to instead formulate the spherical pendulum systems). ¨ problem directly on S2, it is possible to lift the variational For the Stormer–Verlet method, we compute Hamilton’s principle on S2 to SO(3), by relating the curve Γ(t) ∈ equations for the spherical pendulum, which is given by S2 with a curve R(t) ∈ SO(3), by the relation Γ(t) = 1 x˙ = m p, (25) R(t)Γ(0) R(0) = I , where , except that the resulting varia- p˙ = −mge + mgx · e − 1 kpk2 x = f(x, p), (26) tional principle on SO(3) does not have a unique extremizer, 3 3 m due to the presence of a nontrivial isotropy subgroup. With and we apply the generalization of the Stormer–Verlet¨ a suitable choice of connection, this ambiguity can be method for general partitioned problems (see (3.4) in [11]), eliminated, and the resulting problem (and similar problems p = p + h f(x , p ), on homogeneous spaces) can be solved using Lie group n+1/2 n 2 n n+1/2 h variational integrator techniques, as described in [15]. xn+1 = xn + m pn+1/2, h pn+1 = pn+1/2 + 2 f(xn+1, pn+1/2). Nonholonomic Integrators This system of equations is linearly implicit, since the first equation is implicit in p 1 , but the rest of the equations As mentioned in Section IV, the spherical pendulum n+ 2 equations can be viewed as a Suslov problem, which is are explicit. an example of a nonholonomic mechanical system with no The RATTLE method (see (1.26) in [11]) can be applied shape space. In principle, one could apply a nonholonomic to the particle in a uniform gravitational field problem, integrator, such as the one described in [8] and [20], but x˙ = 1 p, replacing the length constraint with an infinitesimal con- m straint and a discrete nonholonomic constraint may result p˙ = −mge3, in poor numerical preservation of the constraint properties if 1 2 subject to the constraint φ(x) = 2 (kxk − 1) = 0. We also the discrete nonholonomic constraint is poorly chosen. An ∂φ T introduce Φ(x) = ∂x = x . Then, the RATTLE method alternative approach to simulating nonholonomic mechanics applied to this problem is given by, involves a discretization of the forces of constraint, and a h T  careful choice of force discretization has been shown to yield pn+1/2 = pn − 2 mge3 + Φ(xn) λn , promising results, see [16] for details. h xn+1 = xn + m pn+1/2, 0 = φ(xn+1), Constrained Symplectic Integrators h T  pn+1 = pn+1/2 − 2 mge3 + Φ(xn+1) µn , Given the relatively simple nature of the unit length 1 0 = m Φ(xn+1) · pn+1. constraint, it is quite natural to apply the RATTLE algo- rithm [1], which is a generalization of the Stormer–Verlet¨ VII. SIMULATIONS method for constrained Hamiltonian systems that is designed In Figures 1 and 2, we present simulations using our theory to explicitly preserve holonomic constraints. This method developed above, which we compare with simulations using does require the use of a nonlinear solver on a system of the generalized Stormer–Verlet¨ method and the RATTLE nonlinear equations of dimension equal to the number of method in Figures 3 and 4, respectively. constraints. The cost of the nonlinear solve can increase For simulations, we select the parameters of the system significantly as the number of copies of the sphere in the and the initial conditions to be m = 1 kg, r = 9.8 m, 1 2 1 2 configuration space increases. h = .2 s, Ω0 = .6 rad/s, Ω0 = 0 rad/s, Γ0 = .3 m, Γ0 =

7508 3 .2 m, Γ0 = −.932738 m. The trajectory of the bob of the equator. This simulation demonstrates the global nature of pendulum is shown in Figure 1a. As expected, it reveals the the algorithm, and also seems to do a good job of hinting at quasiperiodic nature of pendulum’s dynamics. Theoretically, the geometric conservation properties of the method. if one solves the nonlinear equations exactly, and in the absence of numerical roundoff error, the Hamel variational integrator should exactly preserve the length constraint, and the energy. In practice, Figure 1b demonstrates that kΓk stays to within unit length to about 10−10 after 10,000 iterations. Figure 1c demonstrates numerical energy conservation, and the energy error is to about 10−10 after 10,000 iterations as well. Indeed, one notices that the energy error tracks the length error of the simulation, which is presumably due to the relationship between the length of the pendulum and the potential energy of the pendulum. The drift in both appear to be due to accumulation of numerical roundoff error, and Fig. 2: A trajectory with initial conditions above the equator could possibly be reduced through the use of compensated integrated with the Hamel integrator. summation techniques. We also simulate the spherical pendulum using the gen- eralized Stormer–Verlet¨ method and the RATTLE method described in Section VI. The generalized Stormer–Verlet¨ method exhibits surprisingly good unit length preservation in Figure 3b of 10−11 when applied to index-reduced version of the equations of motion (25)–(26). The energy behavior

ï0.94 ï0.96 ï0.98

0.3 (a) Trajectory of the pendulum on S2 0.2 0.1 0.3 0.2 0 0.1 ï0.1 0 ï0.2 ï0.1 ï0.2 ï0.3 ï0.3 (a) Trajectory of the pendulum on S2

(b) Preservation of the length of Γ

(b) Preservation of the length of Γ

(c) Conservation of energy Fig. 1: Numerical properties of the Hamel integrator. (c) Conservation of energy Fig. 3: Numerical properties of the Stormer–Verlet¨ method. Figure 2 shows pendulum’s trajectory that crosses the

7509 in Figure 3c is typical of a symplectic integrator, with the dependent on the quality of the numerical discretization of characteristic bounded energy oscillations. Even though the the natural dynamics. RATTLE method is intended to explicitly enforce the unit IX.ACKNOWLEDGMENTS length constraint, it exhibits a unit length preservation in The authors would like to thank the reviewers for valuable Figure 4b of 10−7, which is poorer than both the Hamel comments. The research of AMB was partially supported variational integrator and the generalized Stormer–Verlet¨ by NSF grants DMS-0806765, DMS-0907949 and DMS- method. The energy error for RATTLE in Figure 4c is 1207993. The research of ML was partially supported by comparable to that of the generalized Stormer–Verlet¨ method, NSF grants DMS-1010687, CMMI-1029445, and DMS- but both pale in comparison to the energy error for the Hamel 1065972. The research of DVZ was partially supported by variational integrator. NSF grants DMS-0306017, DMS-0604108, DMS-0908995, and DMS-1211454. REFERENCES [1] H. C. Anderson, “Rattle: A velocity version of the Shake algorithm ï0.94 ï0.96 ï0.98 for molecular dynamics calculations,” vol. 52, pp. 24–34, 1983. [2] K. Ball, D. V. Zenkov, and A. M. Bloch, “Variational structures for 0.3 Hamel’s equations and stabilization”, Proceedings of the 4th IFAC 0.2 0.1 0.3 Workshop on Lagrangian and Hamiltonian Methods for Non Linear 0.2 0 0.1 Control, pp. 178–183, 2012. ï0.1 0 ï0.2 ï0.1 [3] K. Ball and D. V. Zenkov, “Hamel’s formalism for discrete nonholo- ï0.2 ï0.3 ï0.3 nomic systems,” preprint, 2012. 2 [4] A. M. Bloch, Nonholonomic Mechanics and Control, ser. Interdisci- (a) Trajectory of the pendulum on S plinary Appl. Math. New York: Springer-Verlag, 2003, vol. 24. [5] A. M. Bloch, J. E. Marsden, and D. V. Zenkov, “Quasivelocities and symmetries in nonholonomic systems,” Dynamical Systems: An International Journal, vol. 24, no. 2, pp. 187–222, 2009. [6] A. I. Bobenko and Yu. B. Suris, “Discrete Lagrangian reduction, discrete Euler–Poincare´ equations, and semidirect products,” Letters in Mathematical Physics, vol. 49, pp. 79–93, 1999. [7] ——, “Discrete time Lagrangian mechanics on Lie groups, with an application to the Lagrange top,” Communications in Mathematical Physics, vol. 204, no. 1, pp. 147–188, 1999. [8] Yu. N. Fedorov and D. V. Zenkov, “Discrete nonholonomic LL systems on Lie groups,” Nonlinearity, vol. 18, pp. 2211–2241, 2005. [9] Z. Ge and J. E. Marsden, “Lie–Poisson Hamilton–Jacobi theory and Lie–Poisson integrators,” Phys. Lett. A, vol. 133, no. 3, pp. 134–139, (b) Preservation of the length of Γ 1988. [10] G. Hamel, “Die Lagrange–Eulersche Gleichungen der Mechanik,” Z. Math. Phys., vol. 50, pp. 1–57, 1904. [11] E. Hairer, C. Lubich, and G. Wanner, Geometric Numerical Integra- tion, ser. Comp. Math. New York: Springer-Verlag, 2006, vol. 31. [12] W. R. Hamilton, “On a general method in dynamics, part I,” Phil. Trans. Roy. Soc. Lond., pp. 247–308, 1834. [13] ——, “On a general method in dynamics, part II,” Phil. Trans. Roy. Soc. Lond., pp. 95–144, 1835. [14] J. L. Lagrange, Mecanique´ Analytique. Chez la Veuve Desaint, 1788. [15] T. Lee, M. Leok, and N. McClamroch, “Lagrangian mechanics and variational integrators on two-spheres,” International Journal for Nu- merical Methods in Engineering, vol. 79, no. 9, pp. 1147–1174, 2009. (c) Conservation of energy [16] C. Lynch and D. V. Zenkov, “Stability of stationary motions of discrete-time nonholonomic systems,” in V. V. Kozlov, S. N. Vass- Fig. 4: Numerical properties of the RATTLE method. ilyev, A. V. Karapetyan, N. N. Krasovskiy, V. N. Tkhai, and F. L. Chernousko, eds., Problems of Analytical Mechanics and Stability Theory. Collection of Papers Dedicated to the Memory of Academician VIII.CONCLUSIONSANDFUTUREWORK Valentin V. Rumyantsev. Moscow: Fizmatlit, pp. 259–271, 2009. [17] J. E. Marsden, S. Pekarsky, and S. Shkoller, “Discrete Euler–Poincare´ In this paper, we constructed a variational integrator for the and Lie–Poisson equations,” Nonlinearity, vol. 12, pp. 1647–1662, spherical pendulum by discretizing Hamel’s equations. We 1999. [18] J. E. Marsden and T. S. Ratiu, Introduction to Mechanics and Symme- showed the integrator preserves key mechanical quantities try, 2nd ed., ser. Texts in Appl. Math. New York: Springer-Verlag, and illustrated the work with simulations, and comparisons 1999, vol. 17. with the generalized Stormer–Verlet¨ method and the RAT- [19] J. E. Marsden and M. West, “Discrete mechanics and variational integrators,” Acta Numerica, vol. 10, pp. 357–514, 2001. TLE method. [20] R. McLachlan and M. Perlmutter, “Integrators for nonholonomic Future work will include the simulation of linked rigid mechanical systems,” J. Nonlinear Sci., vol. 16, pp.283–328, 2006. body systems as well as the control of such systems. The [21] Ju. I. Neimark and N. A. Fufaev, Dynamics of Nonholonomic Systems, ser. Translations of Mathematical Monographs. Providence, Rhode excellent numerical properties of the proposed Hamel varia- Island: AMS, 1972, vol. 33. tional integrator will serve as an excellent basis for construct- [22] H. Poincare,´ “Sur une forme nouvelle des equations´ de la mecanique,”´ ing numerical optimal control algorithms, which are heavily CR Acad. Sci., vol. 132, pp. 369–371, 1901.

7510