  We develop a general form of the Ritz method for trial functions that do not
satisfy the essential boundary conditions. The idea is to treat the latter as
variational constraints and remove them using the Lagrange multipliers. In
multidimensional problems in addition to the trial functions boundary weight
functions also have to be selected to approximate the boundary conditions. We
prove convergence of the method and discuss its limitations and implementation
issues. In particular, we discuss the required regularity of the variational
functional, the completeness of systems of the trial functions, and conditions
for consistency of the equations for the trial solutions. The discussion is
accompanied by a detailed examination of examples, both analytic and numerical,
to illustrate the method.
