Scanning probe microscopy is often extended beyond simple topographic imaging to study electrical forces and sample properties, with the most widely used experiment being frequency-modulated Kelvin probe force microscopy. The equations commonly used to interpret this frequency-modulated experiment, however, rely on two hidden assumptions. The first assumption is that the tip charge oscillates in phase with the cantilever motion to keep the tip voltage constant. The second assumption is that any changes in the tip-sample interaction happen slowly. Starting from an electro-mechanical model of the cantilever-sample interaction, we use Lagrangian mechanics to derive coupled equations of motion for the cantilever position and charge. We solve these equations analytically using perturbation theory, and, for verification, numerically. This general approach rigorously describes scanned probe experiments even in the case when the usual assumptions of fast tip charging and slowly changing samples properties are violated. We develop a Magnus-expansion approximation to illustrate how abrupt changes in the tip-sample interaction cause abrupt changes in the cantilever amplitude and phase. We show that feedback-free time-resolved electric force microscopy cannot uniquely determine sub-cycle photocapacitance dynamics. We then use first-order perturbation theory to relate cantilever frequency shift and dissipation to the sample impedance even when the tip charge oscillates out of phase with the cantilever motion. Analogous to the treatment of impedance spectroscopy in electrochemistry, we apply this approximation to determine the cantilever frequency shift and dissipation for an arbitrary sample impedance in both local dielectric spectroscopy and broadband local dielectric spectroscopy experiments. The general approaches we develop provide a path forward for rigorously modeling the coupled motion of the cantilever position and charge in the wide range of electrical scanned probe microscopy experiments where the hidden assumptions of the conventional equations are violated or inapplicable. arXiv:1807.01219v2 [cond-mat.mes-hall]