## Introduction

Programmable and precise control over individual quantum particles, such as laser-cooled trapped ions and neutral atoms, fundamentally enhances our capability to manipulate, probe, and create non-trivial quantum states. In particular, programming internal spin or qubit states of individual trapped ions1,2, spaced a few microns from each other in a linear Coulomb crystal, constitute a powerful platform for quantum information processing (QIP). Individual optical addressing of ions has recently enabled a plethora of challenging experiments, such as creating quantum gates between arbitrary pairs of ion qubits3,4,5,6,7 and engineering non-trivial quantum Hamiltonians for the simulation of strongly correlated many-body phenomena8,9. However, existing technical approaches suffer from scaling and other fundamental challenges, such as lacking independent control4,7,8,9,10,11,12 between the frequency and spatial position of the light, lacking simultaneous illumination capability on arbitrary sets of ions at the diffraction limit13,14, or requiring uniformly spaced ions3,5,6 not readily available in most ion traps15. Crucially, the stringent requirement of low crosstalk between the target ion and its neighbors in QIP experiments, especially for quantum error correction16, necessitates careful engineering and alignment of optical components to minimize aberrations. This problem is compounded by the need to use ultraviolet (UV) radiation for most ion species suitable for QIP1,17. Because, shorter wavelengths accumulate more aberrations for the same optical path mismatch from manufacturing imperfection, optics misalignment, and the use of spherical surfaces. Further, some of the commercial solutions6,18 are expensive and available only for a narrow range of wavelengths.

In this work, we demonstrate a scalable, arbitrary, reprogrammable, and precise individual-ion addressing scheme with in situ aberration-compensation. We adopt a Fourier-holographic19,20 optical addressing approach by employing a programmable amplitude hologram implemented with a commercially available Digital Micromirror Device (DMD). The hologram creates optical field profiles capable of simultaneously addressing arbitrary sets of ions, without changing the frequency of light. We validate high-quality, aberration-compensated optical engineering at λ ≈ 369.5 nm, by observing the fluorescence from the 2S1/22P1/2 transition of an Ytterbium ion (174Yb+) in a Paul trap21. This technique can readily be applied to most ion species, as commercial DMDs capable of handling several Watts of optical power are available for a wide wavelength range of 355 nm–2.5 μm. We use the ion for in situ characterization of aberrations, which are then compensated for with high precision (to λ/20 RMS) by feeding back onto the DMD hologram. An adaptation of the iterative Fourier transformation (IFTA) algorithm22 in generating the DMD holograms allows us to reach intensity crosstalk errors in 10−4–10−5 level for realistic inter-ion separation. This crosstalk error is comparable13 or about an order of magnitude lower6,23 than state-of-the-art trapped-ion QIP experiments, when compared at the same ratio of ion spacing to Gaussian spot size, and approaches error correction thresholds16,24. Significantly, our beam profile data indicate that the low error can be maintained while addressing arbitrary pairs in a chain of over a hundred ions with typical unequal spacings15. These results point to the inherent scalability of our approach compared to other existing technologies. The holographic addressing also allows for precise programming of the optical phase as well as the intensity of light, for applications such as phase-sensitive quantum gates25,26. Faster switching speed of MEMS-mirror technology used in DMD, compared to other hologram technology27, enables exploration of digital28 and digital-analog hybrid simulation29 protocols.

## Results

### Experimental setup

