Introduction

The implementation of quantum computing and quantum information processing require a careful preparation of the initial quantum state and accurate control of its further evolution in time. There is a large body of literature dealing with coherent control in quantum systems. A widely known technique relies on resonant π (or π/2) pulses1. It has the advantage of being fast but turns out to be very sensitive to the pulse duration and peak intensity. Alternatively, the composite pulses approach provide a much more robust quantum manipulation but at the expense of a relatively slow process. It requires a precise control of the relative phase of the successive pulses and on the intensity of each pulse2,3,4,5. Another fast and efficient technique is the optimal control theory6,7,8,9,10,11. However, the optimization may be complicated since it can require a huge number of parameters. On a more analytical and geometric side, the development of the quantum brachistochrone formalism, formulated by using the Pontryagin Maximum Principle (PMP), belongs to the same class of solutions12. Otherwise, purely numerical techniques have been setup for quantum manipulation using for instance genetic algorithm13. Nevertheless, the purely numerical algorithm for optimization works as a black box without understanding the dynamics or knowing the structure of control fields.

Adiabatic processes have been also successful, and in particular the RAP (rapid adiabatic passage)14 for two-states systems, or the STIRAP technique in three-state systems15,16,17. In essence, such techniques are developed so to ensure the adiabatic condition. This means in practice long pulse duration combined with high peak intensity. Interestingly, they can be stated so to generate smooth variations of the parameters in time.

In this article, we setup another strategy inspired by the recent development of “Shortcuts to Adiabaticity” (STA)18,19. In contrast with adiabatic processes, non-adiabatic coupling are canceled out using well-tailored supplementary fields20. Here we will concentrate on a subclass of such solutions usually referred to as reverse engineering protocols21. Such techniques have been recently applied to the fast transport or manipulation of wave functions22,23,24,25, or in tailored transformations in statistical physics26,27,28. The reverse engineering protocol consists in imposing the desired evolution of the dynamical quantity of interest and inferring from it the time evolution of the parameters. Remarkably, reverse engineering protocols can be worked out analytically, see also refs29,30, Its performance when combined with a given constraint has been compared with optimal control in ref.27. They provide an efficient way to drive spin-1/2 system31,32, or, equivalently, a generic two-level system with cold atoms33,34,35.

The shaping of the three components of the time-dependent magnetic field that one shall apply to induce an arbitrary trajectory on the Bloch sphere of a single spin 1/2 has been explicitly worked out in ref.36. Interestingly, the equation of motion of the mean value of the spin cannot be reversed in an unique manner. It means in practice that there is a lot of freedom to reach a given target state and to fulfill also some extra requirements. We will take advantage of this feature in the following. In this article, we setup (i) a few general procedures for reverse engineering, (ii) an algorithm to build up the smooth variations in time of the magnetic field components that one should apply to spin flip a spin 1/2 (or connect two points on the Bloch sphere) in an arbitrary short amount of time, (iii) expand the parameter space of those solutions to fulfill extra requirements such as the robustness of the operation or the application of the transformation to two spins with different coupling strength to the magnetic field. We then discuss how those protocols shall be modified to take into account interactions between spins, and generate in an optimal amount of time entangled states of two or more spins.

Results

Reverse engineering protocols for a single spin

In the reverse engineering approach, the magnetic field components as a function of time are inferred from the equations of evolution of the system once the desired quantum state change, suitably parametrized, is imposed. In practice, it can be useful to have different formulations of the same problem since the inversion37 or the generalization to higher dimension can be easier for one of them. Those ideas have a wide range of possible applications in various systems, including spin system38,39,40, Bose-Einstein condensates (BECs)41,42, and other many-body systems43,44,45.

Hereafter, we propose to work out such an inversion with three different formulations of a spin 1/2 in a time-dependent magnetic field: (i) the direct reversing of the time evolution operator, (ii) the inversion of Madelung representation formulation of the problem and (iii) the inversion of the precession equations. This is a non exhaustive list. For instance, another common method for reverse engineering relies on dynamical invariant33, and will be used in last subsection before discussion.

Inverting the time evolution operator

We consider a spin 1/2 in an initial state \(|\psi \mathrm{(0)}\rangle \). Its time evolution is encapsulated in the evolution operator U(t): \(|\psi (t)\rangle =U(t)|\psi \mathrm{(0)}\rangle \). The most general form for U is a 2 × 2 complex matrix whose coefficients are partially related to ensure its unitary property. Denoting \({u}_{ij}={\rho }_{ij}{e}^{i{\phi }_{ij}}\), the coefficients of U shall fulfill the following relations \({\phi }_{12}={\phi }_{21}\equiv \phi \), \({\rho }_{12}={\rho }_{21}\equiv \rho \), \({\rho }_{11}={\rho }_{22}\equiv r\) and \({\phi }_{11}+{\phi }_{22}=2\phi +\pi \). The most general form of U therefore reads

$$U(t)=(\begin{array}{ll}r{e}^{i{\phi }_{11}} & \sqrt{1-{r}^{2}}{e}^{i\phi }\\ \sqrt{1-{r}^{2}}{e}^{i\phi } & r{e}^{i\mathrm{(2}\phi +\pi -{\phi }_{11})}\end{array}),$$
(1)

