Full-magnetic

The To ff oli gate is the essential ingredient for reversible computing, an energy e ffi cient classical computational paradigm that evades the energy dissipation resulting from Landauer’s principle. In this paper we analyze di ff erent setups to realize a magnetic implementation of the To ff oli gate using three interacting classical spins, each one embodying one of the three bits needed for the To ff oli gate. In our scheme, di ff erent control-spins configurations produce an e ff ective field capable of conditionally flipping the target spin. We study what are the experimental requirements for the realization of our scheme, focusing on the degree of local control, the ability to dynamically switch the spin-spin interactions, and the required single-spin anisotropies to make the classical spin stable, showing that these are compatible with current technology.


I. INTRODUCTION
Reversible computing is a computational paradigm inspired by physical aspects, where the elementary logic operations and logic circuits are ideally invertible [1].The main motivation for reversible computation is to minimize the energy costs by avoiding the requirement of logic operations whose number of outputs is lower than the number of inputs.Indeed, due to the Landauer's principle [2], these irreversible operations dissipate energy, and therefore limit the efficiency of the resulting computation.A central result in reversible computing is that any algorithm can be realised through the use of a single operation called Toffoli gate [1,3], a three-bit to three-bit Control-Control-NOT operation, where the value of the target bit is reversed depending on the value of the first two bits.It is also known that the quantum version of the Toffoli gate is universal for quantum computing, when paired with the Hadamard gate [4] -quantum computing is ideally reversible by physical principles, given the unitarity of quantum evolution.It has been shown that a quantum Toffoli gate can be achieved using the evolution of quantum spin systems either with external control pulses [5] or via unmodulated interactions [6].On the other hand, because of the reversibility of quantum evolution, it has been proved that even a classical Toffoli gate can be obtained from the physical dynamics of quantum spins [7].An implementation of the classical Toffoli gate using a continuous-time machine was proposed by Toffoli [8], which was later extended to the quantum setting by Feynman [9].
In this paper we aim at the possibility of realising a classical Toffoli gate exploiting the continuous-time dynamics of interacting classical spins.A classical spin corresponds to the limit of a quantum spin for large spin quantum number S and is represented as a fixed-modulus vector in a threedimensional space.The building blocks of classical computing with interacting large-S spins have recently been explored in experiments with magnetic adatoms [10], using irreversible operations and thermal equilibrium states that result from the interaction with the substrate environment.On the other hand, in this work we are interested in the reversible dynamics of classical spins in a low relaxation limit, a regime that can be obtained, for instance, in molecular systems [11].More recently, Toffoli gates were implemented using magnetic skyrmions [12], silicon spin qubits [13], and a setup involving spin waveguides, cross-junctions, and phase shifters [14].
The dynamics of classical spins is ruled by Hamiltonians and Poisson brackets that follow from the spin commutation rules in the large-S limit, so they can be imagined as objects carrying a fixed angular momentum and realized as magnetic dipoles.
In the following, we present two different models, whose common feature is the presence of three interacting classical spins, each one embodying one of the three bits needed for the Toffoli gate.In other words, the two logical states of the bits are encoded in the alignment (1-state) or anti-alignment (0-state) of the corresponding spin along a locally preferred direction.The basic idea behind our schemes is that different configurations of the two control-spins give rise to different effective magnetic fields acting on the target spin, thus producing different dynamics.
The two models differ for the choice of the local easy-axis direction: in the first one, introduced in Section II, all spins, being they either control or target, are supposed to be collinear when in their stable steady states, while in the second model they are taken to form mutual well defined angles, as detailed in Section III.In each Section we discuss the role played by single-ion anisotropy and dissipation.Finally, to better frame the problem in view of a concrete realization, a quantitative estimate of the relevant parameters is given in the final Section.