The 369.5 nm light illuminates a circular aperture on the DMD (Texas Instruments DLP9500UV) placed in the Fourier plane (FP) of a focusing lens L2 (f = 200mm), as shown in Fig. 1. The micromirror pitch is d = 10.8 μm and each micromirror can be toggled between two angles, behaving like a local binary light-switch. A binary amplitude grating (with periodicity a = 4d = 43.2 μm) is employed to modulate both the phase and amplitude of the electric field of light, EFP in the DMD plane (FP), such that the target electric field profile in the image plane EIP (with IP referring to either IP1 or IP2, shown in Fig. 1) can be generated with high accuracy. Thus, we operate the DMD as a programmable Fourier hologram. A pinhole placed in the image plane (IP1) of L2 allows us to choose a specific diffraction order (m = −1 here) of the DMD binary grating to propagate to the 174Yb+ ion, after a five times demagnification from IP1 to IP2. The ion is trapped in a Paul trap, with an axial (along y) and radial trapping frequencies of approximately 2π × 180 kHz and 2π × 400 kHz, respectively. We can model the total aberrations from the light source to IP by introducing an aberration phase map $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{IP}})}({\bf{x}})$$ in FP, such that the optical Fourier transformation between the field EFP at FP and EIP at IP of a paraxial lens system of effective focal length f is modified (see Supplementary Information) to

$${E}_{{\rm{FP}}}({\bf{x}}){{\rm{e}}}^{{\rm{i}}{{{\Phi }}}_{{\rm{ab}}}^{({\rm{IP}})}({\bf{x}})}={\left.\frac{\lambda f}{2\pi }{\mathcal{F}}\left[{E}_{{\rm{IP}}}({\bf{x}}^{\prime} )\right]({\bf{k}}^{\prime} )\right|}_{{\bf{k}}^{\prime} = \frac{2\pi }{\lambda f}{\bf{x}}}.$$
(1)

Here, $${\bf{x}}^{\prime}$$ and $${\bf{k}}^{\prime}$$ denote the spatial coordinate and the wave vector at IP respectively, and $${\mathcal{F}}$$ denotes Fourier transformation. The wave vector $${\bf{k}}^{\prime}$$ is related to the spatial coordinate x at FP by $${\bf{x}}=\frac{\lambda f}{2\pi }{\bf{k}}^{\prime}$$. The DMD hologram can then be programmed to imprint a spatial phase $$(-{{{\Phi }}}_{{\rm{ab}}}^{({\rm{IP}})}({\bf{x}}))$$ on the light to nullify the aberrations.

### Aberration characterization

To realize diffraction-limited performance at an image plane, we first characterize the aberration phase map $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{IP}})}({\bf{x}})$$, following a similar approach as in Zupancic et al.19, schematically shown in Figs 2 and 3. We let the light from two FP patches (Figs 2a and 3a), centered at x = 0 (center of the FP aperture) and x = Δ, consisting of a small number of DMD micromirrors, interfere in the image plane IP. The interference fringes are measured on the camera C1 for IP1 (Fig. 2b) or with the ion fluorescence for IP2 (Fig. 3b) for extracting the aberration phase $$({{{\Phi }}}_{{\rm{ab}}}^{({\rm{IP}})}({\boldsymbol{\Delta }})-{{{\Phi }}}_{{\rm{ab}}}^{({\rm{IP}})}({\bf{0}}))$$ (see “Phase profile extraction in the intermediate image plane IP1” section). With the central patch as a reference, we vary Δ to scan the FP aperture on a grid in steps of dg to reconstruct the aberration phase map, after unwrapping the phases30 and interpolating between the grid lines. The FP patch sizes are chosen so as to get a good signal-to-noise ratio, while making sure that the optical phase does not vary appreciably (2π) within a patch. We choose the patch size empirically, such that the standard error in the ion fluorescence signal is approximately ten times smaller than the fringe contrast (Fig. 3b). This leads to about λ/50 uncertainty in phase estimation.

We characterize the total aberrations in terms of three phase maps: $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{0}})}({\bf{x}})$$, $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{1}})}({\bf{x}})$$, and $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{2}})}({\bf{x}})$$, such that $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{IP1}})}({\bf{x}})={{{\Phi }}}_{{\rm{ab}}}^{({\rm{0}})}({\bf{x}})+{{{\Phi }}}_{{\rm{ab}}}^{({\rm{1}})}({\bf{x}})$$ and $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{IP2}})}({\bf{x}})={{{\Phi }}}_{{\rm{ab}}}^{({\rm{0}})}({\bf{x}})+{{{\Phi }}}_{{\rm{ab}}}^{({\rm{2}})}({\bf{x}})$$.

