This paper provides a rigorous derivation of a counterexample of Bourgain, related to a well-known question of pointwise a.e. convergence for the solution of the linear Schrödinger equation, for initial data in a Sobolev space. This counterexample combines ideas from analysis and number theory, and the present paper demonstrates how to build such counterexamples from first principles, and then optimize them.