where the variables r, \({\phi }_{11}\) and φ are time-dependent. The reverse engineering protocol consists in shaping in time the three variables r, \({\phi }_{11}\) and φ to ensure the transformation \(|\psi \mathrm{(0)}\rangle \to |\psi ({t}_{f})\rangle =|{\psi }_{{\rm{target}}}\rangle \). The Schrödinger equation \(i\hslash {\partial }_{t}|\psi (t)\rangle =H|\psi (t)\rangle \) implies that \(H=i\hslash \dot{U}{U}^{\dagger }\). The expansion of H on the Pauli matrices \({\sigma }_{i}\) (\(i=x,y,z\)) gives the time-dependent magnetic field components that should be implemented in order to follow the desired trajectory: \(H=-{\gamma }_{1}{{\bf{s}}}_{1}\cdot {\bf{B}}(t)=-{\gamma }_{1}\hslash \sigma \cdot {\bf{B}}(t)/2\) with

$$\begin{array}{c}{B}_{x}(t)=-\frac{2}{{\gamma }_{1}}\frac{r\mathrm{(1}-{r}^{2})\dot{{\rm{\Phi }}}\,\cos \,{\rm{\Phi }}+\dot{r}\,\sin \,{\rm{\Phi }}}{\sqrt{1-{r}^{2}}},\\ {B}_{y}(t)=-\frac{2}{{\gamma }_{1}}\frac{r\mathrm{(1}-{r}^{2})\dot{{\rm{\Phi }}}\,\sin \,{\rm{\Phi }}-\dot{r}\,\cos \,{\rm{\Phi }}}{\sqrt{1-{r}^{2}}},\\ {B}_{z}(t)=-\frac{2}{{\gamma }_{1}}\dot{{\rm{\Phi }}}{r}^{2},\end{array}$$

where γ 1 is the gyromagnetic factor and \({\rm{\Phi }}=\phi -{\phi }_{11}\) the relative phase. We conclude that only two parameters are relevant in this case r(t) and Φ(t). This form generally contains the particular results deduced from other methods such as the tracking transitionless algorithm and the dynamical invariant approach18, see also refs29,30.

As a simple example, let’s work out the simplest form of the magnetic field components to ensure the spin flip of the spin. The wave function reads \(|\psi (t)\rangle =r(t){e}^{i{\phi }_{11}(t)}|+\rangle +\sqrt{1-{r}^{2}(t)}{e}^{i\phi (t)}|-\rangle \), where |+〉 are the eigenstates of σ z with eigenvalues ±1, corresponding to the spin up and down. To ensure the spin flip from |+〉 to |−〉 in an amount of time t f , we need to fulfill the following boundary conditions, \(r\mathrm{(0)}=1\) and \(r({t}_{f})\,=\,0\). To avoid the divergence of denominators, we choose Φ = 0 and \(r(t)=\cos (\theta (t))\) with \(\theta \mathrm{(0)}=0\) and \(\theta ({t}_{f})\,=\,\pi /2\). We find \({B}_{x}=0\) and \({B}_{z}=0\), and a solution that contains the famous π-pulse solution with a constant magnetic field \({B}_{y}^{0}=\pi /({\gamma }_{1}{t}_{f})\). The general method that we have worked out enables one to have any type of final state, including superposition of states.

Inverting the Madelung representation formulation

Another strategy consists in using an exact semiclassical approach based on the phase-modulus equations, commonly referred to as the Madelung representation. To derive the corresponding set of coupled equations we start by introducing the general form \(|\psi (t)\rangle =a(t)|+\rangle +b(t)|-\rangle \) into the Schrödinger equation in the presence of a time-dependent magnetic field:

$$i\hslash \dot{a}=-\frac{{\gamma }_{1}}{2}\hslash (a{B}_{z}+b{B}_{x}-ib{B}_{y}),$$
(2)
$$i\hslash \dot{b}=-\frac{{\gamma }_{1}}{2}\hslash (a{B}_{x}-b{B}_{z}+ia{B}_{y})\mathrm{.}$$
(3)

Let’s rewrite the coefficients a and b in modulus-phase representation \(a(t)=\sqrt{{n}_{a}(t)}{e}^{i{\phi }_{a}(t)}\), \(b(t)=\sqrt{{n}_{a}(t)}{e}^{i{\phi }_{b}(t)}\). The two previous complex equations can be recast as a Hamiltonian problem for the conjugate variables \(({n}_{a},{\phi }_{a})\) and \(({n}_{b},{\phi }_{b})\): \({\dot{n}}_{i}=-{\partial }_{{\phi }_{i}}H\), \({\dot{\phi }}_{i}={\partial }_{{n}_{i}}H\) with (\(i=a,b\)). It is convenient to introduce the relative variables \({{\rm{\Delta }}}_{n}(t)={n}_{a}(t)-{n}_{b}(t)\) and \(\theta (t)={\phi }_{a}(t)-{\phi }_{b}(t)\). The expression of the Hamiltonian now reads

$$H={\gamma }_{1}{B}_{z}{{\rm{\Delta }}}_{n}\mathrm{/2}+\sqrt{1-{{\rm{\Delta }}}_{n}^{2}}({B}_{x}\,\cos \,\theta -{B}_{y}\,\sin \,\theta ),$$
(4)

and the dynamics is given by the two scalar equations

