Solution (source code)

= Solution

Use the <scattering vector> $\mathbf q=\mathbf k_{\rm in}-\mathbf k_{\rm out}$; reversing its sign conjugates the following amplitudes without changing the intensities. In the <kinematic approximation>, the <atomic scattering factor> of atom $s$ is
$$
f_s(\mathbf q)=\int n_s(\mathbf u)e^{i\mathbf q\cdot\mathbf u}\,d^3u.
$$
Atoms at $\mathbf R+\mathbf d_s$ therefore give the <scattering amplitude>
$$
\boxed{A(\mathbf q)=A_e(\mathbf q)\underbrace{\sum_s f_s(\mathbf q)e^{i\mathbf q\cdot\mathbf d_s}}_{F(\mathbf q)}\underbrace{\sum_{\mathbf R}e^{i\mathbf q\cdot\mathbf R}}_{S_L(\mathbf q)}.}
$$
Here $A_e$ is the single-electron amplitude; $F$ is the <unit cell> <structure factor>, and $S_L$ is the geometrical lattice sum. If the crystal has $N_i$ repeats along $\mathbf a_i$, the latter factor is a product of <geometric series>, whose magnitudes contain
$$
\left|\frac{\sin(N_i\mathbf q\cdot\mathbf a_i/2)}{\sin(\mathbf q\cdot\mathbf a_i/2)}\right|.
$$
The sharp constructive peaks occur when every $\mathbf q\cdot\mathbf a_i=2\pi h_i$. Thus \b[a permitted reflection has wavevector change equal to a <reciprocal lattice vector>], with $F(\mathbf G)\ne0$ and the additional elastic condition $|\mathbf k_{\rm out}|=|\mathbf k_{\rm in}|$. A finite crystal broadens these peaks; it does not impose an exact delta-function selection on every scattered photon.