Dynamics of the cantilever in noncontact atomic force microscopy