Identification of molecular quantum states using phase-sensitive forces

Quantum-logic techniques used to manipulate quantum systems are now increasingly being applied to molecules. Previous experiments on single trapped diatomic species have enabled state detection with excellent fidelities and highly precise spectroscopic measurements. However, for complex molecules with a dense energy-level structure improved methods are necessary. Here, we demonstrate an enhanced quantum protocol for molecular state detection using state-dependent forces. Our approach is based on interfering a reference and a signal force applied to a single atomic and molecular ion. By changing the relative phase of the forces, we identify states embedded in a dense molecular energy-level structure and monitor state-to-state inelastic scattering processes. This method can also be used to exclude a large number of states in a single measurement when the initial state preparation is imperfect and information on the molecular properties is incomplete. While the present experiments focus on N\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${}_{2}^{+}$$\end{document}2+, the method is general and is expected to be of particular benefit for polyatomic systems.

T he quantum control of isolated particles forms the basis for recent advancements in quantum computation 1-3 , for precise time and frequency measurements 4,5 , for searches for new physics beyond the standard model 6,7 , for controlled chemistry [8][9][10] and for quantum communication 11,12 .
Recent progress in the quantum control of single trapped molecules [13][14][15][16][17] has enabled the detection 13,15 , coherent manipulation 14,16 and entanglement 17 of molecular quantum states on the singleparticle level. These advances aim at encoding qubits in rotational and vibrational molecular energy states 18,19 and at performing precise spectroscopic measurements 20 with applications including the development of mid-infra-red frequency standards 21 and testing a possible variation of fundamental constants such as the proton-toelectron-mass ratio [22][23][24][25][26] .
Previous studies [13][14][15][16][17] built on prior knowledge of the molecular energy-level structure to engineer level subspaces that enable a precise control on the quantum level. These approaches relied on the entanglement of the internal molecular states with the external motion of a molecular-ion (MI) and atomic-ion (AI) Coulomb crystal 27,28 . The motion was generated by, e.g., applying statedependent forces on the MI 13,15 . The molecular state was then inferred from the excitation amplitude of the MI-AI crystal read out on the AI.
However, for larger and more complex molecules such prior knowledge of the molecular energy-level structure is often not available. Moreover, situations occur, even in comparatively simple diatomic molecules, in which several states that are potentially populated result in similar excitation amplitudes generated by the state-dependent forces such that it is not readily possible to unambiguously distinguish them. Indeed, it can be expected that this is a typical scenario given that molecular-state preparation down to the hyperfine or Zeeman level is currently only feasible for the simplest systems 14,29 .
Here, we enhanced the capabilities of a recently developed method for the quantum-non-demolition readout of molecular states 15,18 . This was achieved by interfering a reference force applied on the AI with the state-dependent force experienced by the MI. By changing the relative phase of the forces, additional information on the molecular state could be obtained, which is not available from only measuring the amplitude of the forces.
Using this method, we experimentally identified specific hyperfine-Zeeman states of a single 14 N þ 2 MI in different excited rotational states of its electronic and vibrational ground state, thus also probabilistically preparing the MI in a specific hyperfine state. We also showed how this method could potentially be used to track the initial and final states during state-changing processes like chemical reactions and inelastic collisions. Finally, we demonstrated a protocol to simultaneously exclude a large subset of rotational levels. This protocol is useful when probing an unknown molecular state within a complex and only partially known energy level structure.