The measured phase maps are shown in Figs 2c and 3c, respectively, and the measured residual aberration phase maps after aberration correction are shown in Figs 2d and 3d.

The phase map $${{{\Phi }}}_{{\rm{ab}}}^{(0)}({\bf{x}})$$ characterizes a majority of the total aberrations from the source up to IP1 with high precision. For this, we turn on all the micromirrors within the two patches (4 × 4 micromirrors each), as shown in Fig. 2a (top), and choose a grid size dg = 20d. We measure about 6.5λ (13π) peak–peak and 1.13(2)λ RMS phase aberrations (Fig. 2c, top), dominated by astigmatism (Zernike coefficient $${Z}_{2}^{-2}$$), as seen in Fig. 2e. In this manuscript, all phase aberration-specifications are reported after removing the “piston” ($${Z}_{0}^{0}$$) and “tilt” terms ($${Z}_{1}^{-1}$$ and $${Z}_{1}^{1}$$), as piston is an inconsequential global phase, and tilts can be easily fixed by tilting a mirror placed in an FP.

The phase map $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{1}})}({\bf{x}})$$ characterizes additional aberrations, up to IP1, caused by the non-zero diffraction angle of the m = −1 order of the DMD hologram. For this, we employ the binary grating (a = 4d), pre-compensated for $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{0}})}({\bf{x}})$$, within two circular FP patches of diameter dp = 30d each, as shown in Fig. 2a (bottom), and choose the grid size dg = 25d. We measure about 0.45λ peak–peak and 0.09(1)λ RMS phase in $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{1}})}({\bf{x}})$$ (Fig. 2c, bottom), validating our assumption that $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{0}})}({\bf{x}})$$ characterizes the majority of aberrations. This $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{1}})}({\bf{x}})$$ is again dominated by astigmatism ($${Z}_{2}^{-2}$$), which is the primary aberration (except the tilt) from an angled beam. We find that the residual aberrations up to IP1 (Fig. 2d), after compensating for $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{0}})}({\bf{x}})$$ and $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{1}})}({\bf{x}})$$, is 0.014λ RMS (0.15λ peak–peak), which falls below the standard error of 0.025λ.

The phase map $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{2}})}({\bf{x}})$$ is measured with fluorescence from the ion, which behaves as a point detector because it is well-localized (estimated to be ~130 nm RMS at Doppler-cooling temperature) compared to the diffraction limit of 2.8 μm. Instead of moving the ion, we scan the phase difference (ϕ2 in Fig. 3b) between the two circular FP grating patches (dp = 100d, a = 4d, dg = 50d) to move the interference fringes across the ion. The 0.9λ peak–peak and 0.20(1)λ RMS aberrations in $${{{\Phi }}}_{{\rm{ab}}}^{({\rm{2}})}({\bf{x}})$$ are compensated to a residual aberration of 0.05(2)λ RMS (Fig. 3d), resulting in a diffraction-limited spot at the ion, as demonstrated by measuring the beam profile using ion fluorescence in Fig. 3f. The residual aberrations in both IP1 (Fig. 2d) and IP2 (Fig. 3d) are lower than the standard manufacturing tolerance of precision lenses (λ/10 at 633 nm).

### Amplitude characterization on DMD

The amplitude of the light illuminating the DMD FP, EFP (Fig. 2f) is characterized by measuring the intensity of reflected beams from a single patch (10 by 10 micromirrors), scanning across the FP with a grid size dg = 20d. The intensity is measured by C1 within the same ROI used in phase measurements described above (see “Methods” section).

### Programming the DMD hologram

