It is now well-accepted that the modeling and analysis of system must include a study of the stability of the solution under perturbations of the parameters of the problems. In fact, a given problem should not be viewed as a single entity, but in the context of a family of problems that are possible variants of the original one. Of particular interest, are those stability questions that involve both decision variables and dual variables (prices in economics), or state and co-state variables in dynamics. This leads to the study of Lagrangian and Hamiltonian functions, and their relationship to perturbations of the original problem. This is formulated in this paper in terms of the continuity properties of the Legendre-Fenchel transform.