Reverse engineering protocols for controlling spin dynamics

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.

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 ψ | 〉 (0) . Its time evolution is encapsulated in the evolution operator U(t): . The most general form for U is a 2 × 2 complex matrix whose coefficients are partially related to ensure its unitary property. Denoting ρ = ϕ u e ij ij i ij, the coefficients of U shall fulfill the following relations ϕ ϕ ϕ = ≡ 12 21 , ρ ρ ρ = ≡ 12 21 , ρ ρ = ≡ r 11 22 and ϕ ϕ ϕ π + = + 2 11 22 . The most general form of U therefore reads ( 2 ) 11 11 where the variables r, ϕ 11 and ϕ are time-dependent. The reverse engineering protocol consists in shaping in time the three variables r, ϕ 11 and ϕ to ensure the transformation ψ The expansion of H on the Pauli matrices σ i ( = i x y z , , ) gives the time-dependent magnetic field components that should be implemented in order to follow the desired trajectory: where γ 1 is the gyromagnetic factor and ϕ ϕ Φ = − 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 ψ 11 , 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(0) 1 and = r t ( ) 0 f . To avoid the divergence of denominators, we choose Φ = 0 and θ = r t t ( ) cos( ( )) with θ = (0) 0 and θ , and a solution that contains the famous π-pulse solution with a constant magnetic field 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 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 n t e ( ) ( ) The two previous complex equations can be recast as a Hamiltonian problem for the conjugate variables ϕ n ( , ) a a . It is convenient to introduce the relative variables The expression of the Hamiltonian now reads and the dynamics is given by the two scalar equations From the evolution of Δ n and θ, we can infer the components of the magnetic field. For instance, cos sin Combining Eqs (8)-(10), we get z x y 1 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 B 0 x z and ϕ = 0, we find θ γ =  B y 1 . The reverse engineering protocol consists here in choosing for θ(t) a function that obeys the boundary conditions θ = (0) 0 and θ π = t ( ) f , 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 t ( ) z 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 . The set of equations (11) and (12) then reads t an cos s in cos , t an sin s in sin (14) y 1 1 0 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 θ = (0) 0 and θ π = (1) . The simplest polynomial interpolation between those two boundary conditions is θ π = s s ( ) . In this case, = 2 to fulfill those conditions. Equations (13) and (14) 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 η: ϕ 4 . This interpolating function fulfills the required boundary conditions ϕ = (0) 0, ϕ = (1) 0 and ϕ = (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 as a function of the two parameters γ γ / 2 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 γ γ / 2 1 there exists a couple of η κ ( , ) 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 γ γ ∼ 2 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  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 γ ε γ ε − + [ (1 ); (1 )]. For this purpose, we optimize the spin flip fidelity using the free parameters κ and η of our ansatz for the azimuthal angle ϕ t ( ). We introduce the function ε Λ( ) 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 about the mean gyromagnetic factor γ under consideration: (1 ) 2 2 Figure 4 shows the decimal logarithm of the robustness function Λ as a function of κ where ε = . 0 01 and η = 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 ε Λ = .
3 262. We have also represented the evolution of the second spin on the Bloch sphere in the inset of Fig. 4 for κ = .
=− . log [ ( 0 01)] 94297 10 . 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 about the mean value γ . It compares the performance of (i) the simple π-pulse designed for the mean value γ 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). 2 0564, κ = .
3 262, and κ = . 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 γ γ / 2 1 , and plot the new Δ ( = S z 2 ) function as a function of both parameters η and κ. An example is provided in Fig. 6a for γ γ = .
/ 05 2 1 . 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 η = 2, κ = .
3 799 with = − . S log ( ) 12 8491 Our method is generic. For instance with γ = 3 1 and γ = 1 2 , our protocol also provides an optimal solution for the same target states. As an example, we find for η = 8, κ = .

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 In the presence of isotropic interactions 2 ), we search the magnetic field function B t ( ) that one should apply to reach the same target states. We therefore have to solve   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 2 whatever is the strength of interaction between the two spins. However, one can never rich the Bell state | 〉 = |+−〉 + |−+〉 Bell ( ) / 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 |++〉, | 〉 Bell and | 〉 = |+−〉 − |−+〉 A ( ) / 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: 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 B iB x 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 / . The shortcuts to adiabaticity techniques can be used in this subspace to accelerate the transition from the fully polarized state |++〉 to the Bell state | 〉 Bell 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: 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 ξ /  . 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 = |−++〉 + |+−+〉+ |++−〉 ( ) / 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