NOC:Variational Calculus and its applications in Control Theory and Nanomechanics