Results
Phase-sensitive forces. Consider a string of two ions, an AI and an MI confined in a linear radiofrequency ion trap (Fig. 1a). The two-ion string exhibits two fundamental motional modes along the trap axis, an in-phase (IP) mode and an out-of-phase mode 30,31 . The ions are superimposed with a running-wave optical lattice generated by two overlapping linearly polarized counterpropagating laser beams with frequency difference Δf. The lattice induces a modulated ac-Stark shift on the ions which results in a state-dependent optical-dipole force (ODF) oscillating at the frequency Δf. When the oscillation frequency of the ODF matches the one of a motional mode (e.g., Δf = f IP for the in-phase mode), the ODF resonantly excites motion in the mode 15,18,32 . This motion can be detected on the AI through sideband thermometry 15,33,34 .
In addition to the ac-Stark shift on the MI, the lattice may induce a non-negligible ac-Stark shift on the AI. Since two ODFs are applied on the crystal simultaneously, the relative phase of the forces will influence the total degree of motional excitation. This phase depends on both the sign of the detuning of the lattice wavelength from spectroscopic resonances in the ions as well as the distance of the ions from each other. The former determines the sign of the ac-Stark shift experienced by the AI and the MI while the latter determines the relative phase of the optical lattice at the positions of the AI and MI.
For the AI, the sign and amplitude of the ac-Stark shift were constant in our experiments because the lattice beams were far detuned (−|Δ a |) from any atomic resonance (Fig. 2a). Here, the minus sign indicates that the lattice beams were red detuned from the nearest transition. On the other hand, for the MI, the amplitude and sign of the induced ac-Stark shift depended on the specific rovibronic, hyperfine and Zeeman state of the MI. Within the frequency range of the optical lattice used in the present experiments, a range of different spectroscopic transitions were accessible ( Fig. 2b) leading to different detunings (±|Δ m |) depending on the exact state of the MI. Figure 1b shows a schematic of two different configurations of forces on the two ions used in our experiment. Since the AI was always red detuned, it always experienced a force in the direction of higher lattice intensity (high-field seeking configuration). For the MI, however, both high-and low-field seeking (blue detuning) scenarios were possible (upper and lower panels in Fig. 1b). The relative phase of the forces was set by controlling the distance between the two ions, d. By placing the two ions at a separation that corresponded to an integer multiple of lattice nodes, d = nλ/2 (n 2 N is an integer number and λ is the wavelength of the lattice lasers), the ions experienced the same intensity gradient from the lattice. We denote this lattice configuration as "same phase" (SP). In the SP scenario, the forces were in the same (opposite) direction when the MI was red (blue) detuned (SP R and SP B in Fig. 1b). By changing the two-ion distance by half a lattice spacing, Δd = ±λ/4, the ions experienced an opposite gradient of the lattice field, i.e., the opposite phase (OP) of the lattice. In the OP lattice configuration, the forces were in the same (opposite) direction when the MI was blue (red) detuned (OP R and OP B in Fig. 1b).
In the case when the forces interfered constructively (same directions), the resulting motional-excitation signal was stronger than in the case of destructive interference (opposite directions). This by itself did not yield information about the sign of the detuning since the ac-Stark shift varied greatly between different states such that a priori the strength of the signal could not be predicted. In order to disentangle the strength and sign of the ac-Stark shift, the SP and OP configurations were compared by varying the two-ion distance and thus obtained both the magnitude and sign of the ac-Stark shift. As the detuning (Δ m ) changes across a resonance in the molecule, the direction of the induced ac-Stark shift (and hence the dipole force) changes while the direction of the shift (and hence the force) on the AI remains constant (Fig. 1c). As will be shown below, this information proves extremely valuable for distinguishing states in a complex energy level structure.
The signed value of the ac-Stark shift, ΔE j , is related to the dynamic molecular polarizability, α j (ω), via ΔE j ¼ À α j ðωÞ 2ε 0 c I (see Methods). Here, the index j specifies the quantum state of the molecule, ε 0 is the vacuum permittivity, c is the speed of light and I ≈ 11.5 W mm −2 is the intensity of a single lattice beam. The AI was used as a probe for the lattice intensity at the position of the AI-MI crystal (see Methods).

Experiment.
A detailed description of our experimental apparatus is given in refs. 15,18 , a schematic representation is shown in Fig. 1a and a brief overview is given in the Methods section.
The relevant energy levels of 40 Ca + and 14 N þ 2 are shown in Fig. 2. With lattice beams linearly polarized and parallel to the magnetic-field direction, the lattice mainly interacted with highlying (nf)F 7/2 (m = −5/2) and (nf)F 5/2 (m = −5/2) levels in Ca + since the AI was prepared in the metastable (3d) 2 D 5/2 (m = −5/2) state. Here, m denotes the magnetic quantum number. Even though the lattice was highly red-detuned from these AI levels (|Δ a | >250 THz), their contribution to the ac-Stark shift was not negligible (see Methods). For N þ 2 , the lattice was nearly resonant with the A 2 Π u ðv 0 ¼ 2Þ X 2 Σ þ g ðv 00 ¼ 0Þ vibronic transition where v 0 ðv 00 Þ denotes the quantum number of the upper (lower) vibrational level of the transition. The detuning was dependent on the exact rotational, fine, hyperfine and Zeeman state of the MI. Figure 2b shows the detuning of the lattice on the P(J″), Q(J″), and R(J″) lines initiating from the two spin-rotation components of the vibronic ground state. Here, J″ is the quantum number of the total molecular angular momentum without nuclear spin of the MI in its X 2 Σ þ g ðv 00 ¼ 0; N 00 ; J 00 ¼ N 00 ± 1=2Þ ground state and P,Q,R stand for spectroscopic branches with ΔJ ¼ J 0 À J 00 ¼ À1; 0; 1.
An ODF pulse was applied to detect the state of the molecule. In this pulse, the lattice lasers were turned on for a duration of 3 ms to excite motion in the crystal. The motional state of the IP mode was subsequently probed on the AI by Rabi sideband thermometry on a blue sideband of the D 5/2 (m = −5/2) → S 1/2 (m = −1/2) transition 33,34 . The frequency and contrast of the resulting Rabi-oscillation signal was proportional to the ODF strength (Methods).
In order to obtain both the sign and the magnitude of the ac-Stark shift experienced by the MI, the Rabi-oscillation experiment