$${\dot{{\rm{\Delta }}}}_{n}={\gamma }_{1}\sqrt{1-{{\rm{\Delta }}}_{n}^{2}}({B}_{x}\,\sin \,\theta +{B}_{y}\,\cos \,\theta ),$$
(5)
$$\dot{\theta }={\gamma }_{1}[{B}_{z}-\frac{{{\rm{\Delta }}}_{n}}{\sqrt{1-{{\rm{\Delta }}}_{n}^{2}}}({B}_{x}\,\cos \,\theta -{B}_{y}\,\sin \,\theta )]\mathrm{.\ \ \ }$$
(6)

From the evolution of \({{\rm{\Delta }}}_{n}\) and \(\theta \), we can infer the components of the magnetic field. For instance,

$$\begin{array}{c}{B}_{x}(t)=\frac{{\dot{{\rm{\Delta }}}}_{n}}{{\gamma }_{1}\sqrt{1-{{\rm{\Delta }}}_{n}^{2}}\,\sin \,\theta },\\ {B}_{y}(t)=\mathrm{0,}\\ {B}_{z}(t)=\frac{1}{{\gamma }_{1}}(\dot{\theta }+\frac{{\dot{{\rm{\Delta }}}}_{n}{{\rm{\Delta }}}_{n}}{1-{{\rm{\Delta }}}_{n}^{2}}\frac{\cos \,\theta }{\sin \,\theta })\mathrm{.}\end{array}$$

Inverting the precession equation

Alternatively, we can work out the equations of motion for the mean value of the spin

$$\frac{{\rm{d}}\langle {{\rm{s}}}_{1}\rangle }{{\rm{d}}t}=\frac{1}{i\hslash }\langle [{{\rm{s}}}_{1},H]\rangle ={\gamma }_{1}\langle {{\rm{s}}}_{1}\rangle \times {\rm{B}}(t\mathrm{).}$$
(7)

In the following, we note \({{\rm{S}}}_{1}\,=\,2\langle {{\rm{s}}}_{1}\rangle /\hslash \) and use the spherical coordinates to describe the motion of the spin on the Bloch sphere: \({{\rm{S}}}_{1}(\sin \,\theta (t)\cos \,\phi (t),\,\sin \,\theta (t)\sin \,\phi (t),\,\cos \,\theta (t))\). To work out our reverse protocol, we calculate the left-hand side of precession equations (7)

$${\dot{S}}_{1x}=\dot{\theta }\,\cos \,\theta \,\cos \,\phi -\dot{\phi }\,\sin \,\theta \,\sin \,\phi ,$$
(8)
$${\dot{S}}_{1y}=\dot{\theta }\,\cos \,\theta \,\sin \,\phi +\dot{\phi }\,\sin \,\theta \,\cos \,\phi ,$$
(9)
$${\dot{S}}_{1z}=-\dot{\theta }\,\sin \,\theta \mathrm{.}$$
(10)

Combining Eqs (8)–(10), we get

$$\dot{\theta }={\gamma }_{1}({B}_{y}\,\cos \,\phi -{B}_{x}\,\sin \,\phi ),$$
(11)
$$\dot{\phi }={\gamma }_{1}[{B}_{z}-\,\cot \,\theta ({B}_{x}\,\cos \,\phi +{B}_{y}\,\sin \,\phi )],$$
(12)

from which we infer the expression of the transverse magnetic field components. With this set of equations we already obtain a class of solution by setting \({B}_{x}={B}_{z}\,=\,0\) and φ = 0, we find \(\dot{\theta }={\gamma }_{1}{B}_{y}\). The reverse engineering protocol consists here in choosing for θ(t) a function that obeys the boundary conditions \(\theta \mathrm{(0)}\,=\,0\) and \(\theta ({t}_{f})=\pi \), and to infer from it the expression for B y (t). We can readily recover here also the π-pulse solution.

It is interesting to let the possibility to shape any curve on the Bloch sphere36. For this purpose, we need non trivial dependence of both θ(t) and φ(t). However, as suggested by Eqs (11) and (12), we can engineer only transverse magnetic field components and impose the variation of the longitudinal magnetic field component. This choice amounts to using explicitly the non uniqueness of the solution. The solution is then quite simple, we set the evolution of θ(t), φ(t) and \({B}_{z}(t)\) according to our boundary conditions. We have to be careful since we need to avoid divergences. This means that we have to take care of the terms having a tanθ. This latter terms diverge for \(\theta =\pi \mathrm{/2}\), at time \(t={t}^{\ast }\) for which \(\theta ({t}^{\ast })=\pi \mathrm{/2}\). To compensate for this divergence, we have to cancel also \(\dot{\phi }({t}^{\ast }\mathrm{)=0}\) and \({B}_{1z}({t}^{\ast })\,=\,0\). A way out for the last term consists in choosing \({B}_{1z}(t)={B}_{0}\,\cos (\theta (t))\). The set of equations (11) and (12) then reads

$${B}_{x}=-\frac{\dot{\theta }}{{\gamma }_{1}}\,\sin \,\phi -\frac{\dot{\phi }}{{\gamma }_{1}}\,\tan \,\theta \,\cos \,\phi +{B}_{0}\,\sin \,\theta \,\cos \,\phi ,$$
(13)
$${B}_{y}=\frac{\dot{\theta }}{{\gamma }_{1}}\,\cos \,\phi -\frac{\dot{\phi }}{{\gamma }_{1}}\,\tan \,\theta \,\sin \,\phi +{B}_{0}\,\sin \,\theta \,\sin \,\phi \mathrm{.}$$
(14)

