Clever.
You probably won't get a simple answer here (although someone might know the answer/solution (and if I had a couple of hours research, I might even have taken a stab at this))
Take a look at the "Hamilton Formulation" - there's loads of good stuff online.
Understanding advanced physics or applied maths will help.