Averaging for Ordinary Dierential Equations and Functional Dierential Equations