Consider the following example, we want to spin flip the spin from |+〉 to |−〉 in an amount of time \(t={t}_{f}\). For convenience, we use in the following the dimensionless time \(s=t/{t}_{f}\). We use the boundary conditions \(\theta \mathrm{(0)}=0\) and \(\theta \mathrm{(1)}=\pi \). The simplest polynomial interpolation between those two boundary conditions is \(\theta (s)=\pi s\). In this case, \({s}^{\ast }\,=\,\mathrm{1/2}\). The boundary conditions for φ are therefore \(\phi \mathrm{(0)}=0\), \(\phi \mathrm{(1)}=0\) and \(\dot{\phi }\mathrm{(1/2)}=0\). We choose here a polynomial ansatz \(\phi (s)=s-{s}^{2}\) to fulfill those conditions. Equations (13) and (14) take then the simple form

$${B}_{x}=-\frac{\pi }{{\gamma }_{1}{t}_{f}}\,\sin \,(s-{s}^{2})-\frac{1-2s}{{\gamma }_{1}{t}_{f}}\,\tan \,(\pi s)\,\cos \,(s-{s}^{2})+{B}_{0}\,\sin \,(\pi s)\,\cos \,(s-{s}^{2}),$$
(15)
$${B}_{y}=\frac{\pi }{{\gamma }_{1}{t}_{f}}\,\cos \,(s-{s}^{2})-\frac{1-2s}{{\gamma }_{1}{t}_{f}}\,\tan \,(\pi s)\,\sin \,(s-{s}^{2})+{B}_{0}\,\sin \,(\pi s)\sin \,(s-{s}^{2})\mathrm{.}$$
(16)

Figure (1a and b) provide respectively the evolution of the components of the magnetic field and of the spin. The choice of smooth polynomial ansatz for the reverse engineering protocol generates a smooth solution. As intuitively expected, the shorter t f , the larger the variation. This feature can be seen directly on Eqs (15) and (16) through the 1/t f , factors.

Figure 1
figure 1

(a) Evolution of the magnetic field components \({B}_{z}/{B}_{0}\) (solid line), \({B}_{y}/{B}_{0}\) (dashed line) and \({B}_{x}/{B}_{0}\) (dotted line) as a function of time. The shaping of the magnetic field components is obtained self-consistently from a reverse engineering protocol in which we impose the variations of the spin components according to the target state (spin flip in this case) and the time duration of the transformation. (b) Spin components S 1z (solid line), S 1y (dashed line) and S 1x (dotted line) as a function of time. Parameters: \({\tilde{\gamma }}_{1}(\equiv {\gamma }_{1}{t}_{f})=2\), \({B}_{0}=1\).

In conclusion of this subsection, we have shown that different formulations of the same problem yield different class of solutions. Within a given formulation, there is an infinitely large number of solutions for given boundary conditions. Those observations are useful to setup protocols for which we can add more constraints.

In the following, we discuss the simultaneous spin flip of two spin having different gyromagnetic factors with the same time-dependent magnetic field, and the design of magnetic field trajectories that ensure an optimal spin flip fidelity robust against the value of the exact value of the gyromagnetic factor. We will focus on the precession equations which presents the advantage of a direct possible visualization of the spin trajectory on the Bloch sphere.

Simultaneous control of two different spins

Spin flip of different spins

We now consider a second spin S 2 having a different gyromagnetic factor γ 2 (we assume that there is no interactions between the two spins). We want to setup a protocol allowing to control both spins with the same time-dependent magnetic field. Such a situation is common in NMR46 and in quantum dots47. To setup the reverse engineering protocol, we proceed in the following manner: we enlarge the space of functions that flip the first spin, and search for the subset of parameters that also ensure the spin flip of the second spin. We shall use the same variation as previously for θ (=πs) but a more involved φ(s) ansatz with two free parameters, κ and \(\eta \): \(\phi (s)=\kappa [s+(\eta -\mathrm{1)}{s}^{2}-2\eta {s}^{3}+\eta {s}^{4}]\). This interpolating function fulfills the required boundary conditions \(\phi \mathrm{(0)}\,=\,0\), \(\phi \mathrm{(1)}\,=\,0\) and \(\dot{\phi }\mathrm{(1/2)}\,=\,0\). Using Eqs (13) and (14), we can readily infer the time-dependent components of the magnetic field that one should apply.

In Fig. 2, we plot \({\rm{\Delta }}=1-|\langle -|\psi ({t}_{f})\rangle {|}^{2}=\mathrm{(1}+{S}_{2z}\mathrm{)/2}\) as a function of the two parameters \({\gamma }_{2}/{\gamma }_{1}\) and η, and this for different values of κ. Δ provides a direct measurement of the projection of the spin on the z axis at the end of the transformation. The blue zone are those for which we approach the target of a perfect reversing of spin two. This calculation shows (i) that whatever is the ratio \({\gamma }_{2}/{\gamma }_{1}\) there exists a couple of \((\eta ,\kappa )\) parameters that will ensure a perfect rotation of the two spins despite the fact that their coupling strength to the magnetic field is different and (ii) the existence of dense blue zones (for \({\gamma }_{2}\sim {\gamma }_{1}\)) for which the rotation for both spin can be very good, this feature is the one required for robustness against dispersion of the values of γ 2 (see below). Actually, the existence of many curves with minimum values of Δ in Fig. 2 means that we can simultaneously spin flip many spins having different gyromagnetic factors with the appropriate magnetic field. An example is depicted in Fig. 3 for three different spins where we have represented on the Bloch sphere the time-evolution of each spin. Interestingly, our protocol generates loops on the Bloch sphere to ensure that all spin trajectories end up at the opposite pole at the same time. The one loop trajectory is reminiscent of the spin echo technique but is here generated automatically by our protocol.