II. COLLINEAR-SPIN MODEL
A quantum spin corresponds to an angular momentum operator Ŝ having a fixed modulus, Ŝ2 = (ℏS) 2 , S being the (semi-integer) spin quantum number.Its three components obey the commutation relations where Greek letters correspond to the components x, y, and z, and ε αβγ is the completely antisymmetric Levi-Civita symbol.The classical limit ℏ → 0 entails that the spin quantum number S → ∞ in such a way that the modulus ℏS → S is kept constant: Ŝ becomes a classical vector S, i.e., with three commuting components.Being its modulus |S| = S a constant (with the dimensions of an action), it is more convenient to deal with the unit vector s = S/S , whose components obey the Poisson brackets that follow from Eq. ( 1), Our aim is to define a spin system and its dynamics in such a way that it can implement classical logical operations.To accomplish this goal we first specify how a classical spin can be exploited to encode a classical bit.If the spin is subjected to an easy-axis anisotropy that favors its alignment along, say, the z-direction, it can have two stable directions, s z = ±1.The natural mapping is to encode the classical bit into two stable orientations, bit states {0, 1} ⇐⇒ s = { (0, 0, −1), (0, 0, 1) } , (3) that may be dubbed South-and North pole.
As our purpose is to single out a dynamics that could implement a three-bits Control-Control-Operation, here we consider a three classical spins system: s 1 and s 2 are control spins while s ≡ (x, y, z) is the target spin.Besides the easy-axis anisotropy, we consider an exchange interaction between control and target spin, while adjustable magnetic fields are introduced as tunable parameters for driving the dynamics in a controlled way.The Hamiltonian of the system is where the exchange interaction between the control spins and the target spin is ferromagnetic, J > 0, and of the Ising type.Hereafter JS 2 is used as the energy unit and (JS ) −1 as the time unit.The single-site easy-axis anisotropy a > 0 defines the zdirection and the stable up/down configurations.Finally, an overall Zeeman field h ∥ along the z-direction is applied, while a local tunable field h ⊥ (one can assume it to be non-negative, without loss of generality) along the x direction is assumed to act locally on the target spin.
The equations of motion (EoM) are obtained from the Poisson brackets (2) through d(•)/dt = (•), H and the specific form of the Hamiltonian (4) implies that ṡz 1 = ṡz 2 = 0, namely, the z-component of the control spins is conserved.This implies that, if initially in s z i = ±1, the control spins do not evolve in time.This is a desirable feature to implement a Control-Control-Operation, such as the Toffoli gate, which is defined by the following rule: if and only if both control spins are in the 1 configuration (with the encoding (3)) the target spin is flipped (from 0 to 1 or vice-versa), otherwise it is unchanged.
For the dynamics of the target spin, the Hamiltonian (4) yields the following EoM, with effective field If h is constant throughout the target spin motion (namely, if a = 0), then the above equations describe the precession of s around the direction identified by h, which depends on the constant control-spin components s z 1 and s z 2 .Thus, it is necessary to analyze the dynamical behavior of s starting from the four different initial configurations of the control spins/bits, [s 1 s 2 ], according to the encoding of Eq. ( 3).When a 0 Eq. ( 5) is nonlinear, the effective field varies with s and the dynamics is no more a simple precession.In the following section we first consider the case a = 0.

A. No single-ion anisotropy
The case of vanishing anisotropy elucidates the mechanism for the realization of the Toffoli gate via the spin dynamics.For a = 0 the EoM (5) describe a precession of Larmor frequency |h| around the fixed axis h.According to Eq. ( 6), the different precession axes for the possible values of the controls are so that fixing the values of h ∥ and h ⊥ , different trajectories are obtained depending on the initial configuration of the control spins.
A Toffoli gate requires that the dynamical evolution, at time t G , defined as the gate time, produces the transformation on the target spin The first action on s can be achieved only if the precession axis h 11 lies in the xy-plane.From the first of Eqs.(7), this is obtained with the choice while h ⊥ remains the only free parameter that sets the angular frequencies in the different cases.Here it is important to note that the direction of the precession axis, when the control spins are different from the configuration [11], is not relevant since the second condition requires the target to come back to the initial configuration.The fundamental aspect is that the different conditions should be matched at the same gate time t G .This request imposes constraints on the precession periods for the different control configurations, which are In order to obtain the actions described in ( 8), t G must be an odd multiple of T 11 /2 and an integer multiple of T 01 and T 00 , i.e., for three integer numbers n, m, l.Comparing the third and the fourth term with the second one, it must be and the elimination of h ⊥ leads to a constraint for the three integers The latter condition cannot be satisfied, as the left and right terms are even and odd, respectively.Hence, there is no choice of the parameters that allows to exactly achieve the desired transformation, Eq. ( 8).However, this also suggests an interesting comparison: the condition ( 13) is exactly the same found in Ref. 7, where, using a three-qubit Hamiltonian and quantum dynamics, the problem of realizing a classical Toffoli gate was afforded.In particular, comparing the Hamiltonian (4) (with a = 0) with Eq. (1) of Ref. 7 a precise correspondence is found between Eqs. (5) in 7 and our Eqs.(12), where the condition (9) (equivalent to ω 2 = 2J zz in Ref. 7) is also enforced.Therefore, the constraints on the Hamiltonian parameters required for obtaining a Toffoli gate are exactly the same in the pure quantum case (using qubits) and in the classical case (using classical spins).This is not so surprising, if one recalls the identity between the classical equations of motion (5) and the quantum Heisenberg equations for spin operators interacting with an applied field.Such correspondence allows us to follow the reasoning of Ref. 7 to obtain an approximate Toffoli gate when a = 0.In fact, for n = 0 (for the lowest possible t G ) and for a large value of m (i.e.h ⊥ = (m 2 − 1/4) −1/2 ∼ 1/m), assuming exactly valid the first of the (12), the second equation gives l = 2m + O(m −1 ), which is the closer to an integer the larger the value of m.Since one can weaken the encoding rule of the spin/bits, allowing them to represent 1 or 0 if their third component's modulus exceeds a certain threshold value instead of being exactly one (i.e., they do not have to exactly point the poles, but they have to stay in small finite regions close to them), it is possible to exploit the above reasoning to achieve the desired gate using a value of m large enough to meet the second of the conditions (12) within the necessary precision.This is shown for example in Fig. 1.Moreover, the external environment can provide relaxation processes that enhance the stability of these regions, as discussed in Section II C, which is particularly important for applications when the device is used multiple times to realize many gates.

