We develop an approximation for the optical potential in a solid valid at i
ntermediate and high energies, say, energies from 50 eV and larger. The app
roximation builds on the GW expression. We separate the random phase approx
imation polarization propagator in a core electron and a valence electron p
art, and then have a corresponding separation of the optical potential. For
the valence electron optical potential we use a local density approximatio
n because the charge density changes fairly slowly, whereas we use a nonloc
al optical potential for the core electron part. We apply this method to el
ectron-Ar and -Kr elastic scattering, and also to electron scattering from
atoms in van der Waals solids, semiconductors, and metals. We find satisfac
tory agreement with the observed results. We also study the importance of u
sing a nonlocal potential for the core part and the sensitivity to a parame
ter, the average excitation energy. We compare the present results with tho
se calculated by the Hartree-Fock, Dirac-Hara, and Hedin-Lundqvist potentia
ls. The Hedin-Lundqvist potential is rather good for the description of lar
ge-angle scattering, whereas none of the local potentials can describe smal
l-angle scattering well.