Figure 2
figure 2

We design the magnetic field \({\rm{B}}(\eta ,\kappa ,t)\) components as a function of time to ensure the exact spin flip of spin 1 (of gyromagnetic factor γ 1) in an amount of time t f . The parameter space of such solutions has two free extra parameters η and κ. We then calculate the evolution of spin 2 in the time interval \(\mathrm{[0},{t}_{f}]\) in the presence of \({\bf{B}}(\eta ,\kappa ,t)\). We plot the probability, Δ, that spin 2 remains in its initial state as a function of \({\gamma }_{2}/{\gamma }_{1}\) and η parameter for different values of the κ parameter: (a) \(\kappa =0.5\), (b) \(\kappa =2.5\), (c) \(\kappa =3.1\) and (d) \(\kappa =4.5\).

Figure 3
figure 3

Example for which the same \({\bf{B}}(t)\) spin flips perfectly 3 different spin having different gyromagnetic factor: (a) \({\gamma }_{1}=2\), (b) \({\gamma }_{2}=5.34\) and (c) \({\gamma }_{3}=8.94\). Parameters: \(\kappa =0.5\) and \(\eta =5\).

Magnetic field shaping to ensure the robustness of the spin flip protocol

The reverse engineering protocol is well adapted to add further constraints. An important issue is to design spin flip protocols that are robust against the dispersion in the parameters governing the time evolution of the system. A standard example is provided by the dispersion of Larmor frequencies of an ensemble of two-level systems in liquid and solid NMR experiments3. This question is important for the implementation of quantum computing algorithm48.

In this subsection, we propose to optimize the spin flip of a population independent spins whose gyromagnetic factors belongs to the interval \([\bar{\gamma }\mathrm{(1}-\varepsilon );\bar{\gamma }\mathrm{(1}+\varepsilon )]\). For this purpose, we optimize the spin flip fidelity using the free parameters κ and η of our ansatz for the azimuthal angle \(\phi (t)\). We introduce the function \({\rm{\Lambda }}(\varepsilon )\) that measures the average distance towards the exact spin flip by averaging the different probabilities of remaining in the initial state in an interval of size \(2\bar{\gamma }\varepsilon \) about the mean gyromagnetic factor \(\bar{\gamma }\) under consideration:

$${\rm{\Lambda }}(\varepsilon )=\frac{1}{2\bar{\gamma }\varepsilon }{\int }_{\bar{\gamma }\mathrm{(1}-\varepsilon )}^{\bar{\gamma }\mathrm{(1}+\varepsilon )}{\rm{\Delta }}({\gamma }_{2})d{\gamma }_{2}\mathrm{.}$$
(17)

Figure 4 shows the decimal logarithm of the robustness function Λ as a function of κ where \(\varepsilon =0.01\) and \(\eta =20\) is fixed. We observe the existence of a set of discrete “magic” values for κ that ensures an optimal spin flips. The quality of the spin flips increases with the value of the magic κ value. For instance, we get \({\mathrm{log}}_{10}[{\rm{\Lambda }}(\varepsilon =\mathrm{0.01)]}=-7.8816\) for the first magic value \(\kappa =2.0564\), \({\mathrm{log}}_{10}[{\rm{\Lambda }}(\varepsilon =\mathrm{0.01)]}=-8.7127\) for \(\kappa =3.262\). We have also represented the evolution of the second spin on the Bloch sphere in the inset of Fig. 4 for \(\kappa =9.1892\), which corresponds to \({\mathrm{log}}_{10}[{\rm{\Lambda }}(\varepsilon =\mathrm{0.01)]}=-9.4297\).

Figure 4
figure 4

Robustness function \({\mathrm{log}}_{10}[{\rm{\Lambda }}(\varepsilon =\mathrm{0.01)]}\), as a function of κ for \(\eta =20\). Inset: Spin flip trajectory of the second spin on the Bloch sphere with \({\gamma }_{2}=1.01{\gamma }_{1}\), \(\eta =20\) and \(\kappa =9.18918\). For this large magic value of κ, we get \({\mathrm{log}}_{10}[{\rm{\Lambda }}(\varepsilon =\mathrm{0.01)]}=-9.4297\).

For a given time duration t f of the process, the robustness increases at the expense of an increasingly large transient magnetic field amplitude. The use of high optimal values of magic κ generates many rotations of the spin on the Bloch sphere (see the inset of Fig. 4). This is not surprising since it simply generalizes somehow the spin echo technique.

Figure 5 summarizes the robustness functions of different spin flip protocols for gyromagnetic factors spanning the interval \(2\bar{\gamma }\varepsilon \) about the mean value \(\bar{\gamma }\). It compares the performance of (i) the simple π-pulse designed for the mean value \(\bar{\gamma }\) and whose explicit expression is derived in Appendix, (ii) the spin echo technique (see Appendix) and different reverse engineering protocols. We include those latter protocols for a non magic value of the κ parameter and for three magic values. The first magic value is already competitive with the spin echo technique (nearly superposition of the two corresponding robustness function). The larger magic values clearly improve efficiently the fidelity of the spin flip operation on the whole interval investigated here (up to 5% difference of the gyromagnetic factor).

