Prestack depth migration provides a powerful tool for doing velocity analysis in complex media. Both prominent approaches to velocity analysis-depth-focusing analysis and residual-curvature analysis, rely on approximate formulas in order to estimate velocity errors. Generally, these formulas are derived under the assumptions of horizontal reflector, lateral velocity homogeneity, or small offset. Therefore, the conventional methods for updating velocity lack sufficient computational efficiency when velocity has large, lateral variations.Here, using a perturbation method, we derive an analytic relationship between residual moveout and residual velocity. In our derivation, we impose no limitation on offset, dip, or velocity distribution. Based on this formula, we revise the residual-curvature-analysis method for velocity estimation that involves recursion and iteration. Furthermore, this formula provides the P-nsitivity and error estimation for migration-based velocity analysis, which is helpful in explaining the reliability of the estimated velocity.