The classical Rayleigh-Ritz procedure is applied to the variational formulation of the one-dimensional diffusion equation. By minimizing the corresponding functional over finite dimensional piecewise cubic and quintic spaces, generalizations of the classical finite difference schemes are derived in the domain of continuous variables. Error estimates in the continuous norm are established which compare very favorably with corresponding ones in the discrete norm.