Figure 5
figure 5

Robustness function of \({\mathrm{log}}_{10}[{\rm{\Lambda }}(\varepsilon )]\) as a function of ε for different spin flip protocols: π-pulse (upper solid line), spin echo technique (lower solid line), reverse engineering protocol for the non magic value \(\kappa =0.5\) (dotted line), reverse engineering protocols for the magic values \(\kappa =2.0564\), \(\kappa =3.262\), and \(\kappa =9.1892\) (and dashed lines). The larger the magic value the lower the robustness function.

Simultaneous perfect spin flip and superposition state generation

The method presented in the previous subsections can be readily generalized for other requirements. One could flip spin 1 and require for the spin 2 to end up in the horizontal plane of the Bloch sphere (superposition of state up and down with the same weight).

To confirm such possibilities offered by our extended space of parameter, we fix the ratio \({\gamma }_{2}/{\gamma }_{1}\), and plot the new Δ (\(\,=\,{S}_{2z}\)) function as a function of both parameters η and κ. An example is provided in Fig. 6a for \({\gamma }_{2}/{\gamma }_{1}=0.5\). The two cut of the 2D plot (Fig. 6b) taken for two values of the η parameter shows explicitly the existence of two values of κ that ensures an optimal spin flip of spin 1 and that rotate spin 2 in the equatorial plane of the Bloch sphere. For instance, the optimal parameters are here: for \(\eta =2\), \(\kappa =4.6936\) with \({\mathrm{log}}_{10}({S}_{2z})=-12.5451\) and for \(\eta =3\), \(\kappa =3.799\) with \({\mathrm{log}}_{10}({S}_{2z})=-12.8491\).

Figure 6
figure 6

(a) Mean value of the z component of the second spin at t f (in decimal logarithmic scale) as a function of η and κ with \({\gamma }_{1}=2\) and \({\gamma }_{2}=1\). (b) Cut section of Fig. 6(a) as a function of κ for \(\eta =2\) (solid line) and \(\eta =3\) (dashed line).

Our method is generic. For instance with \({\gamma }_{1}=3\) and \({\gamma }_{2}=1\), our protocol also provides an optimal solution for the same target states. As an example, we find for \(\eta =8\), \(\kappa =5.429\) with \({\mathrm{log}}_{10}({S}_{2z})=-12.6294\).

Control of the spin trajectory in the presence of interactions

In this subsection, we extend the results presented in the previous subsections to the situation for which there is an isotropic mutual interactions between the two spins. Interestingly, the solution can be readily obtained from that without interactions. We then discuss a more involved strategy for the case of exchange interaction \({V}_{{\rm{int}}}^{(dd)}=4\xi {s}_{1z}\mathrm{.}{s}_{2z}\) also referred to as the Ising interaction49,50,51.

Isotropic interactions

Consider a magnetic field function \({{\rm{B}}}_{0}(t)\) that solves simultaneously the equations (7) for spin 1 of gyromagnetic factor γ 1 and spin 2 of gyromagnetic factor γ 2 for the desired target states. It obeys (with the same notations as in Sec. Inverting the precession equation)

$$\begin{array}{c}{\partial }_{t}{{\bf{S}}}_{1}^{0}={\gamma }_{1}{{\bf{B}}}_{0}(t)\times {{\bf{S}}}_{1}^{0},\\ {\partial }_{t}{{\bf{S}}}_{2}^{0}={\gamma }_{2}{{\bf{B}}}_{0}(t)\times {{\bf{S}}}_{2}^{0}\mathrm{.}\end{array}$$
(18)

In the presence of isotropic interactions (\({V}_{{\rm{i}}nt}^{(is)}=\mu {s}_{1}\cdot {s}_{2}\)), we search the magnetic field function \(B(t)\) that one should apply to reach the same target states. We therefore have to solve

$$\begin{array}{c}{\partial }_{t}{{\bf{S}}}_{1}={\gamma }_{1}{\bf{B}}(t)\times {{\bf{S}}}_{1}+\mu {{\bf{S}}}_{2}\times {{\bf{S}}}_{1},\\ {\partial }_{t}{{\bf{S}}}_{2}={\gamma }_{2}{\bf{B}}(t)\times {{\bf{S}}}_{2}+\mu {{\bf{S}}}_{1}\times {{\bf{S}}}_{2}\mathrm{.}\end{array}$$
(19)

Let’s search for a solution of the form \({\bf{B}}(t)={{\bf{B}}}_{0}(t)+\alpha {{\bf{S}}}_{1}+\beta {{\bf{S}}}_{2}\), where α and β are two constant parameters that need to be determined. We have

$$\begin{array}{c}{\partial }_{t}{{\bf{S}}}_{1}={\gamma }_{1}{{\bf{B}}}_{0}(t)\times {{\bf{S}}}_{1}+(\mu -\beta {\gamma }_{1}){{\bf{S}}}_{2}\times {{\bf{S}}}_{1},\\ {\partial }_{t}{{\bf{S}}}_{2}={\gamma }_{2}{{\bf{B}}}_{0}(t)\times {{\bf{S}}}_{2}+(\mu -\alpha {\gamma }_{2}){{\bf{S}}}_{1}\times {{\bf{S}}}_{2}\mathrm{.}\end{array}$$
(20)

