The variational procedure of the Hartree–Fock and Kohn–Sham methods can be modified by adding one or more constraints that fix the number of electrons in a given number of molecular fragments. The corresponding Euler–Lagrange equations lead to a modified Fock matrix, where the contribution from the constraints only depends on the overlap matrix, when using the Mulliken or Hirshfeld atoms-in-molecules method. For all compounds in the test set, the energy shows a quadratic dependence on the fixed charges. This behavior provides a procedure to obtain the atomic electronegativity and hardness parameters in the
electronegativity equalization method.