Stability of the Rayleigh-Ritz procedure for nonlinear two-point boundary value problems