Ion trap
Photon counter objective Fig. 1 Experimental scheme. a A pulsed molecular beam of neutral N 2 molecules traversed the centre of a linear radiofrequency ion trap. A single 14 N þ 2 molecular ion was generated from the molecular beam by photoionization and was trapped together with a single laser-cooled 40 Ca + ion (inset). A running-wave optical lattice generated from two counter-propagating laser beams with frequency difference Δf = f IP was overlapped with the two-ion crystal to excite motion depending on the molecular state. The Ca + ion enabled sympathetic cooling of the N þ 2 ion as well as readout of the common motional state and provided a reference for the phase-dependent method presented here. b Four possible configurations (SP R/B , OP R/B ) of the lattice containing the atomic ion (AI, blue circle) and the molecular ion (MI, orange circles). The direction of the force on the MI (AI) (F m(a) ) was determined by the frequency detuning ±|Δ m(a) | of the lattice laser beams from resonance and the relative positions of the particles in the lattice field. The AI and the MI had either the same signs of detuning (top) or opposite signs (bottom). For an MI at positions SP R and SP B in the lattice, the distance between the two ions was such that they experienced the same phase (SP), while at positions OP R and OP B the ions experienced opposite phases (OP) of the lattice intensity gradient. c The ac-Stark shift, ΔE, experienced by the AI in the (3d) 2 D 5/2 (m = −5/2) (red) and the MI in the X 2 Σ þ g ðv 00 ¼ 0; N 00 ¼ 0Þ (blue) states as a function of lattice wavelength in the region 785-790 nm. The direction of the ac-Stark shift switches sign when changing from negative to positive detuning across a molecular resonance while the ac-Stark shift experienced by the AI remains constant in this wavelength range.
was performed twice. Once with an ion distance of d = nλ/2 where n = 19 and λ ≈ 789 nm corresponding to the SP configuration (f SP IP ¼ 695 kHz) and a second time with the ion distance shifted by Δd = +λ/4 corresponding to the OP configuration (f OP IP ¼ 668 kHz). The configurations were changed by adjusting the voltages on the ion-trap end-cap electrodes. The relative uncertainty in determining the ion-ion distance was estimated to be δd/d = 10 −3 (Methods).
Example of Rabi-oscillation signals from two SP/OP experiments are shown in Fig. 3. The blue-sideband-pulse duration, t 729 , was scanned and averaged 20 times for each data point to retrieve two Rabi-oscillation signals in each experiment, one for the SP (blue) and the other one for the OP (purple) configurations. The frequency and contrast of the Rabi signals were observed to be higher for the SP configuration compared to the OP configuration in Fig. 3a, implying that the ODF and overall motional excitation was stronger for the SP configuration. This indicated that the detuning of the lattice frequency from a molecular resonance was to the red in this experiment (Fig. 1b, upper panel). The resulting Rabi oscillations were fitted to a phenomenological function which was used to extract the amplitude of the ac-Stark shift (Methods). Based on the obtained values for the phase and amplitude, the molecular state could unambiguously be identified as N″ = 6, J″ = 11/2, as illustrated in the following section.
In Fig. 3b, the opposite situation occurred for the same settings of the lattice laser beams. Here, the observed frequency and contrast of the Rabi signals were higher for the OP configuration. This implied that the lattice frequency was blue-detuned from the closest molecular resonance. Below it is shown how based on this observation only, all molecular states with N″ ≤ 4 can be excluded.
Results. Our method applied to the identification of specific spin-rotation and Zeeman levels of N þ 2 molecules in the X 2 Σ þ g ðv 00 ¼ 0Þ electronic and vibrational ground state is exemplified in Fig. 4 with the N″ = 4 and N″ = 6 states. By tuning the lattice-laser wavelength near 789 nm, the detection was sensitive to states originating from the N″ = 4, J″ = 7/2 spin-rotation manifold and induced a significant ac-Stark shift through the Q 12 (7/2) transition at 788.624 nm (red lines in Fig. 4). For these states, the lattice frequency was red detuned with respect to the transition frequency. At the same wavelength, the detection was also sensitive to states originating from the N″ = 6, J″ = 11/2 spin-rotation manifold. These states induced a significant ac-Stark shift through the Q 12 (11/2) transition at 789.1872 nm (blue lines in Fig. 4). For these states, the lattice frequency was blue detuned with respect to the transition frequency.
In the present experiments, molecules in the electronic and vibrational ground state were primarily created in rotational states with N″ ≤ 8 by a rotationally unselective photoionization scheme. In each experiment, the molecules were randomly initialized in one of the 540 corresponding hyperfine Zeeman states. The detection protocol was then applied to extract the amplitude and phase of the ODF signal. In many experiments, the signal was very low, indicating that the state of the molecule was not within the subspace of states which could effectively be traced at the chosen lattice-laser wavelength (examples are shown by the red triangles in the bottom of Fig. 4). However, for some experiments (labelled 1-3 in Fig. 4), the ODF amplitude was large enough indicating that the molecule was either in the N″ = 6, J″ = 11/2 or the N″ = 4, J″ = 7/2 spin-rotational states. The added sign information enabled us to distinguish between these two spin-rotation manifolds (blue and red triangles, respectively). The black square exemplifies an experiment in which the sign information was lacking and, therefore, an unambiguous identification of the molecular state was not possible.
For the experiment marked 1 in Fig. 4, the state was identified as N″ = 4, J″ = 7/2. The measured and the predicted ac-Stark shifts agree within 1σ with only six hyperfine Zeeman states (Table 1). Thus, 534 out of 540 possible states can be excluded for a molecule with N″ ≤ 8. Even if we assume a discrepancy of 2σ between theory and our measured ac-Stark shifts, 528 of the 540 possible states of the molecule can be excluded (Table 1). For the experiment marked 2 in Fig. 4, the state was identified as N″ = 6, J″ = 11/2. Here again, only 6 (12) hyperfine Zeeman states agree with theory within 1σ (2σ), thus excluding 99% (98%) of the possible states ( Table 1).
The experiments marked 3 and 4 in Fig. 4 also show opposite signs at a comparable amplitude. While in experiment 3, the state was identified to be 1 out of 4 (6) hyperfine Zeeman states of the N″ = 6, J″ = 11/2 spin-rotation manifold, experiment 4 was associated with 22 (42) hyperfine Zeeman states of the N″ = 4, J″ = 7/2 and N″ = 8, J″ = 17/2 spin-rotation manifolds (Table 1). These experiments exemplified that using the phase information, it is possible to exclude more than 50% (here~85%) of the states compared to when only the amplitude information is available.
To further illustrate the capabilities of the present statedetection protocol, a state-sensitive chemical reaction experiment was implemented to observe how N þ 2 molecules in a determined state react with H 2 background gas molecules to form N 2 H + . Figure 5 shows the results of such an experiment. An N þ 2 molecule was identified to be in the N″ = 4, J″ = 7/2 spinrotational state (Fig. 5a). The molecule eventually reacted with background gas and turned into N 2 H + . The change of the Solid arrows indicate the possible transitions from a single rotational level (split into two spin-rotation components) of the ground vibronic state. Red (blue) arrows indicates red (blue) detuning of the lattice frequency (dashed green arrow) with respect to the relevant transitions.
Rabi-oscillation signal from panel a to panel b indicated a possible change of the chemical composition of the molecule, which was then verified by mass spectrometry (Methods). Due to the mass change of the crystal in the reaction, the frequency difference of the lattice beams, Δf, had to be adjusted to match the new crystal frequency f SP IP ðN 2 H þ Þ ¼ 690 kHz (Methods). The energy-level structure of N 2 H + is not sufficiently known to be able to clearly identify the molecular quantum state generated in the reaction. However, the phase information indicated that the lattice beams were red detuned from the relevant resonance in the N 2 H + molecule. This experiment exemplifies the basic possibility to perform state-to-state chemical reaction experiments involving polyatomic species. The ability to perform such experiments depends on the lifetime of the product state compared to the time required for state detection.
Following the same principle, inelastic, i.e., state-changing, processes of a single molecule can also be traced. In panels c and d of Fig. 5, the results of such an experiment are shown. An N þ 2 ion in the N″ = 6, J″ = 11/2 spin-rotational state underwent a quantum-jump to a different rotational state as can be seen by the change in the amplitude and phase of the Rabi-oscillation signal. The change of state could have been caused by either an inelastic collision with a background-gas molecule or by the scattering of a photon from the lattice laser 15 . Prior to the quantum jump, the OP configuration showed a stronger signal than the SP configuration while after the collision, the OP configuration showed a weaker signal than the SP configuration. This suggests that the molecule underwent a rotational-state change, most probably to the N″ = 4 state though the low amplitude of the signal does not allow us to unambiguously exclude other rotational or vibrational states. The state of the molecule after the quantum jump could have been tested with higher fidelity by changing the lattice laser frequency to a value at which the assumed state would result in an increased signal amplitude. In this experiment, the interrogation time for state identification was on the order of few seconds. This relatively long interrogation time posed no problem since all states of homonuclear diatomics in the electronic ground state are long-lived. However, this timescale could set a limitation for the state identification of polar molecules in which the rovibrational states typically exhibit shorter radiative lifetimes. This can become important, for example, in a state-to-state reaction experiment in which the product states are short lived or if interaction with black-body radiation scrambles the state populations. In this case, the interrogation time can be reduced by carefully choosing the lattice and AI parameters to maximize the signal and minimize the averaging time. Moving the experiment to a cryogenic environment should also reduce the limitation on the interrogation time.
The experiments presented so far relied on prior knowledge of the strengths and positions of molecular transitions to positively identify specific states of a molecule by comparing the experimentally obtained ac-Stark shift to theory. In a variety of molecules, this information will not be completely available. For the common situation in which only the frequencies of the transitions are known, e.g., from a prediction based on known spectroscopic constants, we propose and demonstrate here an adaption of the present method for partial state readout 35 that can be used to exclude a large subset of molecular states simultaneously and provide a non-destructive spectroscopic signal.
An example is given for the present case of N þ 2 . The positions of all spectral lines belonging to the A 2 Π u ðv 0 ¼ 2Þ X 2 Σ þ g ðv 00 ¼ 0Þ transitions up to N″ = 6 colour coded by rotational state are shown in Fig. 6. As can be seen in the figure, a lattice-laser wavelength larger than 789.4 nm (dashed line) is red-detuned with respect to all transitions with N″ ≤ 4. Therefore, detecting a blue detuning in an SP/OP experiment excludes this entire manifold regardless of its substructure or strengths. In Fig. 3b, a demonstration for this partial state readout is shown. Here, a lattice wavelength of 789.71 nm was used and a stronger OP than SP signal was detected which implied that the lattice was blue detuned to the molecular transition, thus enabling to exclude all states with rotational quantum number N″ ≤ 4 for this molecule.
Conversely, the present protocol can be used as a non-destructive readout for spectroscopic excitations when exciting from a partially known initial state, e.g., N″ ≤ 4 (v″ = 0) to a long-lived excited state with a known detuning with respect to the lattice such as the v 0 ¼ 1 state of the X 2 Σ þ g ground state. For instance, at around 804 nm the lattice laser is blue-detuned from the closest transitions out of v ¼ 1 and one can detect a successful spectroscopic excitation from low rotational states in the vibrational ground state to the first excited vibrational state as a change in the sign of the ac-Stark shift even with no available information about the hyperfine or Zeeman structure of either upper or lower states or the transition strengths. Such an approach will greatly enhance the possibilities for nondestructive spectroscopic experiments in complex molecules.
To conclude, we have demonstrated an experimental protocol for molecular-state detection incorporating both the amplitude and sign of the ac-Stark shift. Using this protocol, Zeeman levels of rotational states of N þ 2 were identified in a region where information about only the amplitude of the ac-Stark shift leads to ambiguity in the state identification. The state identification of hyperfine-spin-rotational levels can also be regarded as a probabilistic state preparation. The hyperfine-state preparation of molecular ions has been a long-standing open problem in molecular physics 29,36 for which the present scheme offers a complementary solution.
The present method was also demonstrated to trace reactive and state-changing collisions of single molecules with partial state selectively. We also showed how the sign information provided by the present method can be used for a partial state determination in situations in which only incomplete spectroscopic information is available on the molecule. The present work thus introduces important new tools towards non-destructive state identification and spectroscopy of complex molecular systems.

