  Time-harmonic solutions to the wave equation can be computed in the frequency
or in the time domain. In the frequency domain, one solves a discretized
Helmholtz equation, while in the time domain, the periodic solutions to a
discretized wave equation are sought, e.g. by simulating for a long time with a
time-harmonic forcing term. Disadvantages of the time-domain method are that
the solutions are affected by temporal discretization errors and that the
spatial discretization cannot be freely chosen, since it is inherited from the
time-domain scheme. In this work we address these issues. Given an indefinite
linear system satisfying certain properties, a matrix recurrence relation is
constructed, such that in the limit the exact discrete solution is obtained. By
iterating a large, finite number of times, an approximate solution is obtained,
similarly as in a time-domain method for the Helmholtz equation. To improve the
convergence, the process is used as a preconditioner for GMRES, and the
time-harmonic forcing term is multiplied by a smooth window function. The
construction is applied to a compact-stencil finite-difference discretization
of the Helmholtz equation, for which previously no time-domain solver was
available. Advantages of the resulting solver are the relative simplicity,
small memory requirement and reasonable computation times.
