## Abstract

Precise frequency measurements are important in applications ranging from navigation and imaging to computation and communication. Here we outline the optimal quantum strategies for frequency discrimination and estimation in the context of quantum spectroscopy, and we compare the effectiveness of different readout strategies. Using a single NV center in diamond, we implement the optimal frequency discrimination protocol to discriminate two frequencies separated by 2 kHz with a single 44 μs measurement, a factor of ten below the Fourier limit. For frequency estimation, we achieve a frequency sensitivity of 1.6 µHz/Hz^{2} for a 1.7 µT amplitude signal, which is within a factor of 2 from the quantum limit. Our results are foundational for discrimination and estimation problems in nanoscale nuclear magnetic resonance spectroscopy.

## Introduction

Quantum sensing uses platforms such as photons, ions, solid-state defects, and their quantum properties as resources to estimate physical quantities as precisely as possible^{1,2}. The performance depends on the sensing and readout protocols, which should optimize the ratio of the sensor response for the parameter of interest^{3,4} to readout noise^{5}. Thus, finding optimal protocols is crucial to enabling efficient estimation. One of the major applications of quantum sensing is nanoscale nuclear magnetic resonance (NMR) spectroscopy in which a nanoscale quantum sensor replaces the macroscopic inductive coil and interacts with a sample of nuclear spins^{6,7,8,9}. Pioneering work with the nitrogen-vacancy (NV) center in diamond^{10,11}, has demonstrated nanoscale spatial resolution^{6,7,12,13,14} with single spin sensitivity^{9}. Understanding and realizing the limits of quantum measurements is particularly important in spectroscopy wherein frequency encodes energy, spatial, and structural information.