The binarization of the DMD hologram introduces errors in engineering the target electric field at the image plane. To mitigate errors due to binarization and optical aberrations, we adopt a deterministic iterative Fourier transformation algorithm (IFTA). Our algorithm is based on Wyrowski (1989)22 with two significant modifications. First, we introduce phase constraints at the image plane, making the algorithm suitable for QIP experiments requiring optical phase control25,26. Second, we incorporate the ability to account for aberrations and non-uniform illumination in the Fourier plane. The IFTA strives to minimize errors only inside a user-defined “signal window” in the image plane. A suitable spatial filter placed in IP1, such as a rectangular aperture, shields the ion chain from erroneous signals outside of this signal window.

In Fig. 4a, b, we schematically describe our algorithm and show a numerical simulation for creating a pair of Gaussian spots. Figure 4c shows experimental data taken with camera C1 in IP1 of pairs of Gaussian spots suitable for simultaneously addressing arbitrary pairs of ions with non-uniform spacing. A relative intensity crosstalk error below 10−4 is achieved at a distance of approximately 4wIP1 within a 400wIP1 × 10wIP1 signal window, where wIP1 is the spot size of the addressing Gaussian beam, limited by the numerical aperture. Crucially, this low-error rate is maintained over a large signal window of length ~400wIP1. This suggests that the low-error window can fit up to 400wIP1/4wIP1 = 100 ions. In Fig. 4d, we demonstrate high-quality optical addressing by directly observing ion-fluorescence at the center of the image plane IP2, while scanning the addressing beam along y between the center and the edge of a 120wIP2 × 10wIP2 = 480 μm × 40 μm signal window. While our measurements are limited by the signal-to-noise ratio of ion fluorescence (see “Methods” section) on camera C2, we expect the low-error rates to be transmitted to IP2. This is because, astigmatism (leading aberration) at a field point 240 μm away from the center of IP2 is independently estimated (using Zemax Optics Studio) to be about 0.02 in terms of the standard Zernike coefficient, smaller than the demonstrated aberration correction limit in Fig. 3e (Supplementary Table 2).

## Discussions

In summary, we have demonstrated a high-quality, reprogrammable, ultraviolet, holographic, and individual optical addressing scheme with in situ aberration compensation for trapped ions. The flexibility of our approach facilitates the manipulation of ions with an irregular spacing, such as in Coulomb crystals, vastly extending the capabilities of most trapped-ion systems for QIP. The in situ aberration-compensation also eliminates the need for highly sensitive beam alignment that is often challenging, especially for high numerical apertures. Further, the ions can be addressed by non-Gaussian or “flat-top” beams that can potentially suppress intensity fluctuations critical for low-error quantum operations, especially with ions trapped in weak potentials31. For wavelengths that are not resonant with an atomic transition, we can extend our in situ aberration characterization by using coherent Raman transitions or phase shifts32 on ion-qubit states using Ramsey interferometry.

The intensity modulation profile (Fig. 4a) for addressing a pair of ions with two Gaussian beams is a Gaussian envelope with a sinusoidal modulation in the FP. The extent of the FP Gaussian envelope determines the beam waist wIP at IP, and the spatial frequency of the modulation (limited by the FP pixel size) determines the separation of the Gaussian spots at IP. Therefore, given a fixed ratio between wIP and the spacing of the neighboring addressing beams, the maximum number of addressable ions is fundamentally determined by the number of DMD micromirrors illuminated in the FP. By increasing the grating periodicity a, we can further increase the signal window to accommodate more than 100 ions (Supplementary Information).

To achieve a target intensity crosstalk of 10−4 or lower, wIP ≤ dm/4 (Fig. 4c), which determines the minimum required NA for the objective. Here, dm is the minimum separation between ions, determined by the trapping parameters33. For our Nion = 53 example, dm ≈ 2.4 μm, wIP ≈ dm/7 (Fig. 4c) requiring NA ≈ 0.6, although the minimum required NA ≈ 0.35 (for wIP = dm/4). We note that the aberration correction scheme adopted here has been demonstrated for up to NA = 0.8 imaging system19. For longer ion chains, a large field-of-view may necessitate the characterization of separate aberration phase maps for addressing various spatial regions. For Nion 100, the length of the ion chain increases to ~500 μm while dm ~ 3.5 μm (see trapping parameters in ref. 34) and the minimum required NA ≈ 0.3 which allows for a 500 μm field-of-view35.