Methods
Experimental setup. A molecular-beam machine was coupled to a linear radiofrequency ion trap in which a 40 Ca + AI and a 14 N þ 2 MI were trapped simultaneously (Fig. 1 of the main text). A small magnetic field of 4.6 G defined the quantization axis along the viewing direction of the camera, orthogonal to the trap axis. A continuous-wave (CW) laser beam at 789 nm was split into two paths which were then superimposed on the trapping region in a counter-propagating configuration to form an optical lattice. The polarization of the beams was chosen parallel to the magnetic-field vector. The frequency difference, Δf, between the beam paths was matched to the frequency of the IP motional mode using acousto-optic modulators. Two pulsed dye-laser beams at 202 and 375 nm were used to produce 14 N þ 2 ions by resonance-enhanced multi-photon ionization (REMPI) from the pulsed molecular beam of neutral 14 N 2 molecules 37,38 . The ionization scheme was chosen to create 14 N þ 2 in the lowest rotational levels of the I = 0 or I = 2 nuclearspin isomers (corresponding to levels with even rotational angular momentum quantum numbers N = 0, 2, 4, …) in the electronic and vibrational ground state. We achieved this isomeric selectivity by using a [2 þ 1 0 ] REMPI scheme consisting of two 202 nm photons at 49,426 cm −1 on resonance with the S(0) transition from the rovibronic ground-state (N = 0) in neutral 14 N 2 . Therefore, the I = 1 isomer, with its lowest rotational state N = 1 was excluded from the ionization. Two CW lasers at 397 and 866 nm were used for Doppler laser cooling of Ca + , and another two laser beams at 729 and 854 nm were used for resolved-sideband cooling and coherent state manipulation. The numbers in the first column correspond to the labels shown in Fig. 4. The second column indicates the level of agreement between experiment and theory for the given state (for experiment 4, only states within 1σ agreement are given. An additional 20 × 2 states within 2σ agreement are omitted). N″, J″, I″, F″ and mJ″/F″ stand for the rotational, spin-rotational, nuclearspin, hyperfine and magnetic quantum numbers of N in the electronic and vibrational ground state.
Our experimental procedure was described in detail in refs. 15,18 . Approximately ten Ca + ions were loaded into the trap and Doppler cooled on the (4s) 2 S 1/2 ↔ (4p) 2 P 1/2 ↔ (3d) 2 D 3/2 closed optical cycling transitions to form a string of Coulomb-crystallized ions. A single N þ 2 ion was then loaded into the trap using REMPI. The appearance of a dark ion in the string signalled the sympathetic cooling of a molecule. By lowering the trap depth, Ca + ions were successively ejected from the trap until a Ca + -N þ 2 two-ion string remained. The ions were cooled to the motional ground state of the IP motional mode by resolved sideband cooling on the (3d) 2 D 5/2 (m = −5/2) ← (4s) 2 S 1/2 (m = −1/2) transition of Ca + followed by quenching the D 5/2 state to the S 1/2 level through the (4p) 2 P 3/2 state and optical pumping back to the S 1/2 (m = −1/2) state. To prepare the Ca + ion in the metastable D 5/2 (m = −5/2) state, we used a π-pulse on the narrow D 5/2 (m = −5/2) ← S 1/2 (m = −1/2) transition followed by a state-purification pulse 14,15 . The state-purification pulse projected the Ca + either to the D 5/2 (m = −5/2) or the S 1/2 state with a heralded signal (photon scattering) that allowed us to exclude experiments with improper state preparation. We chose the D 5/2 (m = −5/2) level due to its reduced ac-Stark shift compared to the S 1/2 state which would have overwhelmed the molecular signal.
Phase-sensitive forces. In ref. 15 , we used a similar type of force-spectroscopic method to the one presented here. In that work, we employed a smaller lattice-laser detuning from a specific, well known resonance in N þ 2 prepared in a specific quantum state and consequently required a smaller lattice-laser intensity and duration compared to the present study. Under these conditions, small effects such as the contribution of the ODF on Ca + to the motional excitation, the effects of fardetuned molecular resonances including other electronic transitions and the influence of the polarizability of the N þ 2 core electrons on the excitation strength could be neglected.
For the objectives of the present work, i.e., the determination of an initially unknown quantum state of the molecule, larger detunings from molecular resonances and consequently higher laser intensity and duration were necessary. Here, we give a more complete account of phase-sensitive force spectroscopy that includes the effect of the lattice on both the atomic and the molecular ions.
Normal modes of the system. The derivation of the normal modes of a Coulomb crystal of two ions with unequal masses in a harmonic trap is described in refs. 30,31 . Here, we only give the final results and definitions which will be used later in the extraction of the molecular ac-Stark shift from the experimental signal.
The present system is composed of two ions, a molecular ion with mass m 1 = 28 a.u. and an atomic ion with mass m 2 = 40 a.u. The ions are confined in a harmonic potential characterized by a spring constant, u 0 , such that the frequency of a single particle is given by Here, the subscripts i = 1, 2 refer to the molecular ion and the atomic ion, respectively.
When both ions are trapped together, they form a crystal due to the balance between their Coulomb repulsion, F c ¼ À e 2 =4πε 0 r 2 12 , and the harmonic confinement of the trap. Here, e is the electron charge, ε 0 is the vacuum permittivity and r 12 is the separation between the two ions. The distance between the equilibrium positions, x 0 i , of the ions in the crystal is given by By measuring the trap-oscillation frequency of a single atomic ion, ω 2 , with relative uncertainty δω 2 /ω 2 < 10 −3 , the distance d can be calculated with a similar accuracy.
At the motional-excitation amplitudes reached in the present experiments, the ions performed only small oscillations around their equilibrium positions, i , such that it is safe to keep only harmonic terms in an expansion of the potential. The displacements of the individual particles, however, do not correspond to the normal modes of the system. To transform to a normal-mode   showing the positions of the allowed P, Q and R transitions of the A 2 Π u ðv 0 ¼ 2Þ X 2 Σ þ g ðv 00 ¼ 0Þ band of N þ 2 originating from the rotational levels N″ = 0 (red), 2 (magenta), 4 (orange) and 6 (blue). A subset of these states can be excluded by determining the effective detuning at specific lattice wavelengths using an SP/OP experiment. The dotted, dashdotted and dashed lines show the lattice wavelengths that enable the exclusion of rotational states N″ = 0, N″ ≤ 2 and N″ ≤ 4. The detuning can be chosen either blue of the transitions (782.6, 782.1 and 781.6 nm to exclude N″ = 0, N″ ≤ 2 and N″ ≤ 4 respectively) or red (787.5, 788.2 and 789.4 nm to exclude N″ = 0, N″ ≤ 2 and N″ ≤ 4). By choosing the detuning opposite to the detuning of an excited state of interest, the initial and final states are easily distinguishable in an SP/OP test with no available information about the hyperfine or Zeeman structure of either upper or lower states or the specific transition strengths.
basis, scaling and rotation transformations given by were performed. Here, β ± are the in-phase (−) and out-of-phase (+) normal-mode displacements, θ is a rotation angle where tanðθÞ ¼ 1= ffiffi ffi μ p À ffiffi ffi μ p þ ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 1=μ þ μ À 1 p and μ = m 2 /m 1 . In the normal-mode picture, the system is equivalent to an ion of mass m 2 trapped in a 2D harmonic potential with two uncoupled mode frequencies, Note that a change of one unit in the mass of the molecular ion (as in the case of the chemical reaction described in Fig. 5 of the main text) corresponds to a relative change of the in-phase mode frequency of δΩ − /Ω − ≈ 6 × 10 −3 , which can readily be detected in the present experiments.
Lattice excitation of the normal modes. The optical lattice induces a modulated ac-Stark shift on both the atomic and molecular ion, Here, ΔE 0 i is the ac-Stark shift induced by a single lattice beam, Δω = 2πΔf is the difference in angular frequency of the lattice-laser beams, k = 2π/λ is the latticelaser k-vector and λ ≈ 789 nm is the lattice-laser wavelength. The phase, ϕ 0 i ¼ 2kx 0 i , depends on the equilibrium positions of the particles. In the SP configuration, the phase difference between the two particles, ϕ 0 21 ¼ ϕ 0 2 À ϕ 0 1 ¼ 2kd SP ¼ 2πn (n an integer), is such that the phase of the lattice is equal for both particles. In the OP configuration, ϕ 0 21 ¼ 2kd OP ¼ 2πðn þ 1=2Þ, and the particles experience opposite phases of the lattice intensity gradient (Fig. 1b of the main text). An additional phase difference is attributed to the sign of the ac-Stark shift, ± jΔE 0 i j, which depends on the detuning of the lattice-laser frequency with respect to a dominant resonance in the relevant particle.
To get an intuition on how the ODF on the molecular ion and the atomic ion affect the excitation of the in-phase mode of the crystal, we first expand Eq. (4) in a Taylor series around the equilibrium positions and neglect constant terms of the potential which do not exert any force, In this approximation, the lattice exerts an oscillating spatially homogeneous force with an amplitude F i ¼ 4kΔE 0 i on particle i. In the case of a single particle, this force will lead to coherent excitation of motion in the trap. In the case of two ions with unequal masses, the ac-Stark shift resulting in the driving of the in-phase mode can be obtained using Eq. (2), Here, the ± sign corresponds to the SP and OP configurations, respectively, and ΔE 0 À defines the single-beam ac-Stark shift of the in-phase mode. Thus, the two forces exerted by the lattice on the two ions are combined to a single effective force on the in-phase mode with an amplitude, F À ¼ 4kΔE 0 À . This force will lead to coherent excitation of the in-phase mode of the two-ion crystal. In this analytical derivation, higher order terms of the lattice potential were neglected, which lead to squeezing of the motional states and to mixing of the in-phase and out-of-phase modes. In the data analysis, we used a classical simulation of the two-ion system to account for high-order terms in the lattice excitation 15,18 .
By measuring the in-phase motional excitation amplitude both in the SP (jΔE 0 À ðSPÞj) and in the OP configuration (jΔE 0 À ðOPÞj), the amplitude of the ac-Stark shift, jΔE 0 m j, exerted by the lattice on the molecule can be determined, under the assumption that jΔE 0 m j > jΔE 0 a j. The phase of the ac-Stark shift is inferred from the relative amplitudes obtained in the SP and OP measurements assuming that the sign of the ac-Stark shift on the atomic ion is negative.
Ac-Stark shift of Ca + . The ac-Stark shift, ΔE j , of a level j in Ca + is given by where ε 0 is the vacuum permittivity, c is the speed of light, I the laser intensity, and α j (ω) the dynamic polarizability of level j which is given by Here, α j s ðωÞ and α j t ðωÞ are the scalar and tensor dynamic polarizabilities of level j, Θ is the angle of linear polarization (Θ = 0 for π-polarized light) and J j and m j are the quantum numbers of the total angular momentum and its projection.
The (4s) 2 S 1/2 state of Ca + has only a scalar contribution to the polarizability which results in α S (ω) = 97.5 a.u. 39 for a lattice laser wavelength of 789.0 nm. The (3d) 2 D 5/2 (m = −5/2) state of Ca + has both scalar and tensor contributions to the polarizability. With linearly π-polarized light, this state interacts only with high lying F states. The contribution of these states to the polarizability decays rather slowly such that all states up to the continuum need to be taken into account 39 . The polarizability of this state results in, α D (ω) = 4.44 a.u. 39 at a latticelaser wavelength of 789.0 nm. Small uncertainties in the linear lattice polarization at the level of 1 ∘ amount to~1% error in the D-state polarizability.
The low polarizability of the (3d) 2 D 5/2 (m = −5/2) state with linearly polarized light is comparable to the polarizability of the core electrons, α D;core ¼ 3:03 a.u. 39 for this state. The core contribution is almost identical in the (3d) 2 D 5/2 and the (4s) 2 S 1/2 states (α S;core ¼ 3:134 a.u. 39 in the S state). Therefore, in a spectroscopic experiment on the 2 D 5/2 (m = − 5/2) ← 2 S 1/2 (m = −1/2) transition, the measured ac-Stark shift has contributions mostly from the polarizability of the valence electron in both states, However, in a lattice-excitation experiment, the contribution to the ac-Stark shift from the atomic ion is due to both the core and valence electrons in the relevant state, Ac-Stark shift calibration. The amplitude of the ac-Stark shift was determined from the Rabi-oscillation data (see, e.g., Fig. 3 of the main text) by comparison to a calibration experiment. In this calibration, the Ca + -N þ 2 Rabi-oscillation signal was simulated by exciting motion on a two-ion Ca + -N 2 H + string with a well-defined ac-Stark shift amplitude applied on the atomic ion 15 . We used an N 2 H + molecular ion for convenience due to its longer chemical lifetime. The mass difference of 1 u between N þ 2 and N 2 H + amounts to only a small correction compared to other experimental errors.
In the calibration experiment, Ca + was prepared in the ð4sÞ 2 S 1=2 m ¼ À1=2 ð Þ state due to its large polarizability that allowed us to tune the desired ac-Stark shift. The ac-Stark shift was calibrated by a spectroscopic measurement on the Þtransition of Ca + and varied by changing the lattice-laser power. Six different ac-Stark shifts in the range 0.8−4.6 kHz were applied for generating the calibration data. The spectroscopically measured shifts were the combined shifts of both spectroscopic levels (Eq. (10)). However, since the lattice excitations were preformed in the 2 S 1=2 m ¼ À1=2 ð Þ state only, the 2 D 5=2 m ¼ À5=2 ð Þcontribution (Eq. (11)) was subtracted. Subsequently, a lattice-excitation experiment was performed in which the ODF was applied for 3 ms with well-defined shifts on the Ca + -N 2 H + system so that a Rabi-oscillation signal was obtained for each applied ac-Stark shift (Fig. 7). We used these Rabi-oscillation signals as a reference for the ac-Stark shift amplitudes generated in the experiments described in the main text. In order to extract the amplitude from Rabi-oscillation data with unknown ac-Stark shift, an interpolation between the six calibrated ac-Stark shifts was performed using a single parameter (the ac-Stark shift) fitting function (see details in the supplementary materials of ref. 15 ).
Another advantage of using N 2 H + as opposed to N þ 2 for the calibration experiment besides the longer lifetime is that it has no strong transitions near 789 nm that could interfere with the calibration. There is, however, a residual force on the N 2 H + due to highly detuned transitions in the molecule that must be taken into account (compare Fig. 5b and the associated discussion in the main text). Since the ac-Stark shift on N 2 H + , ΔE N 2 H þ is small compared to the Ca + shift, ΔE Ca þ , in the (4s) 2 S 1/2 (m = −1/2) state, it was neglected to first order. This zero-order fitting function was then used to extract the ac-Stark shift of N 2 H + (Fig. 5). An approximate value of ΔE N 2 H þ ¼ À0:81 kHz was obtained corresponding tõ 15.8% of ΔE Ca þ ¼ 5:41 kHz measured with the same power. This shift was then added to the calibration data for a more realistic fitting function which now includes the total shift from both Ca + and N 2 H + . This procedure was iterated for a first-order estimate of the ac-Stark shift of N 2 H + . The first iteration changed the measured shift to ΔE N 2 H þ ¼ À0:93 kHz corresponding to~18.1% of ΔE Ca þ . The second iteration yielded ΔE N 2 H þ ¼ À0:99 kHz corresponding to~18.5% of ΔE Ca þ . Thus, any residual error in the fitting function after the second iteration was neglected. Figure 7 shows the results of the calibration experiments accounting for the effect of N 2 H + excitation. The Ca + and N 2 H + shifts were added together to produce the effective shift as indicated in the figure legend since the lattice was red detuned for both the atomic and molecular ions and the calibration was preformed in the SP R configuration (Fig. 1b of the main text).
Ac-Stark shift of N þ 2 including hyperfine structure. The lattice-laser beam induced an ac-Stark shift on the molecular ion according to Eq. (8). This shift was calculated by summing up the contributions of the different transitions in the rovibrational band A 2 Π u ðv 0 ¼ 2Þ X 2 Σ þ g ðv 00 ¼ 0Þ, Here, ℏ is the reduced Planck constant, ω jk are the transition angular frequencies 40 and |〈k|μ|j〉| 2 is the squared transition-dipole matrix element calculated using a spherical-tensor-algebra approach 41 using the value of the vibronic Einstein A coefficient taken from ref. 42 . Here, the ground state j is the X 2 Σ þ g ðv 00 ¼ 0Þ vibronic state of N þ 2 which is adequately described by a Hund's case (b) coupling scheme. The excited state k is the A 2 Π u ðv 0 ¼ 2Þ vibronic state described by an intermediate Hund's case (a)/Hund's case (b) coupling scheme 43 . Hyperfine effects are included in the calculation of the dipole matrix element. The effect of mixing of states with different total angular momentum quantum number J by hyperfine interactions 44 should only have a small effect on the ac-Stark shifts and was therefore not included in the calculations.
The contribution of additional vibrational bands in the A 2 Π u ðv 0 ≠ 2Þ excited state and of the B 2 Σ þ u ðv 0 Þ electronic state were included. Here, due to the large detuning, only the rotationless transition frequencies were used 45 . The corresponding Einstein A coefficients were also taken from ref. 45 .
The core polarizability of N þ 2 was estimated from a calculation of the polarizability of N 2þ 2 . The calculation was performed using Gaussian 09 (ref. 46 ) at the CCSD/aug-cc-pVQZ level of theory. The value of the polarizability was found to be α N þ 2 ;core % α N 2þ 2 ¼ 7:23 a.u. which corresponds to an ac-Stark shift of −390 Hz at our experimental parameters.

Data availability
The data that support the findings of this study have been deposited in Zenodo with the identifier DOI: https://doi.org/10.5281/zenodo.3898047.