A numerical method for the nonlinear oscillator problem