Here we determine the quantum limit for discriminating known frequencies, develop a protocol that saturates it, and prove that this protocol achieves the minimal possible error probability as a function of time. After deriving the theoretical limits, we experimentally demonstrate this protocol by discriminating two known frequencies separated by 2 kHz, with a single 44 µs (Fourier limit 1/*T* ~ 23 kHz) coherent measurement. We extend our studies by explicitly analyzing the influence of imperfect readout of our sensor qubit and perform a detailed comparison between two readout strategies.We show that these results can also be applied to find the optimal protocol for frequency estimation^{15,16,17,18,19} and we use this protocol to experimentally estimate the value of a single unknown frequency. The relevance of the estimation protocol for realistic nano-NMR scenarios and the implications of the imperfect NV readout is further analyzed. Our results are important when one is faced with a decision on how to allocate finite resources to construct better sensors.

## Results

### Optimal frequency discrimination using a quantum probe

As a diagnostic tool, NMR can be used to answer “yes–no” questions such as whether a certain toxin or metabolite is present in the sample. As sketched in Fig. 1a, the task is then to discriminate between two known spectra based on their frequency components. We define discrimination error as the error to decide on the wrong spectrum and our goal is to obtain a minimal discrimination error or equivalently a minimal discrimination time. A typical method compromises sampling the signal with consecutive, synchronized measurements and correlating the individual outcomes, e.g., by applying Fourier analysis, to obtain a spectrum. For sufficient recording time, the resolution can be high enough for an almost error-free discrimination. To illustrate, consider a simplified problem in which one wishes to discriminate between two spectra, each containing only a single frequency (*ω*_{1} or *ω*_{2}) with the same amplitude *B* (in units of angular frequency). Naively, the method described above is Fourier limited, i.e., the time required for discrimination is \(T = \frac{1}{{|\omega _{\Delta}|}}\), where *ω*_{Δ} = *ω*_{2} − *ω*_{1}. Using a more sophisticated data analysis, such as Bayesian interference or machine learning, which can be applied for known *B*, the discrimination time lowers to \(T \sim \frac{1}{{B^{2/3}\omega _{\mathrm{{\Delta}}}^{2/3}}}\) (see Supplementary Note 1 and ref. ^{20}) However, we show in the following that, given a sufficient coherence time, the discrimination time can be further reduced to:

The key idea is to drive the sensor such that the angle between the states, \(|\psi \left( {\omega _1} \right)\rangle\) and \(|\psi \left( {\omega _2} \right)\rangle\), is maximal, to guarantee a minimal error probability. Once orthogonality is achieved, quantum projection noise can theoretically be eliminated by measuring in the appropriate basis and it is possible to determine, with a certainty limited by readout fidelity, which frequency is present. Assuming a perfect readout, we show that this method is in general optimal, even if orthogonality cannot be achieved.

Given free evolution of the sensor, the discrimination time is \(T \sim \frac{\omega }{{B\omega _{\mathrm{{\Delta}}}}}\) (see Supplementary Note 1), which is basically the same scaling as the Fourier limit. As sketched in Fig. 1b, the phases \(\varphi (\omega _1)\) and \(\varphi (\omega _2)\), accumulated by the sensor under *ω*_{1} and *ω*_{2}, move apart and get closer to each other such that their difference \(\varphi _{\mathrm{{\Delta}}} = \varphi (\omega _1) - \varphi (\omega _2)\) oscillates and only slowly increases. However, *T* can be significantly reduced by applying a suitable control, which is also shown in Fig. 1b: whenever the states start to get closer to each other (*φ*_{Δ} reduces), a control *π*-pulse can be used to change the direction of motion such that their distance increases instead. Formally, the distance between two states can be described by the angle \(\varphi _{\mathrm{{\Delta}}}/2\,{\underline{\underline {{\mathrm{def}}}}}\, \alpha \left( {\omega _1,\omega _2} \right)\), which evolves as:

where \({\cal{H}}_i\left( t \right) = B\;{\mathrm{sin}}\left( {\omega _i{\mathrm{t}} + \theta } \right)\sigma _{\mathrm{Z}} = {\mathrm{H}}_i\left( t \right)\sigma _{\mathrm{Z}}\) are the corresponding signal Hamiltonians, *θ* is the initial signal phase, and \(\sigma _Z\) is the Pauli spin-*z* operator. As a consequence, maximizing \(\alpha \left( {\omega _1,\;\omega _2} \right)\) implies applying a *π*-pulse whenever \({\mathrm{H}}_1\left( t \right) - {\mathrm{H}}_2\left( t \right)\) changes sign and it follows (see Supplementary Note 1):

where \(\mu _{{\mathrm{max}}}\;{\mathrm{and}}\;\mu _{{\mathrm{min}}}\) are the maximal and minimal eigenvalues of \({\cal{H}}_1 - {\cal{H}}_2\). Application of a series of *π*-pulses with a spacing \(\frac{{2\pi }}{{\omega _1 + \omega _2}}\) constitutes optimal control in this scenario. As orthogonality requires \(\alpha \left( {\omega _1,\;\omega _2} \right) = \pi /2\), the minimal discrimination time is \(T_{{\mathrm{opt}}} = \frac{\pi }{{2\sqrt B \sqrt {|\omega _{\mathrm{{\Delta}}}|} }}\).

For an illustrative explanation, one can think of \(\left| {\psi \left( {\omega _1} \right)} \right\rangle ,\;\left| {\psi \left( {\omega _2} \right)} \right\rangle\) as two runners, where the goal is to maximize the gap between them (see Fig. 1c). As long as the same runner (suppose \(\left| {\psi \left( {\omega _2} \right)} \right\rangle\)) is faster (speed proportional to the current amplitude), their separation gets larger as desired. However, once \(\left| {\psi \left( {\omega _1} \right)} \right\rangle\) starts to be faster than \(\left| {\psi \left( {\omega _2} \right)} \right\rangle\), we prevent a reduction of the gap by flipping the direction they run (equivalent to a *π*-pulse).

The phase acceleration in Eq. (4) coincides with the fundamental speed limit derived in ref. ^{21} and this implies a minimal discrimination error for every *t*. Hereafter, for all error analysis, we assume that the prior probability for both frequencies is 1/2, namely symmetric hypothesis testing. Given any two Hamiltonians \({\cal{H}}_1\left( t \right)\) and \({\cal{H}}_2\left( t \right)\), we prove in Supplementary Note 1 that the error probability when distinguishing between these Hamiltonians, optimized over all possible strategies, is lower bounded by:

where \(\alpha _{{\mathrm{max}}} = {\int\nolimits_0^t} \frac{{\mu _{{\mathrm{max}}} - \mu _{{\mathrm{min}}}}}{2}dt^{\prime}\). This lower bound can always be saturated with a suitable control. Hence, even if \(\alpha _{{\mathrm{max}}} \le \frac{\pi }{2}\) at *t*, the strategy that minimizes the error probability is to apply the above discussed control and perform a measurement at *t*, which implies that even multiple correlated measurements at times shorter than *t*^{19,22} cannot beat this fundamental limit, as shown in Fig. 1d (see Supplementary Note 1).

### Experiments

The experiments are performed using a single NV center in ultrapure diamond (Fig. 2a). Here we use a 400 G magnetic field, aligned along the NV symmetry axis, to lift the degeneracy of the three ground spin states and we use two of these states (here denoted as \(\left| 0 \right\rangle ,\;\left| 1 \right\rangle\)) as a qubit. We initialize our qubit into a coherent superposition state and map the sensor phase *φ* = 2*α* (compare Eq. (3)), acquired during interaction with the control sequence and the signals, into a population difference (such that the probability for the sensor to be projected to \(\left| 0 \right\rangle\) reads \(P = 0.5 \cdot \left( {1 - \sin \left( \varphi \right)} \right)\), which is subsequently read out optically.

In Fig. 2b, *φ*_{Δ} is plotted, when a magnetic field of frequency \(\omega _1 = (2\pi ) \cdot 0.999\) MHz or *ω*_{2} \(= (2\pi ) \cdot 1.001\) MHz, in the range of frequencies typical for nano-NMR experiments with NV centers and was measured with an XY8-N sequence with an interpulse spacing of 500 ns. The interaction time was extended by increasing the pulse number. A logarithmic plot of \(\varphi _{\Delta}\) shows the expected *t*^{2} increase until 44 µs when \(\varphi _{\mathrm{{\Delta}}} = \pi\), at which time the quantum sensor has been evolved into one of two orthogonal states, as \(|P\left( {\omega _1} \right) - P\left( {\omega _2} \right)| = 1\). By using a 90° phase-shifted \(\frac{\pi }{2}\) – pulse (compared to the initialization basis), the sensor phase can be mapped into a population difference and the resulting NV population as a function of interaction time is plotted (Fig. 2c). In Supplementary Note 4, we show that this balanced readout is also optimal. Experimental data for the dependency of the discrimination time on \(\omega _{\mathrm{{\Delta}}}\) and *B* are provided in the Supplementary Note 5. If the coherence of the sensor is not sufficient to achieve orthogonality, the described protocol still remains optimal (see detailed discussion in Supplementary Note 1).

### Complex frequency discrimination

This method can be extended for complex spectra consisting of more than one frequency or amplitude component. Consider a Hamiltonian that takes the general form \({\cal{H}}_{1,2} = {\int} {f_{1,2}\left( \omega \right)\sin \left( {\omega t} \right)d\omega \;\sigma _Z = {\mathrm{H}}_{1,2}\sigma _Z}\) such that the two frequency distribution functions \(f_{1,2}\left( \omega \right)\) are known, but we do not know which of the Hamiltonians, \({\cal{H}}_1\) or \({\cal{H}}_2\), is present. As an illustrative example, we consider the ^{13}C nuclear magnetic spectrum produced by either a sample of ethanol or propanol, both of which contain two chemically distinct carbon groups (Fig. 3a, b). A similar speed bound for discrimination applies to this case (see Supplementary Eq. 1) and is achievable with an analogous protocol. We can again define \({\mathrm{H}}_{\Delta} = {\mathrm{H}}_1 - {\mathrm{H}}_2\), where optimal control is achieved by applying *π*-pulses whenever \({\mathrm{H}}_{\Delta}\) switches sign (Fig. 3c). Importantly, for NMR detection of a polarized sample, the initial signal phase is known, as it is defined by a *π*/2-pulse applied to the sample. As a result, a sensor phase difference of π can be tailored to perform optimal discrimination. Of note, the sensor phase difference also increases according to *t*^{2}, until the signals become completely out of phase with each other.

### Implications of imperfect readout

Above, we showed that in principle, it is possible to discriminate two frequency distributions within a single measurement by eliminating projection noise. As perfect measurements are not possible in an experimental realization, additional readout noise has to be taken into account. For optical readout of NV centers, e.g., photon shot noise has to be considered. As a result, noise analysis is important to obtain a meaningful discrimination error. The readout of the NV center is performed by detecting the spin-dependent fluorescence emitted during a laser pulse (see “Methods”). The recorded photons are well described by a Poisson distribution with an average photon number of \(\lambda _0 = 0.084\) \(\left( {\lambda _1 = 0.07} \right)\) for the \(\left| 0 \right\rangle\) \(\left( {\left| 1 \right\rangle } \right)\) spin state (compare Supplementary Note 2). With this small contrast, the error of a single measurement, assuming again a symmetric hypothesis testing, is ~0.49, even for orthogonal states (see Supplementary Note 4), i.e., we have a nearly 50–50 chance to assign the frequency incorrectly.

The probability to make an incorrect decision can be reduced in two ways: first, by increasing the number of measurements, which we refer to as ensemble averaging. Then, the difference in the number of emitted photons increases, which leads to better discriminability. The second approach is based on improving the readout process itself by increasing the contrast between the states. This can be achieved by introducing an ancilla qubit, which acts as a quantum memory and stores the state of the NV center^{23,24}. This method is usually referred to as single-shot readout (SSR). We experimentally implement these two methods and compare their performance using the error probability as figure of merit. We show that by benchmarking against the number of detected photons, ensemble averaging always performs at least as good as SSR, but when compared in terms of measurement time or number of coherent interaction periods, SSR has particular advantages.

Temporal ensemble averaging was performed using a 1.35 NA oil objective, to collect the NV fluorescence and repeating the sensing and readout *N*_{ens} times (compare Fig. 4a). Hence, given the orthogonal states and *N*_{ens} repetitions of the measurement, the discrimination between the states reduces to discrimination between two Poissonian distributions: \({\mathrm{Poi}}\left( {N_{{\mathrm{ens}}}\lambda _0} \right)\) and \({\mathrm{Poi}}\left( {N_{{\mathrm{ens}}}\lambda _1} \right)\). Assuming small contrast, namely \(\frac{{\lambda _0}}{{\lambda _1}}\) is close to 1, we observe that the error probability scales as \(\exp ( { - N_{{\mathrm{ens}}}0.5\left( {\sqrt {\lambda _1} - \sqrt {\lambda _0} } \right)^2})\) (Supplementary Note 4). For non-orthogonal states, the error probability also decays exponentially with *N*_{ens} to 0 and the error exponent is \(\sim \frac{{\left( {\lambda _0 - \lambda _1} \right)^2\sin \left( \alpha \right)^2}}{{4\left( {\lambda _0 + \lambda _1} \right)}}\) (Supplementary Note 4), where *α* is the angle between the states. Hence, given that the duration of a single ensemble average is *τ* (including the overheads for readout and initialization), the discrimination time with this strategy goes as \(\sim \tau \frac{{4\left( {\lambda _0 + \lambda _1} \right)}}{{\left( {\lambda _0 - \lambda _1} \right)^2\sin \left( \alpha \right)^2}}\)

SSR is implemented by using a weakly coupled ^{13}C spin that forms a memory qubit and allows repetitive readout of the NV state with a quantum non-demolition (QND) experiment^{25} (compare Fig. 4b and Supplementary Note 2). The ancilla qubit allows more photons to be scattered before its state is destroyed and here we perform *N*_{RR} repetitive readouts after one sensing time. The larger *N*_{RR}, the closer we get to a perfect quantum measurement, limited ultimately by the lifetime of the ancilla. For *N*_{RR} = 10^{4}, the photon statistics manifest digital step jumps, which allows high-fidelity readout of the nuclear spin state (see Supplementary Note 2). The discrimination between orthogonal states using this method is, in theory, a discrimination between \({\mathrm{Poi}}\left( {N_{{\mathrm{RR}}}\lambda _0} \right)\) and \({\mathrm{Poi}}\left( {N_{{\mathrm{RR}}}\lambda _1} \right)\), and thus given as \(N_{{\mathrm{RR}}} = N_{{\mathrm{ens}}}\), precisely the same as for ensemble averaging. Then, the only difference is the time required to perform readout of the nuclear spin and that SSR requires only one sensing period, which is discussed in more detail below. For non-orthogonal states however, this strategy is inferior as the error probability does not reduce to 0 in the limit of large *N*_{RR} due to quantum projection noise. This additional uncertainty inherent to quantum measurements results in a scaling as \(0.5\left( {1 - |\sin \left( \alpha \right)|} \right)\) (see Supplementary Note 1).

We experimentally investigated the performance of both strategies by performing ensemble averaging and SSR for discrimination of the same signals described earlier. The error as a function of different parameters is plotted in Fig. 5a–e. In Fig. 5a, it is shown that for any angle *α* between the states (or equivalently, for any coherent interaction period), ensemble averaging performs better than SSR. However, in contrast to the theoretical expectation, we see that ensemble averaging yields a lower error than SSR also for orthogonal states (44 μs, \(\varphi _{\Delta} = \pi\)). The reason for this is that, although the nuclear state can be readout with high fidelity in our experiments, imperfect initialization of the NV center into the correct charge state and the finite ancilla *T*_{1} lifetime, limits the sensor readout fidelity to 0.8 (see Supplementary Note 2 and refs. ^{26,27}). In Fig. 5a (red line), we plot the expected error achievable with SSR under perfect sensor initialization and control, which demonstrates the equivalence between the two readout methods when orthogonality is achieved.

Figure 5b shows the discrimination error as a function of the number of photons detected with each readout technique, for a fixed interaction time of 44 μs (Δ*φ* = π, dotted line in Fig. 5a). As the sensor is driven to an eigenstate, each photon should convey the same information about which frequency is present regardless of whether it was obtained from ensemble averaging or SSR. We observe that imperfect initialization reduces the information carried by each photon using SSR, resulting in the error converging to an offset of 0.2. By using charge-state detection to improve the sensor initialization, it is expected that a convergence in the two readout strategies would be observed.

However, SSR may still be useful if the total measurement time is taken into account. For ensemble averaging, every repetition cycle requires a duration of initialization \(\left( {t_{{\mathrm{init}}}} \right)\), interaction (*t*), and readout \(\left( {t_{{\mathrm{read}}}} \right)\); thus, the total measurement time is \(T_{{\mathrm{ens}}} = N_{{\mathrm{ens}}}\left( {t_{{\mathrm{init}}} + t + t_{{\mathrm{read}}}} \right)\). For our experiments, \(t_{{\mathrm{init}}} + t_{{\mathrm{read}}} \approx 1.5\;\mu {\mathrm{s}}\). For SSR, only one initialization and interaction period are required, while readout is performed *N*_{RR} times. The initialization and readout time for SSR are different to ensemble averaging, however, as manipulation of the ancilla is required; thus, the total time is \(T_{{\mathrm{SSR}}} = t_{{\mathrm{init}}}^{{\mathrm{anc}}} + t + N_{{\mathrm{RR}}}\;t_{{\mathrm{read}}}^{{\mathrm{anc}}}\). For our experiments, \(t_{{\mathrm{init}}}^{{\mathrm{anc}}} \approx 100\;\mu {\mathrm{s}}\) and \(t_{{\mathrm{read}}}^{{\mathrm{anc}}} \approx 17\;\mu {\mathrm{s}}\), so for *N*_{RR} > 10, most of the temporal overheads for SSR arise from readout of the ancilla spin via repeated mapping onto the NV electron spin (see “Methods”). For long interaction times (⪎17 *µ*s), this overhead is less costly than repeating the interaction and SSR is faster than ensemble averaging, as shown in Fig. 5c.

In addition to performing only a single SSR measurement, we investigate the discrimination error when performing multiple SSR measurements. In Fig. 5d, the discrimination error is plotted as a function of the total time required by each readout strategy, including all measurement overheads. For SSR, the time is incremented by performing additional measurements, each using *N*_{RR} = 10^{4} repetitive readouts, which we in the following refer to as hybrid strategy, as many individual SSR are averaged, while for ensemble averaging just *N*_{ens} is increased. Although about twice the number of photons is recorded for the hybrid strategy within the same time, ensemble average still performs better. The reason for this is that *N*_{RR} is too large; we observe that by reducing *N*_{RR}, the hybrid strategy can yield a smaller error as a function of time. For *N*_{RR} = 10^{3}, we find a slightly better scaling for the hybrid strategy using simulations, taking our measurement parameters into account (see Supplementary Note 4), as projection noise is sufficiently reduced. By further reducing to *N*_{RR} = 10^{2}, we find that the error exponent with the hybrid strategy is almost twice as large as the error exponent of ensemble averaging and there is a reduction of the overall error by a factor of 40 after measuring for 1 s. A more detailed analysis and optimization over *N*_{RR} can be found in Supplementary Note 4. In addition to benchmarking against the total measurement time, we also compare in terms of the number of trials, (i.e. the number of times the signal is queried), which becomes critical if many interrogations are prohibited, e.g. due to sample contamination or degradation. As expected, the hybrid strategy performs significantly better, as a high confidence can be obtained from a single trial (Fig. 5e). In Fig. 5d, e the error decays exponentially with the total time (or equivalently number of queries) as expected, the error exponent for both methods is calculated explicitly in Supplementary Note 4.

It should be noted that these results apply to any problem with the aim to discriminate between two NV center states.

### Qptimal frequency estimation using a quantum coherent probe

A related task is to estimate a single unknown frequency *ω* of a signal \({\cal{H}}\left( \omega \right) = B\;\sin \left( {\omega t + \theta } \right)\sigma _Z = H(\omega )\sigma _Z\) with minimum uncertainty \({\mathrm{{\Delta}}}\omega\). The variance \(\left( {{\mathrm{{\Delta}}}\omega } \right)^2\) is lower bounded by the inverse of the quantum Fisher information (QFI) \(I(\omega )\)^{28}:

Notably, the QFI has a clear geometric meaning, as *I*(*ω*) can be written using the Bures distance *d*_{B} between quantum states:

where \(\alpha \left( {\omega - \frac{{\omega _{\Delta}}}{2},\omega + \frac{{\omega _{\Delta}}}{2}} \right)\) is the angle between \(|\psi \left( {\omega \pm \omega _{\mathrm{{\Delta}}}/2} \right)\rangle\). Hence, maximizing the QFI is equivalent to optimizing the discrimination of \(\mathop {{{\mathrm{lim}}}}\nolimits_{\omega _{\mathrm{{\Delta}}} \to 0} \left| {\psi \left( {\omega \pm \frac{{\omega _{\mathrm{{\Delta}}}}}{2}} \right)} \right\rangle\). As shown above, this means maximizing the accumulation of \(\frac{{dH}}{{d\omega }} = \mathop {{{\mathrm{lim}}}}\nolimits_{\omega _{\mathrm{{\Delta}}} \to 0} \frac{{H\left( {\omega + \frac{{\omega _{\mathrm{{\Delta}}}}}{2}} \right) - H\left( {\omega - \frac{{\omega _{\mathrm{{\Delta}}}}}{2}} \right)}}{{\omega _{\mathrm{{\Delta}}}}}\), which is achieved by applying *π*-pulses whenever \(\frac{{dH}}{{d\omega }}\) changes sign. This optimal strategy is illustrated in Fig. 6a, where *π*-pulses are applied at the antinodes of the signal with a spacing close to \(\frac{\pi }{\omega }\). According to Eq. (3), it follows:

The minimal uncertainty obtainable in a single experiment reads^{16}:

and scales again as 1/*t*^{2} due to the phase acceleration of the sensor. This is a special case of the analysis performed in refs. ^{16,17,18,19} and partially realized in ref. ^{15} without taking readout noise into account.

A further peculiarity is that the *π*-pulses should be applied close to the signal antinodes where \(\frac{{dH}}{{d\omega }}\) changes sign, which is in contrast to amplitude estimation. We demonstrate the underlying intuition by recording spectra for the two edge cases—control started close to a signal node \(\left( {\theta = \frac{\pi }{2}} \right)\) or antinode \(\left( {\theta = 0} \right)\). We again used XY8 sequences and chose the readout basis such that the final NV population reads \(P = 0.5 \ast \left( {1 + \sin \left( \varphi \right)} \right)\). When the *π*-pulses are placed at the signal nodes (Fig. 6b blue), the NV population *P* is maximal, but \(\frac{{\partial P}}{{\partial \omega }}\) vanishes; thus, although the sensor acquires maximal phase, it is insensitive to changes in the signal frequency. In contrast, for *θ* = 0 (Fig. 6b green), the sensor acquires minimal phase; however, small frequency changes lead to large population deviations (here, \(\left( {\frac{{\partial P}}{{\partial \omega }}} \right)_{{\mathrm{max}}}\, \approx 10^7\;{\mathrm{Hz}}^{ - 1}\), which corresponds to \(\left( {\frac{2}{{4\pi }}} \right)Bt^2\)).

Assuming perfect quantum measurements, any measurement basis in the *X*–*Y* plane would be optimal, as they all saturate the QFI (see Supplementary Note 7). The imperfect readout of the NV center not only worsens the estimate, but also provokes a dependency on the measurement basis^{29}. When using conventional readout of single NV centers, the fluorescence contrast is very low and the measurement noise barely varies with the measurement basis (see Supplementary Note 8). As a consequence, it is optimal to measure (approximately) in the basis that yields the maximal slope. In our case, assuming an initialization in the *X* basis, a maximal slope is obtained by measuring in the *Y*-basis and it follows (in the limit of small contrast, see Supplementary Note 8):

Taking our experimental values of *λ*_{0}, *λ*_{1} into account, a factor of ~40 in SD is lost.

We realize experimental frequency estimation by measuring an unknown frequency *ω* (=999.3 MHz) oscillating close to 1 MHz with known amplitude (1.7 µT). Applying XY8 sequences with a pulse spacing of 500 ns and locking *θ* = 0, we use ensemble averaging \(\left( {N_{{\mathrm{ens}}} \approx 1000} \right)\) to estimate the frequency several thousand times for a variety of interaction times *t* (controlled by tailoring the *π*-pulse number). By computing the SD and assuming shot noise \(\sqrt T\)-scaling, we are able to extract an estimate for the uncertainty \({\mathrm{{\Delta}}}\omega\) for a single measurement, which is plotted in Fig. 6c. As expected, there is a significant difference between *X* and *Y* readout (for initialization in *X*). Measurements in the *Y* basis saturate the bound in Eq. (9) and, in particular, \({\mathrm{{\Delta}}}\omega\) scales as *t*^{−2}. In contrast, measuring in the *X* basis leads to much higher uncertainties, due to the very small slope \(\frac{{\partial P}}{{\partial \omega }}\). Interestingly, using SSR (here *N*_{RR} = 10^{4}), the results almost coincide with the theoretical limits of perfect projective measurements (Fig. 6c lower), namely a close agreement in uncertainty using *X*/*Y* measurements and an SD of 1.6 µHz/Hz^{2} within a factor of 2 to the limit, 0.9 µHz/Hz^{2} set by the QFI (Eq. (8), red line in Fig. 6c).

### Estimation: consequences of short coherence time

Finally, we address the relevance of this method to practical frequency estimation scenarios in NMR and communication. Although the described protocol is optimal if both, the signal and the sensor, are perfectly coherent, any deviations require further analysis of the estimation strategies.

For signals with short coherence time, which are especially relevant in nanoscale NMR where influences of molecular diffusion and nuclear couplings limit the coherence of the NMR signal^{6,30}, the described protocol remains optimal, as it provides the most information per individual measurement (and correlations are not possible). As shown in Fig. 6d, the frequency can be estimated with an SD improving as *t*^{−2} during one sensing period, where a timing of *θ* = 0 (green) provides three orders of magnitude improvement in SD compared to *θ* = *π*/2 (blue). The estimate can be further improved by performing multiple measurements up to a total measurement time *T*, albeit with a reduced *T*^{−1/2} scaling, typical for incoherent averages. We compute sensitivities, which are here defined as \(\eta = {\mathrm{{\Delta}}}\omega \sqrt T\) of 58 Hz/Hz^{0.5} for *θ* = 0 and 23 kHz/Hz^{0.5} for *θ* = *π*/2. If the signal phase is not known a priori, we cannot apply pulses at the right timing. Nevertheless, using adaptive measurements, the *t*^{−2} uncertainty scaling can be preserved, albeit with a higher uncertainty \({\mathrm{{\Delta}}}\omega\). In Fig. 6d (gray), the frequency SD is plotted where the spacing \(\tau _\pi\) was updated for each interaction time and the measurement was averaged over all signal phases (see Supplementary Note 10). Using this strategy, the frequency can be estimated with an order-of-magnitude reduction in uncertainty and sensitivity (here *η* = 630 Hz/Hz^{0.5}), but without the need to know the starting phase.

In the other limit, the coherence time of the sensor is much shorter than the coherence time of the signal. It has recently been shown that applying a chain of consecutive, correlated, measurements can enhance frequency estimation in this case^{19,22,31,32}. Due to the stability of the phase of the signal, the amount of information gained from late measurements is much larger than the information gained from early ones. Hence, by employing the signal coherence, the *T*^{4} scaling of the QFI, which relies on the coherence of the sensor, degrades to *T*^{3}. Without any control, the QFI in this regime reads (compare ref. ^{19}):

where the decay prefactor: \({\mathrm{sinc}}\left( {\omega t/2} \right)^2\cos \left( {\omega \tau + \frac{{\omega t}}{2} + \varphi } \right)^2\) stems from the oscillations of the signal slope. This term can be suppressed by applying *π*-pulses close to the antinodes and the ultimate limit of the QFI in this regime reads (compare Supplementary Note 11):

Hence, the scaling is the same as without control \(\left( {B^2T^3t} \right)\); however, there is a difference of \(\sim 0.56\omega t\), which can be significant for high frequencies (taking relevant experimental values, \(\omega t \sim 20\), it follows that a factor of ~10 is lost in the absence of control). Here again, the timing of the pulses is crucial. Applying resonant pulses generally leads to: \(I = \frac{4}{3}\left( {\frac{2}{\pi }} \right)^2B^2T^3t\cos \left( \theta \right)^2\) (see Supplementary Note 11). As a consequence, \(I(\omega )\) vanishes for *θ* = *π*/2 and is maximal for *θ* = 0. More generally, applying pulses with a general timing (*θ*) and a general detuning *δ* (defined as \(\omega - \pi /\tau _\pi\), where \(\tau _\pi\) is the spacing between the *π*-pulses), leads to:

It is noteworthy that in the limit of \(\delta t \ll 1,\;\delta T \gg 1\) (which was implemented in ref. ^{19}), only a factor of 1/2 is lost, compared to the optimum, due to the detuning. Hence, in this regime, the maximal achievable advantage, compared to the results in ref. ^{19}, is a factor of 2.

## Discussion

We introduced a quantum mechanical detection scheme, which achieves a quadratic increase in the sensor phase, while simultaneously reducing measurement noise, to allow frequency discrimination with a single measurement. We derived the fundamental error limit in Hamiltonian discrimination and achieved it experimentally with a suitable control. This method can provide a significant speed-up in diagnostic tests based on single quantum sensors, such as nano-NMR. In addition, we have described optimal frequency estimation strategies dependent on the readout method, and using near-ideal measurements, we obtain a frequency uncertainty near the quantum limit. If the signal phase is known, the best frequency estimate is obtained when control is started close to a signal antinode, in contradiction to methods that optimize amplitude sensitivity. These findings should prove useful in NMR, where a *π*/2-pulse on the sample defines the signal phase^{30,31}. When the signal phase is unknown, an improved scaling can be maintained using an adaptive approach. Applications for these techniques include quantum spectroscopy and spectrum analyzers^{33}, characterization of quantum systems, search for dark matter, and construction of improved frequency standards.

## Methods

### Experimental setup

An arbitrary waveform generator (Tektronix AWG70001A) with 20 ps timing resolution and 8 bit amplitude resolution was used for microwave control of the NV center and to generate signals of well-defined frequency and phase. Before every measurement, possible phase shifts due to different cable lengths and microwave switches and combiners were compensated for. The signal amplitude at the NV center was calibrated prior to every measurement with a standard XY8 measurement. For the fluorescence detection, we used only the first 350 ns, as we found that this duration optimizes the signal-to-noise ratio for our experimental setup.

### Diamond samples

All QND measurements were performed on a diamond with 0.1% ^{13}C content^{25}. NV centers in this diamond have long-phase memory times (~50 µs), while maintaining a high probability to find weakly coupled ^{13}C spins. For all other experiments, a hemispherical diamond polished into a solid immersion lens provided a higher photon detection efficiency. On the flat surface, an isotopically enriched diamond layer (99.999% ^{12}C) containing NV centers was grown by a plasma-enhanced chemical vapor deposition process, as in ref. ^{34}. The diamond was boiled in a 1 : 1 : 1 tri-acid mixture (H_{2}SO_{4} : HNO_{3} : HClO_{4}) for 4 h at 130 °C before experiments.

### Readout statistics

For ensemble averaging, a single measurement was defined as a single interaction time followed by a single laser pulse, repeated *N*_{ens} times. The readout noise, \(\delta _{\mathrm{SN}}\) was determined by performing a few thousand subsequent, identical measurements and recording fluctuations from the average fluorescence intensity. For SSR statistics, a single projective measurement was performed after each interaction time. The nuclear spin state was measured with *N*_{RR} repetitive mapping operations which, based on the overlap of the photon intensities, results in a readout fidelity higher than 99% for *N*_{RR} = 10^{4}. Fluctuations in the readout state from a few thousand subsequent identical measurements was used to determine the SD, respectively.

### Discrimination analysis

For *y*-basis readout, the probability *P* for the NV to remain in its initial \(\left| 0 \right\rangle\) state is \(P = \sin ^2\left( {\frac{\pi }{4} - \frac{\varphi }{2}} \right)\) (see Fig. 2d). This formula was also used to calculate the phase accumulation as shown in Fig. 2c. For ensemble measurements, detection of a fluorescence level above or below a threshold value determined the frequency assignment. For SSR, the frequency was assigned dependent on the readout state, which was determined from a normalized fluorescence measurement (see Supplementary Note 2).

## Data availability

The data that support the findings of this study are available from the corresponding author upon reasonable request.

## Code availability

Codes are available upon request from the authors.

## References

Degen, C. L., Reinhard, F. & Cappellaro, P. Quantum sensing.

*Rev. Mod. Phys.***89**, 035002 (2017).Pirandola, S., Bardhan, B. R., Gehring, T., Weedbrook, C. & Lloyd, S. Advances in photonic quantum sensing.

*Nat. Photonics***12**, 724–733 (2018).Wootters, W. K. Statistical distance and Hilbert space.

*Phys. Rev. D***23**, 357–362 (1981).Margolus, N. & Levitin, L. B. The maximum speed of dynamical evolution.

*Phys. D Nonlinear Phenom.***120**, 188–195 (1998).Helstrom, C. W. Quantum detection and estimation theory.

*J. Stat. Phys.***1**, 231–252 (1969).Staudacher, T. et al. Nuclear magnetic resonance spectroscopy on a (5-nanometer)

^{3}sample volume.*Science***339**, 561–563 (2013).Mamin, H. J. et al. Nanoscale nuclear magnetic resonance with a nitrogen-vacancy spin sensor.

*Science***339**, 557–560 (2013).Aslam, N. et al. Nanoscale nuclear magnetic resonance with chemical resolution.

*Science***357**, 67–71 (2017).Müller, C. et al. Nuclear magnetic resonance spectroscopy with single spin sensitivity.

*Nat. Commun.***5**, 4703 (2014).Balasubramanian, G. et al. Nanoscale imaging magnetometry with diamond spins under ambient conditions.

*Nature***455**, 648–651 (2008).Maze, J. R. et al. Nanoscale magnetic sensing with an individual electronic spin in diamond.

*Nature***455**, 644–647 (2008).Sushkov, A. O. et al. Magnetic resonance detection of individual proton spins using quantum reporters.

*Phys. Rev. Lett.***113**, 197601 (2014).Lovchinsky, I. et al. Nuclear magnetic resonance detection and spectroscopy of single proteins using quantum logic.

*Science***351**, 836–841 (2016).Lovchinsky, I. et al. Magnetic resonance spectroscopy of an atomically thin material using a single-spin qubit.

*Science***355**, 503–507 (2017).Naghiloo, M., Jordan, A. N. & Murch, K. W. Achieving optimal quantum acceleration of frequency estimation using adaptive coherent control.

*Phys. Rev. Lett.***119**, 180801 (2017).Pang, S. & Jordan, A. N. Optimal adaptive control for quantum metrology with time-dependent Hamiltonians.

*Nat. Commun.***8**, 14695 (2017).Gefen, T., Jelezko, F. & Retzker, A. Control methods for improved Fisher information with quantum sensing.

*Phys. Rev. A***96**, 032310 (2017).Yang, J., Pang, S. & Jordan, A. N. Quantum parameter estimation with the Landau-Zener transition.

*Phys. Rev. A***96**, 020301 (2017).Schmitt, S. et al. Submillihertz magnetic spectroscopy performed with a nanoscale quantum sensor.

*Science***356**, 832–837 (2017).Aharon, N. et al. NV center based nano-NMR enhanced by deep learning.

*Sci. Rep.***9**, 17802 (2019).Aharonov, Y., Massar, S. & Popescu, S. Measuring energy, estimating Hamiltonians, and the time-energy uncertainty relation.

*Phys. Rev. A***66**, 052107 (2002).Boss, J. M., Cujia, K. S., Zopes, J. & Degen, C. L. Quantum sensing with arbitrary frequency resolution.

*Science***356**, 837–840 (2017).Neumann, P. et al. Single-shot readout of a single nuclear spin.

*Science***329**, 542–544 (2010).Steiner, M., Neumann, P., Beck, J., Jelezko, F. & Wrachtrup, J. Universal enhancement of the optical readout fidelity of single electron spins at nitrogen-vacancy centers in diamond.

*Phys. Rev. B***81**, 035205 (2010).Unden, T. et al. Quantum metrology enhanced by repetitive quantum error correction.

*Phys. Rev. Lett.***116**, 230502 (2016).Waldherr, G. et al. Dark states of single nitrogen-vacancy centers in diamond unraveled by single shot NMR.

*Phys. Rev. Lett.***106**, 157601 (2011).Aslam, N., Waldherr, G., Neumann, P., Jelezko, F. & Wrachtrup, J. Photo-induced ionization dynamics of the nitrogen vacancy defect in diamond investigated by single-shot charge state detection.

*N. J. Phys.***15**, 013064 (2013).Braunstein, S. L. & Caves, C. M. Statistical distance and the geometry of quantum states.

*Phys. Rev. Lett.***72**, 3439–3443 (1994).Itano, W. M. et al. Quantum projection noise: population fluctuations in two-level systems.

*Phys. Rev. A***47**, 3554–3570 (1993).Schwartz, I. et al. Blueprint for nanoscale NMR.

*Sci. Rep.***9**, 6938 (2019).Glenn, D. R. et al. High-resolution magnetic resonance spectroscopy using a solid-state spin sensor.

*Nature***555**, 351–354 (2018).Bonato, C. et al. Optimized quantum sensing with a single electron spin using real-time adaptive measurements.

*Nat. Nanotechnol.***11**, 247–252 (2016).Chipaux, M. et al. Magnetic imaging with an ensemble of nitrogen-vacancy centers in diamond.

*Eur. Phys. J. D***69**, 166 (2015).Osterkamp, C. et al. Stabilizing shallow color centers in diamond created by nitrogen delta-doping using SF6 plasma treatment.

*Appl. Phys. Lett.***106**, 113109 (2015).

## Acknowledgements

T.G. is thankful to Yosi Atia and Dorit Aharonov for fruitful discussions. A.R. acknowledges the support of ERC grant QRES, project number 770929, grant agreement number 667192 (Hyperdiamond), and the ASTERIQS and DiaPol projects. T.G. is supported by the Adams fellowship of the Israeli Academy of Sciences and Humanities. L.P.M. is supported by an Australian Research Council Future Fellowship (project number FT180100100) funded by the Australian Government. F.J. acknowledges support from ERC Synergy Grant HyperQ, the German Federal Ministry of Education and Research (BMBF), DFG (excellence cluster POLIS and CRC1279), VW Stiftung, and EU via ASTERIQS.

## Funding

Open Access funding enabled and organized by Projekt DEAL.

## Author information

### Authors and Affiliations

### Contributions

F.J., A.R., and T.G. initiated the project. S.S., L.P.M., D.L., N.S., and F.J. carried out the experiments with advice from T.G. and A.R. Analysis and interpretation of the experiments was mainly done by S.S., L.P.M., and T.G. Derivation of the theoretical principles was carried out by T.G., A.R., and L.P.M. C.O., J.L., and M.M. were responsible for sample preparation. The manuscript was written by L.P.M., S.S., and T.G. with input from all the authors.

### Corresponding author

## Ethics declarations

### Competing interests

The authors declare no competing interests.

## Additional information

**Publisher’s note** Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Supplementary information

## Rights and permissions

**Open Access** This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.

## About this article

### Cite this article

Schmitt, S., Gefen, T., Louzon, D. *et al.* Optimal frequency measurements with quantum probes.
*npj Quantum Inf* **7**, 55 (2021). https://doi.org/10.1038/s41534-021-00391-5

Received:

Accepted:

Published:

DOI: https://doi.org/10.1038/s41534-021-00391-5