Choosing \(\beta =\mu /{\gamma }_{1}\) and \(\alpha =\mu /{\gamma }_{2}\), we now have to solve the set of equations

$$\begin{array}{c}{\partial }_{t}{{\bf{S}}}_{1}={\gamma }_{1}{{\bf{B}}}_{0}(t)\times {{\bf{S}}}_{1},\\ {\partial }_{t}{{\bf{S}}}_{2}={\gamma }_{2}{{\bf{B}}}_{0}(t)\times {{\bf{S}}}_{2}\mathrm{.}\end{array}$$
(21)

and we know the solution \({{\bf{S}}}_{1}={{\bf{S}}}_{1}^{0}\) and \({{\bf{S}}}_{2}={{\bf{S}}}_{2}^{0}\). We conclude that the system (19) admits the solution \({{\bf{S}}}_{1}={{\bf{S}}}_{1}^{0}\) and \({{\bf{S}}}_{2}={{\bf{S}}}_{2}^{0}\) with a magnetic field that varies as

$${\bf{B}}(t)={{\bf{B}}}_{0}(t)+\frac{\mu }{{\gamma }_{2}}{{\bf{S}}}_{1}^{0}+\frac{\mu }{{\gamma }_{1}}{{\bf{S}}}_{2}^{0}\mathrm{.}$$
(22)

In other words, once we have a solution for two independent spins (including in the case of two different gyromagnetic factors) we have also the solution for two spins that interact through an isotropic interaction potential of the form \({V}_{{\rm{int}}}^{(is)}=\mu {{\bf{s}}}_{1}\cdot {{\bf{s}}}_{2}\) whatever is the strength of interaction between the two spins. However, one can never rich the Bell state \(|{\rm{Bell}}\rangle =(|+-\rangle +|-+\rangle )/\sqrt{2}\) with isotropic interactions.

Ising interactions

To reach such a state, one needs anisotropic interactions. The Hamiltonian of two identical spins 1/2 therefore reads

$$H=-\gamma {{\bf{S}}}_{{\rm{1}}}\cdot {\bf{B}}(t)-\gamma {{\bf{S}}}_{2}\cdot {\bf{B}}(t)+{V}_{{\rm{int}}}^{(dd)}\mathrm{.}$$
(23)

It is block diagonal in the basis that classifies the states by their angular momentum |++〉, \(|{\rm{Bell}}\rangle \) and \(|A\rangle =(|+-\rangle -|-+\rangle )/\sqrt{2}\).

As we are interested in the simultaneous spin flip of the two interacting spins or in the generation of the Bell state, we search for a solution in the subspace of angular momentum J = 1: \(|\psi (t)\rangle =a(t)|++\rangle +b(t)|{\rm{Bell}}\rangle +c(t)|--\rangle \). The time dependent complex coefficients a(t), b(t) and c(t) obey the set of linearly coupled equations

$$i\hslash \dot{a}=a(\gamma {B}_{z}+\xi )+b{B}_{-}\gamma /\sqrt{2},$$
(24)
$$i\hslash \dot{b}=a{B}_{+}\gamma /\sqrt{2}-b\xi +c{B}_{-}\gamma /\sqrt{2},$$
(25)
$$i\hslash \dot{c}=b{B}_{+}\gamma /\sqrt{2}+c(-\gamma {B}_{z}+\xi ),$$
(26)

where γ is the gyromagnetic factor and \({B}_{\pm }={B}_{x}\pm i{B}_{y}\).

The adiabatic passage techniques shows that the dynamics is amenable to a 2 × 2 submatrix involving only a and b variables49. The adiabaticity requires a transformation on a typical time scale of \(30\hslash /\xi \). The shortcuts to adiabaticity techniques can be used in this subspace to accelerate the transition from the fully polarized state |++〉 to the Bell state \(|{\rm{Bell}}\rangle \) 52.

For this purpose, we search for a solution that corresponds to a transverse rotating magnetic field whose amplitude varies as a function of time: \(\gamma {B}_{x}(t)=B(t)\cos (\omega t)\) and \(\gamma {B}_{y}(t)=B(t)\sin (\omega t)\). The sub matrix on a and b variables can be recast in a symmetric form within the interaction picture

$${H}_{I}(t)=(\begin{array}{cc}{\rm{\Delta }}(t\mathrm{)/2} & B(t)/\sqrt{2}\\ B(t)/\sqrt{2} & -{\rm{\Delta }}(t\mathrm{)/2}\end{array}),$$
(27)

where the diagonal time dependent coefficient is related to the longitudinal magnetic field component: \({\rm{\Delta }}(t)=\gamma {B}_{z}(t)-\omega +2\xi \). A convenient and classical method to implement reverse engineering in this context relies on the use of dynamical invariants. This method simply consists in determining a matrix I(t) that fulfills the following relation

$$\frac{dI(t)}{dt}=\frac{\partial I(t)}{\partial t}-\frac{i}{\hslash }[I(t),{H}_{I}(t)]\,=\,\mathrm{0,}$$
(28)