B. Single-ion anisotropy
In this section we analyse the dynamics of the target spin s for a finite value of the anisotropy parameter (i.e., for a 0).In this case, the motion described by Eqs. ( 5) is not a simple precession, as the effective field h, which depends on the value of s z , changes during the motion.
As there are no simple analytical solutions in this case, we integrate numerically the EoM.Specifically, we analyze the dynamics of the target s to find a single gate time t G which accomplishes the transformation (8), exploiting the freedom given by the three parameters h ⊥ , h ∥ , and a.
The general expressions are derived in Appendix A, and assume a simpler form for h = 0, namely when the controls are in the state [11] and h ∥ is given by Eq. ( 9).In this case (see Eq. (A8) for the general case), the function z(t) satisfies and setting z = cos θ, it further simplifies to θ2 = h 2 ⊥ − a 2 sin 2 θ .As the condition a| sin θ | ≤ h ⊥ must be satisfied, it follows that for an anisotropy value larger than the field strength (a > h ⊥ ) the target spin cannot cross the equator (sin θ = 1) and its motion is confined to a cone of aperture sin −1 (h ⊥ /a) around the pole where its dynamics started, θ(0) = 0 or θ(0) = π.Therefore, the condition a < h ⊥ must be fulfilled for achieving a target spin to flip between the poles.Under this condition, the implicit kinematic equation reads The resulting trajectories are closed and connect the two poles in a time corresponding to half-period of the motion, where is the complete elliptic integral of the first kind.Therefore, the effect of anisotropy is to increase the precession period T 11 = 2π/h ⊥ in Eqs.(10).Note that if the condition (9) were not satisfied, the trajectory of s would not cross the opposite pole, since in that configuration Eq. (A8) in both cases becomes ż2 = −4 h2 .Because the motion is always periodic, there are time periods for any control-spin configuration (in particular those different from [11], where h 0) after which the target spin returns to the starting position.Then, as described before, a Toffoli gate occurs at time t G if Eqs. (11) are satisfied.However, as analytic expressions for T 00 and T 10 are not available, we consider a numerical solution of Eq. (A9) in those cases.In Fig. 2 the dynamics in presence of a non-zero anisotropy term is shown as an example.
On the other hand, in Section III we will show that the use of non-collinear control spins simplifies Eq. ( 11) in the anisotropic case, since all the periods T αβ for any α, β = 0, 1 can be expressed in terms of elliptic integrals.Although the exact solution of ( 11) may be impossible even in the presence of anisotropy, we show in the following that approximate solutions are enough in the presence of Gilbert damping, since the latter stabilizes the evolution.