By numerical simulation, we find that a deterministic hologram using our IFTA algorithm is capable of producing lower RMS errors within the user-defined signal window compared with a typical hologram using a probabilistic algorithm19, where a probability is assigned to each micromirror for binarization. We directly compare IFTA simulation results from Fig. 4b with the probabilistic algorithm for the same target in Fig. 5. Figure 5 show one instance (Fig. 5a) and an average of over 20 instances (Fig. 5b, c) of the simulated beam profile, respectively, in the image plane with the probabilistic algorithm. The accuracy of the electric field obtained with IFTA surpasses that with the probabilistic algorithm after about N ≈ 100 iterations and produces about an order of magnitude less intensity crosstalk after N ≈ 2000 iterations (Fig. 5b, c). The computational time for IFTA is proportional to N and is about 5 s for N = 2000 on a GPU (Nvidia RTX2070 Super).

The DMD efficiency, defined as the ratio of usable power in the image plane signal window to input power on the DMD, is determined by several factors, including the efficiency of the user-defined amplitude grating, the number of addressing beams, and the efficiency of the fixed micromirror grating on the DMD chip (Supplementary Information). By turning on a uniform amplitude grating (a = 4d) across the FP aperture, we measure an efficiency of ~4.5% in the m = −1 diffraction order. For creating n addressing Gaussian beams with equal intensity in the image plane, the efficiency scales approximately as 1/n (i.e., 1/n2 per addressing beam), and is independent of the total number of ions, Nion in the system. Despite low efficiency due to the amplitude grating, the exquisite control over aberrations allows for high optical intensity at ions. For example, 1 mW, λ ≈ 369.5 nm resonant (for an Ytterbium ion) light incident on the DMD will result in an intensity I ≈ 1.1 × 108 Wm−2 ≈ 2.2 × 105Isat where Isat is the saturation intensity of the 2S1/2 − 2P1/2 transition, assuming a NA = 0.6 objective. As for a mode-locked laser, used in many QIP experiments, the finite frequency bandwidth will broaden the addressing beam profile compared to a continuous wave laser (Supplementary Information).

Apart from the higher power handling capability of DMDs (up to 10 W in the UV and higher for longer wavelengths), they can also be switched at a faster rate (>10 kHz) compared to other spatial light modulators, such as liquid crystal on silicon spatial light modulator (LCOS-SLM) (<1 kHz)27. Individual micromirrors of a DMD can be switched as fast as in 10 μs and can potentially be made even faster13. However, the data transfer rate between the DMD controller and the chip is currently a bottleneck. Megahertz rate light switching, required for some QIP experiments, can be achieved by using an acousto-optic modulator (AOM) in conjunction with the DMD. The relatively slow switching speed of the DMD compared to trapped-ion quantum gates36 increases the total algorithm time in a quantum experiment. The long coherence time of trapped-ion qubits37 in absence of any control light implies negligible decoherence compared to typical gate infidelities24, for example, an infidelity of $$\sim \!1-\exp \left(-(30{\rm{\mu s}}/10{\rm{s}})\right)\approx 3\times 1{0}^{-6}$$ for an idling time of 30 μs and a coherence time of 10 s. However, other sources of error such as motional heating rate of the specific trap have to be taken into account to accurately quantify the impact of a longer algorithm time.

The experiments with ion fluorescence collection reported here suffer from an unwanted scattering of the resonant light (about 10% relative to the peak fluorescence of the addressing beam) from vacuum chamber windows leaking onto the imaging system, thus, reducing the signal-to-noise ratio of the ion fluorescence signal on the camera C2. The unwanted scattering also limited the maximum area or which we could characterize aberrations using the ion and thus reduced the NA to 0.08. The scattering problem can be mitigated by using separate directions for measurement and addressing. Also, experiments that don’t require addressing and measurement at the same time (for example state preparation by optical pumping) do not suffer from the scattering problem. The high-precision addressing capabilities demonstrated here open up exciting possibilities for new experiments, such as partial measurement of a quantum system at the level of a single qubit without decohering others.

