## Abstract

We put forward reverse engineering protocols to shape in time the components of the magnetic field to manipulate a single spin, two independent spins with different gyromagnetic factors, and two interacting spins in short amount of times. We also use these techniques to setup protocols robust against the exact knowledge of the gyromagnetic factors for the one spin problem, or to generate entangled states for two or more spins coupled by dipole-dipole interactions.

## 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) pulses^{1}. 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 pulse^{2,3,4,5}. Another fast and efficient technique is the optimal control theory^{6,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 solutions^{12}. Otherwise, purely numerical techniques have been setup for quantum manipulation using for instance genetic algorithm^{13}. 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 systems^{15,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 fields^{20}. Here we will concentrate on a subclass of such solutions usually referred to as reverse engineering protocols^{21}. Such techniques have been recently applied to the fast transport or manipulation of wave functions^{22,23,24,25}, or in tailored transformations in statistical physics^{26,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 refs^{29,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 system^{31,32}, or, equivalently, a generic two-level system with cold atoms^{33,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 inversion^{37} 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 system^{38,39,40}, Bose-Einstein condensates (BECs)^{41,42}, and other many-body systems^{43,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 invariant^{33}, 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

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

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 approach^{18}, see also refs^{29,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:

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

and the dynamics is given by the two scalar equations

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

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)

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

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 sphere^{36}. 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

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

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.

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 NMR^{46} and in quantum dots^{47}. 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.

#### 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 experiments^{3}. This question is important for the implementation of quantum computing algorithm^{48}.

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:

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\).

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).

