Functional of dynamical variables whose variation yields the equations of motion in Lagrangian mechanics