Solution (source code)

= Solution

For a <photon>, the <photon energy> formula and the vacuum relation $\nu=c/\lambda$ give $E_\gamma=hc/\lambda$. For an <Electron>, the <de Broglie wavelength> gives the same <momentum> magnitude $p=h/\lambda$, but the nonrelativistic <kinetic energy> is $K_e=p^2/(2m_e)$. Using $h=6.62607015\times10^{-34}\,\mathrm{J\,s}$, $m_e=9.10938\times10^{-31}\,\mathrm{kg}$ and $1\,\mathrm{eV}=1.602176634\times10^{-19}\,\mathrm J$,
$$
E_\gamma=\frac{(6.62607015\times10^{-34})(2.99792458\times10^8)}{4.0\times10^{-9}}
=4.96611\times10^{-17}\,\mathrm J,
$$
$$
K_e=\frac{(6.62607015\times10^{-34})^2}{2(9.10938\times10^{-31})(4.0\times10^{-9})^2}
=1.50617\times10^{-20}\,\mathrm J.
$$
Thus, to the precision of the <wavelength>,
$$
\boxed{E_\gamma=3.1\times10^2\,\mathrm{eV},\qquad K_e=9.4\times10^{-2}\,\mathrm{eV}.}
$$
The electron answer is its <kinetic energy>, as required for the diffraction experiment; its <relativistic energy> would additionally include the approximately $511\,\mathrm{keV}$ <rest energy>. Since $K_e\ll m_ec^2$, the nonrelativistic approximation is well justified. Equal <wavelengths> imply equal <momenta>, not equal energies for particles with different <energy–momentum relations>.