#### 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\).

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 interaction^{49,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)

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

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

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

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

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

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

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* variables^{49}. 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

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

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,

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 \).

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 communications^{53,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 transport^{22,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 refs^{6,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 refs^{37,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 gates^{55}.

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 theory^{56,57}, with possible applications in the used of quantum dots^{58}, nitrogen-vacancy centre in diamond^{59}, control of nonlinear excitations in ferromagnet^{60,61,62}, superconducting circuits^{63,64}, and optomechanical systems^{65}, to name a few recent examples.

## Additional information

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

## References

- 1.
Allen, J, L. & Eberly, H.

*Optical Resonance and Two-Level Atoms*(Wiley, New York, 1975). - 2.
Tycko, R. Broadband population inversion.

*Phys. Rev. Lett.***51**, 775 (1983). - 3.
Levitt, M. H. Composite pulses.

*Prog. Nucl. Magn. Reson. Spectrosc.***18**, 61–122 (1986). - 4.
Torosov, B. T., Guérin, S. & Vitanov, N. V. High-fidelity adiabatic passage by composite sequences of chirped pulses.

*Phys. Rev. Lett.***106**, 233001 (2011). - 5.
Genov, G. T. & Vitanov, N. V. Dynamical suppression of unwanted transitions in multistate quantum systems.

*Phys. Rev. Lett.***110**, 133002 (2013). - 6.
Solá, I. R., Malinovsky, V. S. & Tannor, D. J. Optimal pulse sequences for population transfer in multilevel systems.

*Phys. Rev. A***60**, 3081 (1999). - 7.
Boscain, U., Charlot, G., Gauthier, J.-P., Guérin, S. & Jauslin, H.-R. Optimal control in laser-induced population transfer for two-and three-level quantum systems.

*J. Math. Phys.***43**, 2107–2132 (2002). - 8.
Hegerfeldt, G. C. High-speed driving of a two-level system.

*Phys. Rev. A***90**, 032110 (2014). - 9.
Das, P. K. Optimal control of two-level quantum system with weighted energy cost functional.

*Cybern. Phys.***1**, 96 (2012). - 10.
Glaser, S. J.

*et al*. Training schrödinger’s cat: quantum optimal control.*The Eur. Phys. J. D***69**, 279, https://doi.org/10.1140/epjd/e2015-60464-1 (2015). - 11.
Garon, A., Glaser, S. J. & Sugny, D. Time-optimal control of su(2) quantum operations.

*Phys. Rev. A***88**, 043422, https://doi.org/10.1103/PhysRevA.88.043422. (2013). - 12.
Carlini, A., Hosoya, A., Koike, T. & Okudaira, Y. Time-optimal quantum evolution.

*Phys. Rev. Lett.***96**, 060503 (2006). - 13.
Weidner, C., Yu, H., Kosloff, R. & Anderson, D. Z. Atom interferometry using a shaken optical lattice.

*Phys. Rev. A***95**, 043624 (2017). - 14.
Vitanov, N., Fleischhauer, M., Shore, B. & Bergmann, K. Coherent manipulation of atoms and molecules by sequential laser pulses.

*Adv. At. Mol. Opt. Phys.***46**, 57–190 (2001). - 15.
Bergmann, K., Theuer, H. & Shore, B. Coherent population transfer among quantum states of atoms and molecules.

*Rev. Mod. Phys.***70**, 1003 (1998). - 16.
Král, P., Thanopulos, I. & Shapiro, M. Colloquium: Coherently controlled adiabatic passage.

*Rev. Mod. Phys.***79**, 53–77 (2007). - 17.
Vitanov, N. V., Rangelov, A. A., Shore, B. W. & Bergmann, K. Stimulated raman adiabatic passage in physics, chemistry, and beyond.

*Rev. Mod. Phys.***89**, 015006 (2017). - 18.
Torrontegui, E.

*et al*. Shortcuts to adiabaticity.*Adv. At. Mol. Opt. Phys***62**, 117–169 (2013). - 19.
Deffner, S., Jarzynski, C. & del Campo, A. Classical and quantum shortcuts to adiabaticity for scale-invariant driving.

*Phys. Rev. X***4**, 021013 (2014). - 20.
Chen, X., Lizuain, I., Ruschhaupt, A., Guery-Odelin, D. & Muga, J. G. Shortcut to adiabatic passage in two- and three-level atoms.

*Phys. Rev. Lett*.**105**, 123003, https://www.ncbi.nlm.nih.gov/pubmed/20867634, https://doi.org/10.1103/PhysRevLett.105.123003 (2010). - 21.
Chen, X.

*et al*. Fast optimal frictionless atom cooling in harmonic traps: shortcut to adiabaticity.*Phys. Rev. Lett*.**104**, 063002, https://www.ncbi.nlm.nih.gov/pubmed/20366818, https://doi.org/10.1103/PhysRevLett.104.063002 (2010). - 22.
Torrontegui, E.

*et al*. Fast atomic transport without vibrational heating.*Phys. Rev. A***83**, 013415 (2011). - 23.
Guéry-Odelin, D. & Muga, J. Transport in a harmonic trap: Shortcuts to adiabaticity and robust protocols.

*Phys. Rev. A***90**, 063425 (2014). - 24.
Zhang, Q., Chen, X. & Guéry-Odelin, D. Fast and optimal transport of atoms with nonharmonic traps.

*Phys. Rev. A***92**, 043410 (2015). - 25.
Martínez-Garaot, S., Palmero, M., Muga, J. G. & Guéry-Odelin, D. Fast driving between arbitrary states of a quantum particle by trap deformation.

*Phys. Rev. A***94**, 063418 (2016). - 26.
Guéry-Odelin, D., Muga, J., Ruiz-Montero, M. J. & Trizac, E. Nonequilibrium solutions of the boltzmann equation under the action of an external force.

*Phys. Rev. Lett.***112**, 180602 (2014). - 27.
Martínez, I. A., Petrosyan, A., Guéry-Odelin, D., Trizac, E. & Ciliberto, S. Engineered swift equilibration of a brownian particle.

*Nat. physics***12**, 843 (2016). - 28.
Le Cunuder, A.

*et al*. Fast equilibrium switch of a micro mechanical oscillator.*Appl. Phys. Lett.***109**, 113502 (2016). - 29.
Barnes, E. & Sarma, S. D. Analytically solvable driven time-dependent two-level quantum systems.

*Phys. Rev. Lett.***109**, 060401 (2012). - 30.
Vitanov, N. V. & Shore, B. W. Designer evolution of quantum systems by inverse engineering.

*J. Phys. B: At. Mol. Opt.***48**, 174008 (2015). - 31.
Emmanouilidou, A., Zhao, X.-G., Ao, P. & Niu, Q. Steering an eigenstate to a destination.

*Phys. Rev. Lett.***85**, 1626 (2000). - 32.
Ban, Y., Chen, X., Sherman, E. Y. & Muga, J. Fast and robust spin manipulation in a quantum dot by electric fields.

*Phys. Rev. Lett.***109**, 206602 (2012). - 33.
Ruschhaupt, A., Chen, X., Alonso, D. & Muga, J. Optimally robust shortcuts to population inversion in two-level quantum systems.

*New J Phys.***14**, 093040 (2012). - 34.
Daems, D., Ruschhaupt, A., Sugny, D. & Guérin, S. Robust quantum control by a single-shot shaped pulse.

*Phys. Rev. Lett.***111**, 050404 (2013). - 35.
Lu, X.-J.

*et al*. Fast and robust population transfer in two-level quantum systems with dephasing noise and/or systematic frequency errors.*Phys. Rev. A***88**, 033406 (2013). - 36.
Berry, M. Transitionless quantum driving.

*J. Phys. A: Math. Theor.***42**, 365303 (2009). - 37.
Chen, X., Ban, Y. & Hegerfeldt, G. C. Time-optimal quantum control of nonlinear two-level systems.

*Phys. Rev. A***94**, 023624 (2016). - 38.
Takahashi, K. Transitionless quantum driving for spin systems.

*Phys. Rev. E***87**, 062117 (2013). - 39.
Zhang, J.

*et al*. Experimental implementation of assisted quantum adiabatic passage in a single spin.*Phys. Rev. Lett.***110**, 240501 (2013). - 40.
Farzanehpour, M. & Tokatly, I. Dynamics of observables and exactly solvable quantum problems: Using time-dependent density-functional theory to control quantum systems.

*Phys. Rev. A***93**, 052515 (2016). - 41.
Bason, M. G.

*et al*. High-fidelity quantum driving.*Nat. Phys.***8**, 147–152 (2012). - 42.
Liu, J.

*et al*. Theory of nonlinear landau-zener tunneling.*Phys. Rev. A***66**, 023404 (2002). - 43.
Chen, Y.-A., Huber, S. D., Trotzky, S., Bloch, I. & Altman, E. Many-body landau-zener dynamics in coupled one-dimensional bose liquids.

*Nat. Phy.***7**, 61–67, https://doi.org/10.1038/nphys1801 (2011). - 44.
del Campo, A. Shortcuts to adiabaticity by counterdiabatic driving.

*Phys. Rev. Lett.***111**, 100502 (2013). - 45.
Brouzos, I.

*et al*. Quantum speed limit and optimal control of many-boson dynamics.*Phys. Rev. A***92**, 062110 (2015). - 46.
Assémat, E.

*et al*. Simultaneous time-optimal control of the inversion of two spin-1/2 particles.*Phys. Rev. A***82**(2010). - 47.
Hu, X., de Sousa, R. & Das Sarma, S. Interplay between zeeman coupling and swap action in spin-based quantum computer models: error correction in inhomogeneous magnetic fields.

*Phys. Rev. Lett*.**86**, 918–21, https://www.ncbi.nlm.nih.gov/pubmed/11177973, https://doi.org/10.1103/PhysRevLett.86.918 (2001). - 48.
Ohlsson, N., Mohan, R. K. & Kröll, S. Quantum computer hardware based on rare-earth-ion-doped inorganic crystals.

*Opt Commun.***201**, 71–77 (2002). - 49.
Unanyan, R. G., Vitanov, N. V. & Bergmann, K. Preparation of entangled states by adiabatic passage.

*Phys. Rev. Lett*.**87**, 137902 https://www.ncbi.nlm.nih.gov/pubmed/11580627, https://doi.org/10.1103/Phys-RevLett.87.137902 (2001). - 50.
Mancini, S. & Bose, S. Engineering an interaction and entanglement between distant atoms.

*Phys. Rev. A***70**, 022307 (2004). - 51.
Yun, S. J., Kim, J. & Nam, C. H. Ising interaction between two qubits composed of the highest magnetic quantum number states through magnetic dipole-dipole interaction.

*J. Phys. B: At. Mol. Opt. Phys.***48**, 075501 (2015). - 52.
Paul, K. & Sarma, A. K. High-fidelity entangled bell states via shortcuts to adiabaticity.

*Phys. Rev. A***94**, 052303 (2016). - 53.
Verstraete, F., Dehaene, J. & De Moor, B. Normal forms and entanglement measures for multipartite quantum states.

*Phys. Rev. A***68**, 012103 (2003). - 54.
Baguette, D., Bastin, T. & Martin, J. Multiqubit symmetric states with maximally mixed one-qubit reductions.

*Phys. Rev. A***90**, 032314 (2014). - 55.
Boozer, A. Time-optimal synthesis of su (2) transformations for a spin-1/2 system.

*Phys. Rev. A***85**, 012317 (2012). - 56.
Lapert, M., Zhang, Y., Braun, M., Glaser, S. & Sugny, D. Singular extremals for the time-optimal control of dissipative spin 1/2 particles.

*Phys. Rev. Lett.***104**, 083001 (2010). - 57.
Stefanatos, D. & Li, J.-S. Constrained minimum-energy optimal control of the dissipative bloch equations.

*Syst. & Control. Lett*.**59**, 601–607, http://www.sciencedirect.com/science/article/pii/S0167691110000915. https://doi.org/10.1016/j.sysconle.2010.07.004 (2010). - 58.
Press, D., Ladd, T. D., Zhang, B. & Yamamoto, Y. Complete quantum control of a single quantum dot spin using ultrafast optical pulses.

*Nat.***456**, 218 (2008). - 59.
Zhou, B. B.

*et al*. Accelerated quantum control using superadiabatic dynamics in a solid-state lambda system.*Nat. physics***13**, 330–334, https://doi.org/10.1038/nphys3967 (2017). - 60.
Li, Z.-D.

*et al*. Screw-pitch effect and velocity oscillation of a domain wall in a ferromagnetic nanowire driven by spin-polarized current.*J. Physics: Condens. Matter***22**, 216001, http://stacks.iop.org/0953-8984/22/i=21/a=216001 (2010). - 61.
Li, Z.-D., Liu, F., Li, Q.-Y. & He, P. B. Dzyaloshinskii-moriya domain wall resonance in ferromagnetic nanowires with a spin-transfer torque.

*J. Appl. Phys.***117**, 173906, https://doi.org/10.1063/1.4919676 (2015). - 62.
He, P.-B., Yan, H., Cai, M.-Q. & Li, Z.-D. Sustained chiral magnetic domain wall motion driven by spin-orbit torques under the tilted current.

*EPL*(*Europhysics Lett*.)**114**, 67001, http://stacks.iop.org/0295-5075/114/i=6/a=67001 (2016). - 63.
Novikov, S.

*et al*. Raman coherence in a circuit quantum electrodynamics lambda system.*Nat. Phys.***12**, 75 (2016). - 64.
Kumar, K. S., Vepsäläinen, A., Danilin, S. & Paraoanu, G. S. Stimulated raman adiabatic passage in a three-level superconducting circuit.

*Nat. Commun.***7**, 10628, https://doi.org/10.1038/ncomms10628 (2016). - 65.
Dong, C., Fiore, V., Kuzyk, M. C. & Wang, H. Optomechanical dark mode.

*Sci.***338**, 1609–1613 (2012).

## Acknowledgements

This work was partially supported by the NSFC (11474193), the Shuguang Program (14SG35), the Program for Eastern Scholar, the grant NEXT ANR-10-LABX-0037 in the framework of the Programme des Investissements dAvenir and the Institut Universitaire de France. Q.Z. acknowledges the CSC PhD exchange program (grant number 201606890055).

## Author information

### Affiliations

#### Shanghai University, Department of Physics, Shanghai, 200444, P. R. China

- Qi Zhang
- & Xi Chen

#### Université de Toulouse, UPS, Laboratoire Collisions Agrégats Réactivité, IRSAMC, F-31062, Toulouse, France

- Qi Zhang
- & D. Guéry-Odelin

#### CNRS, UMR 5589, F-31062, Toulouse, France

- Qi Zhang
- & D. Guéry-Odelin

### Authors

### Search for Qi Zhang in:

### Search for Xi Chen in:

### Search for D. Guéry-Odelin in:

### Contributions

X.C. and D.G.O. devised the research. Q.Z., X.C. and D.G.O. performed the calculations and wrote the paper.

### Competing Interests

The authors declare that they have no competing interests.

### Corresponding authors

Correspondence to Xi Chen or D. Guéry-Odelin.

## 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 theref 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

## Comments

By submitting a comment you agree to abide by our Terms and Community Guidelines. If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.