C. Stability improvement due to external environments
Without an external environment, the dynamics described in the previous sections continues indefinitely so the driving field h ⊥ needs to be switched off externally to stop the dynamics and achieve the gate.As this scheme requires a careful timing of the switch control, its practical realization may be difficult.In the following we show that this limitation can be overcome by exploiting the interaction of the system with an external environment which provides a mechanism to stabilize the dynamics and help the realization of the Toffoli gate.The key point is that in a bistable configuration there are two stable minimum-energy spin orientations (North and South poles).The effect of the dissipation is then to drive the system to the "closest" equilibrium position, so that even if the Toffoli gate is implemented with some errors, as long as the imperfect dynamics brings the target spin close to the desired configuration, then relaxation processes transform such a dynamics into a perfect gate.In the following we show how this condition can be achieved.
A damping term, −η s × ṡ, that accounts for the energy loss of the magnetic moment caused by its interaction with the surroundings, is introduced following the scheme of the Laundau-Lifshitz-Gilbert (LLG) model.The equation ( 5) for the target spin is then extended to We note that both the North and the South poles, z = ±1, are equilibrium configurations for the LLG equation, when h ⊥ = 0. To check for the stability of these configurations we first linearize Eq. ( 19) around these points and we calculate the eigenvalues of the resulting matrix, ∂ α L β z=±1 , which are Both poles are stable if the real part of the above eigenvalues is negative, i.e., 2a−| h| > 0. Therefore, taking into account the condition (9), that entails | h| ≤ 4, the stability is guaranteed for an anisotropy strength that satisfies a > 2.Moreover, the field h ⊥ has to be larger than a to allow a spin flip of the target when the controls are in the configuration [11].Therefore, the condition that allows to obtain the Toffoli gate with stable periodic orbits is  [11] for the first column (a,d), [00] for the central column (b,e) and [10] (equal to [01]) for the last column (c,f).We used a ≃ 2.5, h ⊥ ≃ 2.7 and η = 0.01.The field h ⊥ is switched off after a time given by Eq.( 17).
The effect of the damping factor for the dynamics of the target spin is plotted in Fig. 3, where it can be clearly seen that in all possible configurations of the control spins the target spin always converges to the desired pole.The damping term is assumed to be weak and the flipping time is found from Eq. ( 17).This represents an estimate of the time in which the driving field, h ⊥ , must be switched off to allow the relaxation of the target spin towards the closest equilibrium configuration.Even though the switching time is not perfectly matched, and even if the times T αβ do not exactly satisfy Eq. ( 11), one can see from Fig. 3 that the dynamics implements a Toffoli gate that becomes exact in the long time limit, due to the sequential effects of the strong driving pulse and the stabilizing environment.

