Abstract
A general method to derive a useful finite difference scheme for various kind of partial differential equations is proposed. The main idea is to start from discretization of the free energy of the physical system under consideration followed by a suitable discrete variation. The method can be applied to nonlinear partial differential equations in dissipative form or in conservative form and gives a difference scheme which conserves some important physical properties. Results of numerical experiments on the Cahn-Hilliard equation and on the KdV equation are shown.