## Methods

### Phase-profile extraction in the intermediate image plane IP1

The interference fringes in IP1 (in Fig. 2b for example) are sampled by the camera C1 as a 2D array. We crop the array within a region of interest (ROI) for phase extraction. The cropped array is denoted as Ixy(mp, np) where Δ ≡ (x, y) denotes the coordinate of the scanning patch relative to the reference patch in the DMD FP, and (mp, np) denotes the coordinates of camera pixels. Here, m and n denote the two spatial directions of the fringes on the camera. We first calculate the spectrum Sxy of Ixy with a 2D fast Fourier transformation (FFT),

$${S}^{xy}={\rm{abs}}({\rm{FFT}}[{I}^{xy}]).$$
(2)

Next, we apply a high-pass filter (HPF) to filter out the low spatial frequency background envelope of Ixy and retrieve the spatial frequency of the interference fringes $$({\kappa }_{m}^{xy},{\kappa }_{n}^{xy})$$,

$$(| {\kappa }_{m}^{xy}| ,| {\kappa }_{n}^{xy}| )={\rm{abs}}({\rm{argmax}}[{\rm{HPF}}[{S}^{xy}]]).$$
(3)

A robust estimate for $$({\kappa }_{m}^{xy},{\kappa }_{n}^{xy})$$, that is insensitive to shot-to-shot fluctuations in the interference fringes, can be obtained by finding their linear functional dependence on the FP coordinates (x, y), as

$${\kappa }_{m}^{xy}=ax+by,\,a\,>\,0$$
(4)
$${\kappa }_{n}^{xy}=a^{\prime} x+b^{\prime} y,\,a^{\prime}\, <\,0.$$
(5)

Here, $$a,a^{\prime} ,b,b^{\prime}$$ are fitting parameters. The relative negative sign between a and $$a^{\prime}$$ is due to the fact that the camera is facing opposite to the beam pointing direction. From the two spatial frequencies, we can construct a complex plane wave fringe profile,

$${T}^{xy}({m}_{{\rm{p}}},{n}_{{\rm{p}}})=\exp ({\rm{i}}({\kappa }_{m}^{xy}({m}_{{\rm{p}}}-{m}_{c})+{\kappa }_{n}^{xy}({n}_{{\rm{p}}}-{n}_{c}))),$$
(6)

where (mc, nc) is the coordinate of the user-defined center of the interference fringes. The phase of the FP at (x, y) is computed from,

$$\phi (x,y)={\rm{angle}}(\sum _{{m}_{{\rm{p}}},{n}_{{\rm{p}}}}({T}^{xy}\cdot {I}^{xy})).$$
(7)

### Zernike coefficients

Zernike polynomials, commonly used to describe optical aberrations, are a sequence of orthogonal polynomials defined within a unit circle. They are expressed in polar coordinates ρ and θ as

