rigid_body_ode, a MATLAB code which sets up and solves the ordinary differential equations (ODE) representing the Euler equations for a rotating rigid body, with three unequal moments of inertia, originally proposed by Fred Krogh.

A rectangular object can rotate stably about its longest or shortest axis, but not the intermediate one. We let x(t), y(t), and z(t) be the angular momenta, and I1, I2, I3 the moments of inertia about the three principal axes.

The ODE can be written:

        x' = a y z
        y' = b x z
        z' = c x y
        a = 1/I3 - 1/I2
        b = 1/I1 - 1/I3
        c = 1/I2 - 1/I1

Example choices include (I1,I2,I3) = (1,1/2,1/3) and (I1,I2,I3) = (1/6,1,2/3).


The computer code and data files described and made available on this web page are distributed under the MIT license


rigid_body_ode is available in a MATLAB version and an Octave version and a Python version.

Related Data and codes:


matlab_ode, MATLAB codes which set up various ordinary differential equations (ODE).


  1. Ernst Hairer,
    Solving differential equations on manifolds,
    Universite de Geneve,
    June 2011.
  2. Ernst Hairer, Christian Lubich, Gerhard Wanner,
    Geometric numerical integration,
    Springer, 2006.
  3. Cleve Moler,
    Tumbling Box ODE,
  4. Lawrence Shampine, Marilyn Gordon,
    Computer Solution of Ordinary Differential Equations: The Initial Value Problem,
    Freeman, 1975,
    ISBN: 0716704617,
    LC: QA372.S416.
  5. Gilbert Strang,
    Differential equations and linear algebra,
    Wellesley-Cambridge Press, 2015, ISBN13: 9780980232790.

Source Code:

Last revised on 30 April 2021.