  We derive the complete flexoelectric tensor, including electronic and
lattice-mediated effects, of an arbitrary insulator in terms of the microscopic
linear response of the crystal to atomic displacements. The basic ingredient,
which can be readily calculated from first principles in the framework of
density-functional perturbation theory, is the quantum-mechanical probability
current response to a long-wavelength acoustic phonon. Its second-order Taylor
expansion in the wavevector q around the Gamma (q=0) point in the Brillouin
zone naturally yields the flexoelectric tensor. At order one in q we recover
Martin's theory of piezoelectricity [R. M. Martin, Phys. Rev. B 5, 1607
(1972)], thus providing an alternative derivation thereof. To put our
derivations on firm theoretical grounds, we perform a thorough analysis of the
nonanalytic behavior of the dynamical matrix and other response functions in a
vicinity of Gamma. Based on this analysis, we find that there is an ambiguity
in the specification of the "zero macroscopic field" condition in the
flexoelectric case; such arbitrariness can be related to an analytic
band-structure term, in close analogy to the theory of deformation potentials.
As a byproduct, we derive a rigorous generalization of the Cochran-Cowley
formula [W. Cochran and R. A. Cowley, J. Phys. Chem. Solids 23, 447 (1962)] to
higher orders in q. This can be of great utility in building reliable atomistic
models of electromechanical phenomena, as well as for improving the accuracy of
the calculation of phonon dispersion curves. Finally, we discuss the physical
interpretation of the various contributions to the flexoelectric response,
either in the static or dynamic regime.
