  This paper presents a direct solution technique for the scattering of
time-harmonic waves from a bounded region of the plane in which the wavenumber
varies smoothly in space.The method constructs the interior
Dirichlet-to-Neumann (DtN) map for the bounded region via bottom-up recursive
merges of (discretization of) certain boundary operators on a quadtree of
boxes.These operators take the form of impedance-to-impedance (ItI) maps. Since
ItI maps are unitary, this formulation is inherently numerically stable, and is
immune to problems of artificial internal resonances. The ItI maps on the
smallest (leaf) boxes are built by spectral collocation on tensor-product grids
of Chebyshev nodes. At the top level the DtN map is recovered from the ItI map
and coupled to a boundary integral formulation of the free space exterior
problem, to give a provably second kind equation.Numerical results indicate
that the scheme can solve challenging problems 70 wavelengths on a side to
9-digit accuracy with 4 million unknowns, in under 5 minutes on a desktop
workstation. Each additional solve corresponding to a different incident wave
(right-hand side) then requires only 0.04 seconds.
