  Outer crusts of neutron stars and interiors of cool white dwarfs consist of
bare atomic nuclei, arranged in a crystal lattice and immersed in a Fermi gas
of degenerate electrons. We study electrostatic properties of such Coulomb
crystals, taking into account the polarizability of the electron gas and
considering different lattice structures, which can form the ground state. To
take the electron background polarization into account, we use the linear
response theory with the electron dielectric function given either by the
Thomas-Fermi approximation or by the random-phase approximation (RPA). We
compare the widely used nonrelativistic (Lindhard) version of the RPA
approximation with the more general, relativistic (Jancovici) version. The
results of the different approximations are compared to assess the importance
of going beyond the Thomas-Fermi or Lindhard approximations. We also include
contribution of zero-point vibrations of ions into the ground-state energy. We
show that the bcc lattice forms the ground state for any charge number $Z$ of
the atomic nuclei at the densities where the electrons are relativistic
($\rho\gtrsim10^6$ g cm$^{-3}$), while at lower densities the fcc and hcp
lattices can form the ground state. The MgB$_2$-like lattice never forms the
ground state at realistic densities in the crystallized regions of degenerate
stars. The RPA corrections strongly affect the boundaries between the phases.
As a result, transitions between different ground-state structures depend on
$Z$ in a nontrivial way. The relativistic and quantum corrections produce less
dramatic effects, moderately shifting the phase boundaries.