$${Z}_{n}^{m}(\rho ,\theta )=\left\{\begin{array}{l}{N}_{n}^{m}{R}_{n}^{| m| }(\rho )\cos (m\theta )\,{\rm{for}}\,m\ge 0\\ -{N}_{n}^{m}{R}_{n}^{| m| }(\rho )\sin (m\theta )\,{\rm{for}}\,m\,<\,0\end{array}\right.$$
(8)
$${R}_{n}^{| m| }(\rho )=\mathop{\sum }\limits_{k=0}^{\frac{n-| m| }{2}}\frac{{(-1)}^{k}(n-k)!}{k!(\frac{n+| m| }{2}-k)!(\frac{n-| m| }{2}-k)!}{\rho }^{n-2k}$$
(9)
$${N}_{n}^{m}=\sqrt{\frac{2(n+1)}{1+{\delta }_{m,0}}},$$
(10)

such that

$$\mathop{\int}\limits_{0}^{2\pi }\mathop{\int}\limits_{0}^{1}{Z}_{n}^{m}(\rho ,\theta ){Z}_{n^{\prime} }^{m^{\prime} }(\rho ,\theta ){\mathrm{d}}\rho {\mathrm{d}}\theta =\pi {\delta }_{n,n^{\prime} }{\delta }_{m,m^{\prime} }.$$
(11)

The aberration phase map Φ(ρ, θ) can be expressed as a unique linear combination of Zernike polynomials,

$${{\Phi }}(\rho ,\theta )=\mathop{\sum}\limits_{n,m}{c}_{n}^{m}{Z}_{n}^{m}(\rho ,\theta ).$$
(12)

We estimate the Zernike coefficients in our measured phase maps by uniformly sampling across the FP aperture (of radius $${r}_{{\rm{aperture}}}$$), as

$${c}_{n}^{m}=\frac{1}{N}\mathop{\sum}\limits_{x,y}{{\Phi }}(x,y){Z}_{n}^{m}(x,y).$$
(13)

Here,

$$\rho =\frac{\sqrt{{x}^{2}+{y}^{2}}}{{r}_{{\rm{aperture}}}}$$
(14)
$$\theta ={\rm{arctan2}}(y,x).$$
(15)

The sample size N equals to the number of grid points in scanning the FP patches. In our experiments, we extract the Zernike coefficients (Eq. (13)) after averaging the phase maps over five repeated measurements. The uncertainty of the Zernike coefficients and the standard deviation δΦ(x, y) of the phase map are related through,

$$\delta {c}_{n}^{m}=\frac{1}{N}\sqrt{\sum _{x,y}{(\delta {{\Phi }}(x,y){Z}_{n}^{m}(x,y))}^{2}}.$$
(16)

### Amplitude characterization

The amplitude profile of the beam illuminating on the DMD Ein(x) is characterized by measuring its intensity, $$| {E}_{{\rm{in}}}({\bf{x}})| =\sqrt{I({\bf{x}})}$$. We turn on all the micromirrors in a 10d × 10d patch and scanned on a dg = 20d grid on the DMD. We choose an ROI on the camera C1 (in IP1) to avoid diffraction from the OFF mirrors (as shown in 2b), and measure the total intensity on all pixels within the ROI. We subtract the contribution of OFF mirrors in the ROI, by taking another image with all micromirrors in the OFF position.

### Ion fluorescence measurement

While measuring ion fluorescence (in Figs 24), we keep a weak Doppler-cooling beam on, shining perpendicularly to the DMD beam, in order to keep the ion cold and hence localized. We extract the fluorescence count due to the DMD beam only (n(DMD)), by taking into account the contributions from the side-Doppler-cooling fluorescence as well as unwanted reflections of these beams, as,

$$\begin{array}{ll}{n}^{({\rm{DMD}})}\,=\,(n-{n}^{(935{\rm{off}})})-({n}^{({\rm{DMD}}{\rm{off}})}-{n}^{({\rm{DMD}}{\rm{off}}\& 935{\rm{off}})}).\end{array}$$
(17)

Here, n is the total count detected on a camera pixel. n(935off) denotes the count with the 935 nm repumper beam turned off, pumping the ion into the D3/2 dark state. Hence, n(935off) measures the unwanted reflection of the DMD and side-fluorescence beams. n(DMDoff) denotes the measured count with DMD beam turned off, and hence includes fluorescence and unwanted reflections from the side-Doppler-cooling beam. $${n}^{({\rm{DMD}}{\rm{off}}\& 935{\rm{off}})}$$ denotes the measured count with the DMD and the 935 nm beams turned off, and hence includes the unwanted reflections from the side-Doppler-cooling beam. The error bars presented in the results here are calculated by propagating errors in each term in Eq. (17).