It is the purpose of this paper to consider a more general application of the variational method to the particle-in-the-box problem with polynomial trial functions.
We generalize a recently developed perturbation approach [F. M. Fern\'andez and E. A. Castro, Phys. Rev. A 46, 7288 (1992)], extending its applicability to a wider variety of separable quantum-mechanical problems. As an illustrative example, we consider a particle in a one-dimensional box with a finite potential wall perturbed by a linear potential and obtain the perturbation corrections to the wave function and energy of an arbitrary state in terms of the corresponding unperturbed quantities.