In this notebook, we re-analyze the inverted spherical pendulum in new terms: as a gauge theory in
SO(3)
, the Lie group of rotations in 3 dimensions. We first reproduce the equations of motion in pitch/cone-roll coordinates, known from earlier notebooks, from connections in the covariant derivative, computed automatically from a kinetic-energy metric. This metric measures distances between configuration velocities in the 2D quotient group
SO(3)/SO(2)
. Adding a third angle ψ, spinning the pendulum on its long axis, extends the group via fibration to
SO(3)
. Physically, it adds gyroscopic forces to the pendulum, making it easier to stabilize than by, say, control forces applied at the base. We offer an interactive visualization that lets a user smoothly vary the system from a free pendulum that falls, to a gyroscope that precesses and nutates. The visualization also reveals coordinate singularities, which we eliminate in an upcoming notebook that addresses the problem in another gauge,
SU(2)
, the unitary group of rotation operators, the exact same group used in quantum theory of the Standard Model.

Plan for this Notebook

◼
  • Recap the established Lagrangian formulation and visualization of the inverted spherical pendulum (ISP) in pitch/cone-roll coordinates.
  • ◼
  • Reformulate in geometric terms, with kinetic energy as the metric tensor, and potential energy as a scalar gradient field.
  • ◼
  • Do this twice to make a software-engineering point: once in the toolkit’s newer “indexer sector,” and again in the older “ sector” via an existing gradient operator.
  • ◼
  • Show that the equations of motion are identical however derived.
  • ◼
  • Exhibit breakdown of the numerical solution at a singular point of the coordinates, setting the stage for upcoming resolution in the
    SU(2)
    gauge.
  • ◼
  • Add the third angle—twist around the baton axis—adding gyroscopic effects to the physics. Visualize the results as before.
  • Initialize the Relativity Toolkit

    Optional: Quit for a Fresh Kernel

    ◼
  • Note: if you call Quit in a notebook, evaluation may hang. If you want to “Evaluate Notebook,” mark the following two cells “Evaluatable” in the Cell
    ->
    Property menu, call Quit and FrontEndTokenExecute once each, then comment out the cells, or mark them unevaluatable again. Alternatively, you can quit the kernel via the Evaluation menu (last item). At that point, you can “Evaluate Notebook” in a clean environment, or evaluate cells individually.
  • Quit[];
    In[]:=
    FrontEndTokenExecute["DeleteGeneratedCells"]

    Download the Code

    In[]:=
    getToolkit[branch_]:=​​With[​​{base="https://raw.githubusercontent.com/rebcabin/RelativityToolkit/"<>branch<>"/",​​bust="?t="<>ToString[Round[AbsoluteTime[]]]},​​{rules=base<>"RelativityToolkit.wl"<>bust},​​Get[rules]];​​getToolkit["v1.13.0"];
    »
    Relativity Toolkit version :1.13.0
    »
    Relativity Connection Symbol :Γ

    Original Problem, Visualization, and Solution

    This section is a recap of the standard Euler-Lagrange process, which was fully developed in Perspectives on energy conservation: discrete variational spherical pendulum, April 2025. There are three sub-sections here, copy-pasted and lightly edited from that notebook:
    ◼
  • Save and print equations of motion for later comparison with the new geometric process.
  • ◼
  • Visualize the 2D,
    {δ,η }
    ,
    SO(3)/SO(2)
    coordinate system, common to both the old Euler-Lagrange process and to the new geometric derivation.
  • ◼
  • Visualize solutions of the equations, pertinent to both derivation processes.
  • Equations of Motion via Euler-Lagrange

    Here are the old Euler-Lagrange definitions without the explanations that appear in the old notebook. All we really need from this is the Echo of the Euler-Lagrange equations at the end and the setups for the visualizations to follow.
    In[]:=
    ClearAll[e1,e2,e3,o,g,plotRg];​​e1={1,0,0};e2={0,1,0};e3={0,0,1};​​o={0,0,0};g=9.81;plotRg={-1.25,1.25};​​​​ClearAll[cm];​​(cm[{δ_,η_}]:=RotationMatrix[η,e1].RotationMatrix[δ,e2].{0,0,Subscript[c,z]});​​​​ClearAll[zh];​​zh[{δ_,η_}]:=cm[{δ,η}][[3]];​​​​ClearAll[numRules];​​numRules={δ[t]->δ,η[t]->η,δ'[t]->Dδ,η'[t]->Dη,m->1,Subscript[c,z]->1.2};​​​​ClearAll[Vnum,V];​​V[{δ_,η_}]:=mgzh[{δ,η}];​​Vnum[{δ_,η_}]=((V[{δ,η}])/.numRules);​​​​ClearAll[v];​​(v[{δ_,η_}]:=D[cm[{δ,η}],t]);​​​​ClearAll[Tnum,T];​​(T[{δ_,η_}]:=1/2mv[{δ,η}].v[{δ,η}]);​​Tnum[{δ_,η_},{Dδ_,Dη_}]:=1/2(1.2)^2(Dδ^2+(1/2(1+Cos[2δ]))Dη^2);​​Tnum[{δ_,η_},{Dδ_,Dη_}]=(T[{δ[t],η[t]}]/.numRules//FullSimplify);​​​​ClearAll[Lnum,L];​​(L[{δ_,η_}]:=T[{δ,η}]-V[{δ,η}]);​​​​ClearAll[Leqns];​​With[{Lcrds={δ[t],η[t]}},​​With[{Lvels=D[Lcrds,t]},​​With[{Lncnf={0,0}},(*non-conservativeforces*)​​Leqns=Flatten@MapThread[​​{q,v,f}|->D[D[L[Lcrds],v],t]-D[L[Lcrds],q]==f,​​{Lcrds,Lvels,Lncnf}]]]];​​​​ClearAll[stEqns];​​(stEqns=Equal@@@(Solve[Leqns,{δ''[t],η''[t]}]//FullSimplify//Chop//Part[#,1]&));​​Echo[stEqns//TableForm,"State-space equations (stEqns) :"];​​​​ClearAll[tLim,initialConditions,stSolns];​​tLim=200;
    »
    State-space equations (stEqns) :
    ′′
    δ
    [t]Sin[δ[t]]
    9.81Cos[η[t]]
    c
    z
    -1.Cos[δ[t]]
    2
    ′
    η
    [t]
    ′′
    η
    [t]
    9.81Sec[δ[t]]Sin[η[t]]
    c
    z
    +2.Tan[δ[t]]
    ′
    δ
    [t]
    ′
    η
    [t]
    ◼
  • The second,
    η''
    , equation has Sec[δ[t]], which equals ComplexInfinity when
    δ=(π/2)=90°
    . That’s the source of divergence we’ll see below in the solutions.
  • Visualization 1: The Coordinate System

    The standard spherical coordinates are singular at the North and South poles, at the two equilibrium positions of the ISP—hanging straight down or balanced straight up. In neither of these positions is azimuth mathematically defined. These coordinates are problematic for computation.
    ◼
  • I witnessed an accident wherein the control software for a radio telescope failed to account for the singularity, wrapped cables around the azimuthal axis mount, and stretched them to breaking. No one was hurt.
  • Turn the spherical coordinate system 90° from vertical about the Y axis so that the poles are on the geophysical Equator. By so moving the poles, the equilibrium positions are no longer singular. We haven’t removed the singularity, merely moved it from the equilibrium positions, hiding it for the common equilibrium cases (specifically for our earlier control applications).
    Moving the singularity does not remove it, however. Topologically, no smooth, 2D coordinate grid can cover a sphere without a singularity. When the baton falls across the equator at
    δ=(π/2)=90°
    , the η degree of freedom becomes undefined and the math breaks as Sec[δ[t]], in the
    η''
    equation, goes to ComplexInfinity. This topological singularity is inevitable in any global coordinate system on
    SO(3)
    (See references to Do Carmo, Marsden et al., Baez and Muniain, and Burke).
    Measure the angular position of the baton with two angles:
    ◼
  • δ, measuring co-latitude from North. Call it pitch.
  • ◼
  • η
    , measuring angle counterclockwise around the original X axis. Call it cone-roll.
  • Both angles can endure adding or subtracting any multiple of 360°.
    This global coordinate system will be as good as any in
    SO(3)
    or
    SO(3)/SO(2)
    for numerical integration.
    ◼
  • One way out of the singularity trap is multiple coordinate systems with transition functions in overlap areas. That’s a good solution, but much more complicated than going to
    SU(2)
    , which double-covers the sphere with no singularity. When we go to
    SU(2)
    in an upcoming notebook, there will be no poles to worry about.
  • ClearAll[rig];​​With[{l=1.2,mass=1.0,d=2.4,r=0.02},​​{baton=Cylinder[{{0,0,-l},{0,0,+l}},r],​​batonCenterBodyFrame={0,0,l}},​​rig["graphics primitives"]=baton;​​rig["moment of inertia"]=​​With[{Ib=mass*(MomentOfInertia[baton]/Volume[baton])},​​{Ibi=Inverse@Ib},​​{Ib,Ibi}];​​rig["cb"]:=batonCenterBodyFrame;​​rig["half length"]:=l;​​rig["mass"]:=mass;];​​ClearAll[jack];​​jack[0,opacity_:0.1,diameter_:0.01]:={​​Opacity[opacity],​​{Red,Arrow[Tube[{o,e1}],diameter]},​​{Darker[Green],Arrow[Tube[{o,e2}],diameter]},​​{Lighter[Blue],Arrow[Tube[{o,e3}],diameter]},​​{Lighter[Cyan],Arrow[Tube[{o,-e1}],diameter]},​​{Magenta,Arrow[Tube[{o,-e2}],diameter]},​​{Yellow,Arrow[Tube[{o,-e3}],diameter]}};​​With{epsilon=0.0001,h=1/15.,w=1/4.,vu=3.,o={0,0,0},​​thin={0,0,.0001},​​cb=rig["cb"]},​​{kart=Cuboid[{-w,-w,epsilon},{w,w,epsilon+h}],s=2,​​floor=Polygon[{{-vu,-vu,0},{vu,-vu,0},{vu,vu,0},{-vu,vu,0}}]},​​{c3=Cylinder[{o,thin},scb[[3]]],​​b3=Sphere[o,scb[[3]]],t3x=Tube[{-scb[[3]]e2,scb[[3]]e2},.01],axisLabelStyle=text|->Style[text,Red,Bold,18,FontFamily->"Courier New"]},​​Manipulate​​DynamicModule​​{renderPos=o,Στs=o,cs,rotfn},​​cs=RotationMatrix[η,e1].RotationMatrix[δ,e2].cb;​​renderPos=-cs[[1]]e1-cs[[2]]e2;​​rotfn=RotationTransform[η,e1]@*RotationTransform[δ,e2];​​ShowGraphics3D{GeometricTransformation[jack[0],rotfn],​​{Black,t3x},​​{White,Opacity[.7/8],c3,b3,​​GeometricTransformation[c3,RotationTransform[δ,e2]]},​​{Red,Sphere[scs,1/16.]},​​{Yellow,Opacity[.3/4],floor},​​{Green,Opacity[.6],Translate[kart,renderPos]},{White,Opacity[.75],​​Translate[​​Translate[GeometricTransformation[rig["graphics primitives"],rotfn],cs],​​renderPos+(epsilon+h)e3]}},​​
    ,​​ParametricPlot3D[sRotationMatrix[ha,e1].RotationMatrix[δ,e2].cb,{ha,0,2π}],​​{{δ,10°},-360°,360°,1°,Appearance->{"Open"}},​​{{η,0°},-360°,360°,1°,Appearance->{"Open"}},SaveDefinitions->True

    Visualization 2: Solving the Equations of Motion

    ◼
  • In another notebook, How to Land a Rocket, I show how to balance the baton via control theory at the unstable equilibrium, standing straight up.
  • Geometric Equations of Motion

    Geodesic Equations

    While standard Lagrangian mechanics produces equations of motion from scalar energy functionals, we can alternatively derive the equations of motion directly as geodesic equations in the geometry of the configuration space. One immediate benefit is that the geodesic equations yield directly intuitive terms:

    Absolute Derivative

    By the chain rule
    we get concise equations of motion

    Inertial Forces from the Connection

    By projecting (contracting) the covariant-derivative-of-the-velocity on the velocity, we get the coordinate accelerations—we might have expected that—plus all the inertial forces from the connection Γ. Here is the interpretation of the inertial forces.

    All Forces from Connections

    We have repeatedly claimed in various notebooks that ALL forces come from connections. What about those “forces from potentials” on the right-hand side of the new equations of motion? It turns out that they are the time-time components of 4D connections. We’ll leave that analysis for another notebook, and just take them on the right-hand side for now. That keeps the analysis smaller so we can explain it intuitively.

    Geometric Equations of Motion

    Let’s re-derive the equations of motion geometrically, then show them equal to our old equations of motion, derived via the Euler-Lagrange process. We’ll repeat the new derivation twice using two different sectors of the  toolkit: first, the newer, component-based “indexer” sector and then the older, rule-based “” sector. These sectors can be freely mixed and matched. The indexer sector has the advantage of conciseness, but at the cost of explicit index up-ness and down-ness. The indexer sector is analogous to a weakly typed sub-language. The  sector requires more code, but keeps track of the variance and valence. The  sector is analogous to a strongly typed sub-language.
    Start with the same old kinetic and potential energies, geometrically, this time:

    Kinetic Energy

    is the code. In traditional notation, it is

    Metric Tensor times Velocities

    QED■

    We’ll need the connection, Γ, computed from the metric and its inverse.
    ◼
  • Note the presence of Sec[δ[t]] in the 〚2,2〛 element of the metric. The metric diverges when δ[t]90°.
  • New function for the toolkit v1.13.0.
    This function internally produces a time injector rather than relying on an external definition. Its output is the full contravariant vector (up index) of inertial forces.
    New function for the toolkit v1.13.0.
    Adds an explicit coordinate acceleration term to the inertial forces and produces the entire vector.

    Potential Scalar Field

    New function for the toolkit v1.13.0.
    Gravitational force is the negative gradient of the potential.

    Equations of Motion

    New Equations

    Everything is in component-indexed form.

    Old Equations

    Old == New

    QED■

    In the  Sector

    In the above computations in the indexer sector, there is one nagging programming nit. We computed the gradient of the potential through an explicit contraction in PotentialScalarField, rather than via ’s gradient operator, GradRaised. To put GradRaised to work, we must redo the entire computation in the  sector, where GradRaised was developed. We’ll find the code more verbose, but producing the same result.
    Recall how to convert a matrix into  rules:
    This is a sparse-matrix representation, alternative but equivalent to the full matrices above.

    Absolute DerivativeUD

    Recall how to compute Γ components in the  sector: via rules

    CurvatureForcesUD

    New functions for the toolkit v1.13.0.

    PotentialScalarFieldUD

    New function for the toolkit v1.13.0.
    Here’s were we use GradRaised.

    The Final Test

    QED■

    What is ψ? The only thing it could be: twist around the long axis of the baton, changing the baton from a pendulum that falls over into a spinning, cylindrically symmetric top that gyroscopically resists falling over.
    Gyroscopic forces are again inertial, arising from a new metric and connection, but we get them with no further manual effort. Just turn the crank and get a spinning symmetrical top.

    Kinetic Energy

    The η-ψ cross-terms in the kinetic energy arise from projecting η-rotation against the ψ axis. As the baton starts to fall, its spinning inertia about the ψ axis flings it back up, decreasing η and causing precession and nutation.
    To consider the extremes:
    The projection of the η-rotation against the ψ axis generates the gyroscopic forces, and we’ll see a term corresponding to that projection in the connection.

    Gauge Potential and Gauge Connection

    Topology

    As the baton moves around the sphere, the spin fibers suffer a global topological twist. Gyroscopic precession and nutation are the physical manifestation of the baton’s navigating this twisted space.
    Now, just mimic the indexer-sector development above. Precession and nutation arise spontaneously.
    For inspection; not used in the sequel.

    Connection and Equations of Motion

    QED■

    Plot the Solutions

    The following plots are fascinating if not illuminating. They serve mostly as a plausibility check.

    Things to Try

    Notes on the Term “Gauge”

    The term “gauge” is used in physics in at least five different ways:
    1
    .
    Gauge Choice
    ◼
  • in this notebook, the specific choice to place the poles of the coordinate system on the Equator
  • 2
    .
    Gauge Transformation
    3
    .
    Gauge Potential, Gauge Connection
    the geometric field that absorbs inhomogeneous terms generated from partial derivatives across changing reference frames.
    4
    .
    Gauge Covariant Derivative
    5
    .
    Gauge Group

    Conclusion

    In this notebook, we demonstrate that the classical mechanics of rigid bodies can be well understood as a geometric gauge theory. By defining a kinetic-energy metric for the configuration space of a spinning baton, the  calculus automatically generates the covariant derivatives and connections necessary to produce the correct equations of motion. Bypassing the traditional scalar energy functionals of Lagrangian mechanics, we reveal that inertial forces, such as centrifugal and Coriolis, are simply the geometric consequence of moving through a curved coordinate space.

    References

    1
    .
    Beckman, Brian. From the steam age to quantum fields: a unified approach via UD tensorial calculus. Wolfram Community post.
    2
    .
    Beckman, Brian. General relativity in the UD calculus. Wolfram Community post.
    3
    .
    Beckman, Brian. Formal Differential Geometry in the UD Calculus: Part 1. Wolfram Community post.
    4
    .
    Beckman, Brian. Covariant Derivatives and Connections in the  Calculus. Wolfram Community post.
    5
    .
    Beckman, Brian. Riemann Curvature in  + Compiler POC. Wolfram Community post.
    6
    .
    Beckman, Brian. Schwarzschild Orbits in the  Calculus. Wolfram Community post.
    7
    .
    Beckman, Brian. Schwarzschild Metric from Scratch via  Compilation. Wolfram Community post.
    8
    .
    Beckman, Brian. Gauge Theory in . Wolfram Community post.
    9
    .
    Manfredo P. do Carmo, Differential Geometry of Curves and Surfaces, Revised and Updated Second Edition,
    10
    .
    John Baez, Javier P. Muniain, Gauge Fields, Knots and Gravity, Part II, “Gauge Fields” and the sections on Fiber Bundles.
    11
    .
    Jerrold E. Marsden, Tudor Ratiu, with Ralph Abraham. Manifolds, Tensor Analysis, and Applications, Third Edition (link unavailable).
    Theorem 8.5.12 (Hairy Ball Theorem). Every vector field on an even-dimensional sphere has a critical point.
    12
    .
    William L. Burke, Applied Differential Geometry.

    CITE THIS NOTEBOOK