with the boundary conditions \([{H}_{I}\mathrm{(0),}\,I\mathrm{(0)]}=[{H}_{I}({t}_{f}),I({t}_{f})]=0\). To find this matrix I(t), we use the Lie algebra operators and expand I(t) on the Pauli matrices: \(I(t)={\rm{u}}\cdot {\rm{\sigma }}\) where u is a unit vector of spherical angles \((\theta ,\phi )\). The eigenstate of I(t), \(|{\varphi }_{+}(t)\rangle =\,\cos (\theta \mathrm{/2)}{e}^{i\phi }|++\rangle +\,\sin (\theta \mathrm{/2)|}{\rm{Bell}}\rangle \), is also the eigenstate of \({H}_{I}(t)\) for initial and final time according to the commutation relations for boundary conditions. The reverse engineering method amounts to fixing the evolution of the vector u in order to interpolated the evolution between the initial state \(|{\varphi }_{+}\mathrm{(0)}\rangle \propto |++\rangle \) and the desired final state \(|{\varphi }_{+}({t}_{f})\rangle \propto |{\rm{Bell}}\rangle \). To this end, the commutation relations shall be transposed as boundary conditions for the time dependent variables θ(t) and φ(t): \(\theta \mathrm{(0)}=0\), \(\theta ({t}_{f})=-\pi \), \(\dot{\theta }\mathrm{(0)}=0\), \(\dot{\theta }({t}_{f})=0\), \(\phi \mathrm{(0)}=-\pi \mathrm{/2}\), \(\phi ({t}_{f})=-\pi \mathrm{/2}\), \(\phi ({t}_{f}\mathrm{/2)}=-\pi \mathrm{/2}\), \(\dot{\phi }\mathrm{(0)}=-\pi /{t}_{f}\), and \(\dot{\phi }({t}_{f})=\pi /{t}_{f}\). From Eq. (28), we obtain the relation between the Hamiltonian variables and the angles of u, namely,

$$\dot{\theta }=\sqrt{2}B(t)\,\sin \,\phi ,$$
(29)
$$\dot{\phi }=-{\rm{\Delta }}(t)+\frac{\dot{\theta }}{\tan \,\theta \,\tan \,\phi }\mathrm{.}$$
(30)

We infer the value of \(B(t)\) and \({B}_{z}(t)\), using the polynomial interpolation of minimum order according to the boundary conditions for the θ(t) and φ(t) variables.

In Fig. 7, we plot the fidelity towards the desired Bell state at final time by solving the set of Eqs (24)–(26) with the magnetic field derived from the preceding approach. We find an improvement of at least one order of magnitude on the time required to reach the Bell state with high fidelity compared to the adiabatic evolution. As intuitively expected, it is impossible to accelerate to arbitrary short time. This is due to the finite value of the coupling (the ζ parameter) that we kept fixed and which imposes a timescale \(\hslash /\xi \).

Figure 7
figure 7

Fidelity to reach the Bell state from a doubly polarized initial state |++〉 (i.e. \(|\langle {\rm{Bell}}|\psi ({t}_{f})\rangle {|}^{2}\)) as a function of the time duration of the transformation in the case of dipole-dipole interaction (solid line). Similar plot (i.e. \(|\langle {\rm{W}}|\psi ({t}_{f})\rangle {|}^{2}\)) to reach the W entangled state with three spins at the vertex of an equilateral triangle (dashed line).

Interestingly, this method can be readily generalized to more spins in a symmetric configuration. For instance, with three spins at the vertex of an equilateral triangle the same approach enables one to design in time the required fast evolution of the magnetic field components to drive the system from the fully polarized state |+++〉 to the W entangled state \(\,=\,(|-++\rangle +|+-+\rangle +|++-\rangle )/\sqrt{3}\) (see dashed line in Fig. 7). The method developed here can be readily generalized to larger number of coupled spins. An interesting perspective is the possibility to generate reliably states pertaining to different equivalent classes through stochastic local operations with classical communications53,54.

Discussion

In this paper, we have proposed a reverse engineering approach to shape a time-dependent magnetic field to manipulate a single spin, two spins with different gyromagnetic factors, and two or more interacting spins in short amount of times. These techniques, as extension of previous STA techniques for atomic transport22,23,24, provide robust protocols against the exact knowledge of the gyromagnetic factors for the one spin problem, or can be used to generate entangled states of two or more coupled spins. The analytical and smooth magnetic fields derived from reverse engineering are experimentally implementable, and the further optimization does not requires time-dependent perturbation theory or numerical iteration, as compared to the previous results in refs6,33. Such fully analytical protocols with good understanding on the spin dynamics and the structure of magnetic fields may also provide an efficient initial guess for numerical iteration used in optimization, see the example in refs37,45. The large space of parameters available in reverse engineering enables one to handle extra constraints. For instance, our technique can be readily adapted to the use of only two control fields (for instance in the xy- plane) as usually done in NMR. We have investigated several state to state transfer. Actually, the reverse engineering formalism presented for the evolution operator also provides the appropriate framework to generate universal rotation or unitary gates55.

Finally, we emphasize that the reverse engineering for spin dynamics provides powerful and effective language to implement the possible coherent control for spin qubits by shaping time-dependent magnetic field. Since the spin 1/2 systems, and equivalent two-level systems, are ubiquitous in the areas of quantum optics, the results, including fast and robust spin flip and entanglement generation, are applicable to quantum commutating and quantum information transfer, encompassing rather different quantum systems. An important extension of this work is the design of reverse engineering protocols in the presence of dissipation, a topic that has been extensively studied in the framework of optimal control theory56,57, with possible applications in the used of quantum dots58, nitrogen-vacancy centre in diamond59, control of nonlinear excitations in ferromagnet60,61,62, superconducting circuits63,64, and optomechanical systems65, to name a few recent examples.