This package generates code for the Euler-Lagrange equations as well as Hamilton's equations for GeometricIntegrators.jl and related packages.


EulerLagrange.jl and all of its dependencies can be installed via the Julia REPL by typing

]add EulerLagrange


Using EulerLagrange.jl is very simple and typically consists of four to five steps:

  1. Obtain symbolic variables for a Lagrangian or Hamiltonian system of a given dimension.
  2. Obtain a symbolic representation of the parameters of the system if it has any.
  3. Build the Lagrangian or Hamiltonian using those symbolic variables and parameters.
  4. Construct a LagrangianSystem or HamiltonianSystem, which is where the actual code generation happens.
  5. Generate a LODEProblem or HODEProblem that can then be solved with GeometricIntegrators.jl.

Details for the specific system types can be found on the following pages:


If you use EulerLagrange.jl in your work, please consider citing it by

  title={EulerLagrange.jl: Code generation for Euler-Lagrange equations in Julia},
  author={Kraus, Michael},