III. NON-COLLINEAR-SPIN MODEL
We now consider a different scenario where the stable positions of the control spins may be along different axes e 1 and e 2 , while the target bit is defined in the z direction.The values 1 and 0 of a control bit correspond to the spin being aligned or antialigned with the direction e i , i.e., s i = e i ⇔ 1 and s i = −e i ⇔ 0. To simplify the analysis, the control spins are assumed to be frozen in their state, while the effect of the anisotropy is taken into account in the next subsection.
Unlike the Ising interaction considered in Eq. ( 4), here the target spin s has a Heisenberg coupling with the control spins and is subjected to an external field h, Since the control spins s 1 and s 2 are frozen, the resulting dynamics is a precession around the effective field s 1 + s 2 + h with frequency |s 1 + s 2 + h|.It is easy to see that the choice of h = e 1 + e 2 freezes the dynamics for the [00] configuration, for which H 00 = 0 or, equivalently, the precession frequency is ω 00 = 0. On the other hand, respectively for the configurations [10] and [01] so that ω 10 = ω 01 = 2, namely the target spin comes back to the initial state at time T [01] = π and for every integer multiple of it.As in the previous scheme, we define the Toffoli gate time at one of these times, namely t G = mT [01] , and for the [11]  or, equivalently, where 2φ is the angle between e 1 and e 2 .Many solutions are possible (provided that the condition 2n + 1 < 4m is satisfied).This amounts to require cos φ = 2n+1 4m , so that the simplest one is for n = 1 and m = 1, namely A. Easy-axis anisotropy We consider the effect of a non-zero anisotropy a for the target spin s along the z-axis, H = (s 1 + s 2 + h) • s + a(s z ) 2 .The equation of motion for the target spin s reads We assume that now e 1 and e 2 lie in the xy-plane and we study the dynamics of the target spin, for all the control configurations, setting the x-axis in the direction of the in-plane field s 1 + s 2 + h ≡ ( h, 0, 0), with h00 = 0, h10 = 2, h01 = 2, and h11 = 2|e 1 + e 2 | = 4 cos φ.In this case the EoM can be cast in a form equivalent to Eq. ( 15), where h ⊥ is replaced by h.For any control configuration [αβ] one can use Eq. ( 17) to get the half period, for h > a, as Similarly to what happened in the collinear case, from Eq. ( 18) we find that the anisotropy increases the period from the precession time 2π/ h.The Toffoli gate for a given time t G can be accomplished by imposing the condition Eq. ( 11) where so, choosing m = n = 1 as above, one finds an implicit condition that determines φ, IV. CONCLUDING REMARKS In this paper we have analysed several setups that realize a magnetic implementation of a Toffoli gate, under some suitable assumptions about the building elements of the device.Specifically, the control spins must be kept fixed during the target spin evolution.This requires that at least one of the following conditions to be satisfied: i) an external magnetic field can be applied to the target spin only [this is implicitly assumed by writing the Hamiltonian as in Eqs.( 4) and ( 22)]; ii) the control spins are held along their initial orientation by stronger interactions with other circuit elements (e.g., as in Ref. 10); iii) a much higher single-ion anisotropy acts on the control spins.In the latter case we point out that, unless the anisotropy could be externally controlled on a time scale similar to the gate operation times, it may be difficult to make the scheme scalable, i.e., allowing for a given spin to act as a control or a target at different steps of the device operation.
Moreover, while the Hamiltonian model ( 4) allows for stationary logical states (with spins aligned along the quantization axis) for h ⊥ = 0, this does not hold for the non-collinear scheme, where timing thus becomes even more critical and it not only requires to have control over the external magnetic field, but also over the control-target interaction.Namely, one has to be able to switch on/off both the interaction and the field in very short times.Once this requirement is satisfied, outside of the time intervals of gate operation the target is subjected only to the effect of the anisotropy, which can therefore be even small to assure the stability of the logical states.
On the other hand, in the collinear model, a single ion anisotropy on the target spin is not only required to properly set the quantization axis, but it has also to be strong enough, i.e. a > 2, to stabilize the spin configurations representing the logical states.As the proper spin-flip operation can be achieved only if h ⊥ > a, measuring spin values in ℏ units and writing the control-target coupling as J (S z 1 +S z 2 )S z , the anisotropy term as −AS 2 z , and the Zeeman term as −g s µ B ⃗ S • ⃗ H, we may go back to physical units, to get a quantitative estimate of the relevant parameters.For the system presented in Ref. 10 we can gauge J ≃ 0.3 meV ≃ 3.5 K, an order of magnitude similar to that observed also in molecular magnets [11,15,16], typically J ≃ 1 − 20 K. Therefore we may assume J ∼ 1 K as a reasonable value for the control-target coupling; taking S ∼ 3 − 5, we get H ∥ ∼ 10 T, A ∼ 5 K and H ⊥ ∼ 50 − 100 T. Because these are rather high values, the non-collinear scheme is a better candidate in view of an experimental realization of the device.From the above calculations, the order of magnitude for the gate operation time is in the range of 10-100 ps.
The necessary requirements on the field strength and on the timing can be made less strict due to the effect of a weak dissipative environment.We have shown in Sec.II C that, although the small price that has to be paid in terms of gateoperation time and thermal energy loss, the environment is beneficial for implementing the device.Indeed we have shown that if the non-dissipative dynamics, while being not perfect, brings the target not too far from the wanted logical state configuration, the effect of dissipation is to eventually stabilize the target spin.

Figure 1 .
Figure 1.Target spin s trajectories on the unit sphere with h ∥ = −2 and h ⊥ = 0.201 (i.e. the value obtained from the first of Eqs.(12) with n = 0 and m = 5).As shown in the legend panel, different colors correspond to different control configurations.

Figure 2 .
Figure 2. s trajectories on the unit sphere with h ∥ = −2, h ⊥ = 2.7 and a = 2.5, starting from the north pole.Final time is obtained from Eq. (17).Different colors correspond to different control configurations, as reported in the legend.

Figure 3 .
Figure 3. Dissipative dynamics of the target spin following the LLG equation (19) for two different initial configurations along the z axis, s z T = 1 for the top row (a,b,c) and s z T = −1 for the bottom row (d,e,f), and different choices of the control spin, namely[11] for the first column (a,d), [00] for the central column (b,e) and[10] (equal to [01]) for the last column (c,f).We used a ≃ 2.5, h ⊥ ≃ 2.7 and η = 0.01.The field h ⊥ is switched off after a time given by Eq.(17).