Simulating single-spin dynamics on an IBM five-qubit chip

In this paper we show how the IBM superconducting chips can be a powerful tool for teaching foundations of quantum mechanics for undergraduate students (for graduates as well, in some cases). To this end, we briefly discuss about the main elements of the IBM Quantum Experience platform necessary to understand this paper, i.e., how to implement operations and single-qubit measurements. We experimentally study the dynamics of single spin systems interacting with static and time-dependent magnetic fields. First, we study the resonant behavior of a single spin coupled to a time-dependent rotating magnetic field. To end, we study the Larmor precession phenomenon. In both cases we show the theoretical and real experimental implementation. This article could be useful in introductory courses on quantum mechanics and nuclear magnetic resonance foundations, for example.


I. INTRODUCTION
In traditional courses of quantum mechanics where we introduce the notion of single-spin dynamics, some interesting results are discussed in a theoretical way, without any experimental implementation or verification. On the other hand, simulating quantum physics is an interesting task that we can explore in the IBM Team's quantum plataform, namely, the IBM Quantum Experience (IBM-QE) 1 . From such platform we have access to a five-qubit system 2 in which we can manipulate it from unitary operations (unitary operators) and measurements. This platform has been used to experimentally confirm some theoretical results on quantum information and computation [3][4][5][6][7] as well as to implement high technology quantum protocols like teleportation 8,9 , among others [10][11][12][13][14][15] .
Methods to circumvent experimental limitations of teaching quantum physics have been considered in literature through simulations [16][17][18] , experimental proposal in quantum optics 19 , nuclear magnetic systems 20 and classical implementation of quantum computers 21 . By using a different approach, in this paper we discuss how useful the IBM-QE can be in a physics teaching scenario, where we develop a didactic strategy to deal with the problem of experimentally present foundations of single-spin dynamics in presence of a magnetic field, including time-dependent fields. To this end, we first present the relevant elements that we need to know before starting the simulation of the examples we will present here. We discuss about the unitary operators that we will use in our simulations and how we can implement measurements in IBM-QE. By the way, we adopt an approach which allows us to introduce how measurement of some physical quantities are performed in a Nuclear Magnetic Resonance (NMR) experimental setup 22 . Then, we discuss about the first interesting phenomena of single-spin dynamics, namely spin resonance phenomena, associated with a spin-1 2 particle in presence of a strong static field along z-direction and a rotating magnetic field. We discuss how the resonance phenomenon emerges from a suitable choice of the rotating magnetic field frequency and how it allows us to promote transitions between "spin up" and "spin down" states of the system, even when such rotating field is weakly interacting with the system 22,23 . To conclude, we study the Larmor spin precession behavior.

II. THE IBM QUANTUM EXPERIENCE
The five-qubit IBM quantum chip is composed by five superconducting transmon qubits operating at a temperature scale around 15 mK 24-26 . A superconducting transmon qubit is composed of two coupled Josephson junctions, with Josephson energy E J and capacitance C J 27 , and shunted by an additional external capacitance C E , as shown in Fig. 1a. As sketched in Fig. 1b, this system presents a quantized energy levels structure E n , where two of these energy levels (the two lowest-energy levels) are used as an artificial qubit for quantum computation, since quantum coherence is observed in such systems 28 . Because the Josephson junctions are superconducting devices, the system is composed by a large number of Cooper pairs (a pair of electrons), where the collective effect of these pairs allows us to use a superconducting qubit as "artificial atom". In particular, we can use it as a two-level system. For this reason, this system is not a genuine two-level quantum system, like spin-1/2 particle in presence of a magnetic field or the polarization states of light. However, the characteristics and dynamics of superconducting qubits allows us to simulate such systems.
For more relevant details about the superconducting transmon qubits, we recommend the Refs 25,26,28 .
In particular, we can perform simulations and real experimental realizations from two different quantum chips, known as the IBM Q 5 Tenerife (ibmqx4) and IBM Q 5 Yorktown (ibmqx2) quantum chips. Particularly, throughout this article we implement the experiments on IBM Q 5 Yorktown quantum chip, due to the good decoherence time scale of its qubits 1 .
In this section we discuss on some important elements of the IBM-QE to be considered in this paper, but more information about IBM-QE quantum chips can be obtained from a number of papers in literature 8 , as well as from the own IBM-QE team beginners guide 29 .
A. IBM-QE single-qubit operations Single qubit operations are unitary transformations on two level systems which, in a realistic physical scenario, arise as result of a dynamics provided by Schrödinger equation for some time dependent (or time independent) Hamiltonian H(t). In particular, single-qubit operations can be obtained from different quantum evolutions, as in spin dynamics 20,30 or in a quantum particle in a double-well 31 , for example. In this paper, the relevant single-qubit operations implementable by the IBM five-qubit chip are where λ, φ and θ are free real parameters that can be adjusted in accordance with the gate to be implemented. It is possible to see that the gates U 1 (λ) and U 2 (λ, φ) can be obtained from gate U 3 (θ, φ, λ), but under experimental viewpoint the gates U 1 (λ) and U 2 (λ, φ) can be more efficient than its counterpart obtained from U 3 (θ, φ, λ). In fact, each gate can be characterized from its run-time (time associated with real pulse sequence on transmon qubits), where the run-time for U 1 (λ) can be neglected, U 2 (λ, φ) is a gate with duration of 1 unit of gate time and U 3 (θ, φ, λ) has run-time of 2 units of gate time. Therefore, it is most convenient to use the gates U 1 (λ) and U 2 (λ, φ) whenever possible.

B. Measuring physical quantities in a single-spin system
The measurement process in physics depends on the system under consideration 20,30,[32][33][34] .
Here, we are interested in studying a single-spin-1 2 system driven by magnetic fields which act on it. Thus, since the system can be found in two different orthogonal states |↑ and |↓ associated with different values of the spin component, these states work as a computational basis in a Nuclear Magnetic Resonance based quantum computer 20,30 . In particular, the IBM-QE allows us to implement measurements in computational basis |0 ≡ |↑ and |1 ≡ | ↓ , i.e., given a quantum state |ψ = a| ↑ + b| ↓ , the measurement outcome provides values for |a| 2 and |b| 2 . Thus, the physical quantities which we can measure in IBM-QE are constrained to a set of measurements that can be obtained from parameters |a| 2 and |b| 2 .
For example, if we want to measure the expected value of the spin along z direction, we have where S x , S y and S z are the spin operators defined as Thus, it is possible to compute M z . In addition, if we want to compute the expected value of spin along x direction, we need to compute M x = ψ|S x |ψ . It can be done if we define the operator where one uses the relation S x = HS z H to write with |ψ x = H|ψ . In quantum computation, the operator H is a Hadamard gate and it can be implemented on IBM-QE. In conclusion, it means we can measure M x if we implement a Hadamard gate on the state |ψ and then we measure the output state in computational basis. In a similar way, the measurement of the quantity M y = ψ|S y |ψ can be done by defining the rotation operator that represents a rotation of an angle ξ around X-direction 23 . Thus, if we implement the operation with ξ = −π/2 we get so that we can show that S y = R x (−π/2)S z R † x (−π/2), then with |ψ y = R † x (−π/2)|ψ . Thus, we can measure any spin component along the directions x, y and z. In addition, we can perform measurement of any physical quantity O which can be written as O = Rr(φ)S z R † r (φ), where Rr(φ) denotes a rotation of an angle φ around directionr, from equation

III. SINGLE-SPIN DYNAMICS ON IBM QUANTUM EXPERIENCE
The spin is an internal degree of freedom of the electron that can be manipulated through external magnetic fields. In particular, for a spin-1 2 particle we have two distinct states |↑ and |↓ . These two states satisfy the eigenvalue equation in which is the reduced Planck's constant and S n = ( /2)σ n , where σ n (n = {x, y, z}) denotes the Pauli matrices for a two-level system given by (with i = √ −1) so that the matrix form for the basis |↑ and |↓ reads as |↑ = [ 1 0 ] t and |↓ = [ 0 1 ] t , with superscript "t" denoting the transpose of a matrix.

A. Simulating Nuclear Magnetic Resonance phenomenon
Let us consider the coupling dynamics of a single spin-1 2 with a rotating magnetic field B(t) given by where B 0 = B 0ẑ is the field component along the Z-direction and B rf (t) is a time-dependent transverse magnetic fields, given by where ω is the rotating frequency of the transverse magnetic field, also known as Radio-Frequency (rf) field. Therefore, the Hamiltonian of the system is written as where ω 0 is the Larmor frequency and ω rf is the coupling intensity between the spin and the rf-field. The solution of the Schrödinger equation for the system is known and given by (See In matrix form, we write each evolution operator as where ∆ = ω 0 − ω is a detuning between the rf-field and the Larmor frequencies, and Ω 2 = ∆ 2 + ω 2 rf is the effective Rabi frequency, which takes into account the effects due to the detuning 35 . It is worth to mention that the term e − iωt 2 in U 0 (t) represents a global phase and can be neglected, as we will do from now on. In particular, here we will simulate the resonance phenomenon, where a small rf-field (|ω rf | |ω 0 |) can be used to flip the spin state when the rf-field oscillation frequency is close to ω 0 (|∆| → 0). Under this configuration, and the system will evolve as In case where the initial state is given by |ψ (0) = |↑ , we compute the time-dependence of the Z-spin component and we find Notice that the parameter ω does not develop any role in the above quantity. We choose this particular state because the standard input state in IBM quantum chip is the computational state |0 , namely the spin-up state |↑ .
To simulate the spin dynamics of the Eq. (21) we need to map the evolution operators U 0 (t) and U ress xz (t) into the available parameters in IBM-QE. We mean, from the Eqs. (2) we need to identify the operator U 0 (t) as U 1 (λ 1 ) and the operator U ress (t) as U 3 (θ, φ, λ) for a particular choice of the parameters λ, φ and θ. A first point to be highlighted is that λ, φ and θ are dimensionless parameters, so we need to get a correspondence between the dimensionless parameters of U 0 (t) and U ress xz (t) with the parameters associated to the operators U 1 (λ 1 ) and U 3 (θ, φ, λ), respectively. In our case, it is possible to see that In conclusion, U ress (t) would be simulated through the sequence The quantum circuit that executes this task is shown in Fig. 2. In Fig. 2a we present the theoretical and experimental data of the spin dynamics for the case where ω = ω 0 (resonance situation). To this end, we encode our spin (to be driven by Hamiltonian in Eq. (15)) as the qubit q [2] shown in Fig. 2b. The experimental chip condition is shown in table I, as provided by IBM team before we start the experimental procedure. In table I, Table I  Now, as a second application, we discuss the experimental simulation of the Larmor precession phenomenon. Let us consider the system at the initial state where θ ∈ [0, π]. If the system is driven by a time-independent magnetic field along zdirection, i.e., B 0 = B 0ẑ , the associated Hamiltonian is read as the evolved state of the system will be given by (up to a global phase) whereŨ 0 (t) = e − i H 0 t = diag[ 1 e iω 0 t ] is the evolution operator. Now, by computing the behavior of the physical quantities defined in Eqs. (3), (6) and (9), we get In order to see the precession behavior, if we define the spin vector M xy in xy-plane as so that we use the Eqs. (27) and we get The geometrical representation of M xy is a spinning vector around z-axis (in the xyplane) and its norm is || M xy || = | sin(θ)|/2. Therefore, when we define the spin vector since M z = cos(θ)/2. The geometrical representation of M(t) is shown in Fig. 3a. For this reason, we call such dynamics Larmor spin precession or spin precession.
To simulate such dynamics, we need to prepare the initial input state |ψ 0 , then we implement the evolution as provided by the evolution operatorŨ 0 (t). Then, we measure the spin component along directions x, y and z. Thus, the circuit which simulates the spin precession is shown in Fig. 3 and we can build it following three steps: (1) The initial state: As mentioned, the IBM-QE has a natural input state given by |0 = |↑ , so any algorithm input state should be achieved from it. In particular, the The above unitary operator is obtained from the gate U 3 (θ, φ, λ) in Eq. (2) if we set (2) The evolution: As previously discussed, the evolution as provided by operatorŨ 0 (t) can be achieved through the U 1 (λ) gate (up to a global phase) whenever we set λ = ω 0 t.
(3) The measurement: The last circuit step is the measurement. To measure the z-spin component we do not need to implement rotations, since the natural measurement basis of the IBM-EQ is the computational basis ("spin-up " and "spin-down" basis in our case). The spin measurement along x and y direction are obtained as discussed in Sec. II B, so we need to implement a Hadamard (H) gate and R x = R † x (−π/2) gate to measure in x and y basis, respectively.
The experiment of the precession spin was implemented with same qubit as in previous experiment, but with new physical parameters as shown in Table II. In experiment we have two dimensionless parameters to be adjusted, namely the parameter θ associated with initial state and the quantity ω 0 t due to the time-dependence of the operatorŨ 0 (t). Thus, we choose two values of θ and we experimentally study the behavior of the physical quantities defined in Eq. (27) as function of ω 0 t. Since we need to start the protocol with the same state for each measurement, we set the same parameter θ in gate U 3 for each circuit of the

IV. CONCLUSION
Here we have presented a didactic proposal which can be used to present a more consistent study on quantum single-spin dynamics, where we discussed how to remotely implement its experimental realization in a superconducting quantum processor. To this end, we encourage the use of the IBM-QE platform as a resource for teaching quantum mechanics from an experimental approach, in completeness with the theoretical one. Here we have shown the required elements (quantum gates and measurement) to study single-spin dynamics from IBM-QE systems. As a demonstration of how useful the IBM-QE platform can be, we discuss about two particular and interesting dynamics of single-spin system. As a first example, we have discussed about the resonance phenomena in systems composed of nuclear spins, with high applicability in nuclear magnetic resonance based quantum technologies.
To conclude, we have studied the Larmor precession phenomena. Both applications could be experimentally verified. It is worth to highlight that both experiments were implemented in a relatively short time, for our case, in average, it took between 3 and 10 minutes for getting the experimental data file for each execution (each point of the graph).
The single-qubit dynamics studied in this paper can be implementable through different physical systems. For example, by using the photon polarization, a number of half-wave plate and quarter-wave plate can be used to simulate the dynamics. In this system, the readout process can be done through state tomography of the photon polarization. However, because this system needs a laboratory with high technology electronic devices, such laboratories are not accessible for a large number of universities. A second possibility of physical system, which can implement the experiment discussed here can be, is a NMR experimental setup. However, these system are orders of magnitude more expensive than optical ones. Therefore, the IBM-QE project is a possibility of experimental realizations on quantum information and computation for a number of universities around the world.
In this Appendix we discuss about the exact solution of the spin dynamics of a particle in presence of a time-dependent magnetic field given by B(t) = B 0 + B rf (t), where B 0 = B 0ẑ and B rf (t) are a static magnetic field along Z-direction and a time-dependent transverse magnetic fields, respectively. In particular, here we focus on case with B rf (t) = B rf [cos(ωt)x + sin(ωt)ŷ], where ω is the rotating frequency of the transverse magnetic field, also known as Radio-Frequency (rf) field. The coupling energy of the system with the field allows us to write the system Hamiltonian as where we used that µ = γ σ/2 is the magnetic dipole moment, with σ = σ xx + σ yŷ + σ zẑ and γ being the gyromagnetic ratio, which defines the coupling of the spin with the external magnetic field, ω 0 is the Larmor frequency and ω rf is the coupling of the spin with rf-field.
Mathematically we write ω 0 = −γB 0 and ω rf = −γB rf 22 . The procedure discussed in this Appendix is used to find the solution of the spin dynamics when the rf-field is much smaller than the static longitudinal field B 0 , that is, || B 0 || || B rf (t)|| or |ω 0 | |ω rf |. As we shall see in this Appendix, even in case where the rf-field is much smaller than the static field, we will show how the resonance phenomena develops a significant role in spin dynamics of the system. Thus, here we are interested in solving the dynamics To this end, in order to simplify the above equation, let us consider an auxiliary state |ξ(t) so that |ψ(t) can be written as where U 0 (t) is a time-dependent operator U 0 (t) given by As we shall see, this particular operator allow us to drastically simplify the dynamics equation of the system. Thus, by using Eq. (A3) in Eq. (A2), we get so that we use the property U † 0 (t)U 0 (t) = 1 to write In conclusion, we get a dynamics equation for |ξ(t) given by in which we define the new (transformed) Hamiltonian It is important to highlight here the additional term in the above equation. The contri- can be interpreted as a "fictitious potential" 39 and it has been considered in a number of applications 22,23,40 . Therefore, we can find the solution |ψ(t) if we know the solution for |ξ(t) . The most important result here is associated with the Hamiltonian H ξ (t). Now, let us compute the first term in Hamiltonian H ξ (t) as where we can use the relations to write Now, by computing the second term of H ξ (t) we get Thus, we conclude that It is worth to highlight in above equation the quantity ∆ = ω 0 − ω, called detuning between the rf-field and the Larmor frequencies. In particular, when ∆ is very close to zero we have a resonance situation, and this configuration is very important because if we put ∆ → 0, the dominant parameters in dynamics of the system are associated with the rf-field.
Moreover, this result is very useful, since we now can compute the solution for |ξ(t) from a time-independent Hamiltonian. Now, the solution for |ξ(t) reads as where Ω 2 = ∆ 2 +ω 2 rf is the effective Rabi frequency, which takes into account effects due to the detuning ∆. Thus, by using the fact that U xz (0) = U 0 (0) = 1, we find that |ξ(0) = |ψ(0) and this calculation concludes the proof of the Eq. (16).

Appendix B: Non-unitary effects in superconducting transmon qubits
In this section we briefly discuss about undesired effects in real quantum information processors. In particular, we will focus on experimental device used in this manuscript.

Decoherence phenomena
Due to our inability of decoupling our quantum system from its environment (thermal reservoir, for example), the run time of a computation (or dynamics) is bounded by two important time scales, namely, T 1 and T 2 . The first quantity T 1 is an energy relaxation time scale that arises from natural perturbations (external effects) in the system. This natural perturbation drives the system through a non-unitary process from an arbitrary state |ψ to the fundamental state |↓ . This process is also called spontaneous emission 25 . Therefore, since quantum computation needs coherence (superposition) to implement powerful algorithms, we can see that such effect becomes a problem. As an alternative to bypass this problem, we can implement computations with run time T comp T 1 , so that the decohering effect due to spontaneous emission is minimized (or suppressed in some cases). On the other hand, there is a different time scale T 2 that is associated with loss of coherence of the system (also called phase damping 23 ). We mean, given a general quantum state |ψ = a|↓ + b|↑ , the coherence of the system in the basis {|↓ , |↑ } can be easily identified from the density where the diagonal terms (|b| 2 and |a| 2 ) denote the population of each state {|↓ , |↑ } and off-diagonal state are coherence terms, that is, we say that a quantum state has coherence in basis {|↓ , |↑ } when |ab * | = 0. Therefore, non-unitary processes that drastically change the quantity |ab * | are undesired. In order to explain the phase damping process, consider the initial state of the system is given by the above density matrix, then if the system evolves under phase damping process the evolved state ρ(t) of the system state is 23 Therefore, from above equation we can see that ρ(t T 2 ) ≈ diag |b| 2 |a| 2 , where the system becomes (approximately) a maximally mixed state and no coherence in basis {|↓ , |↑ } is present. On the other hand, we can see that ρ(t 2T 2 ) ≈ ρ ψ , so that the loss of coherence can be negligible. For this reason, the knowledge of the quantities T 1 and T 2 is very important to the run time of the computation T comp . The bigger the T 1 and T 2 are, the bigger the T comp can be. In the experiment presented in this manuscript, the computation time is of order of a few tens of nanoseconds, while the time scales T 1 and T 2 are of the order of a few of tens of microseconds. Then, the condition T comp T 1 and T comp T 2 is verified and we can approximate our analysis via unitary processes, as done in main text of the manuscript. Consequently, any error in process is associated with systematic control and readout errors, as we shall discuss in next section.

Control and readout of transmon superconducting qubits
Any physical system (two-level system) used as a qubit for quantum information processing needs to satisfy a number of criteria known as DiVincenzo's criteria 41 . DiVincenzo's criteria is a list with 7 conditions to be satisfied for any system that can be used to quantum information, computation and communication. In particular, two of these conditions are related with control and readout of the qubits of the system, that is, any good qubit needs to be manipulated and the information encoded in it needs to be read. In particular, in transmon superconducting qubit the control and the readout can be achieved by an external driving microwave acting on the system. For more details about the interaction of the transmon qubit with the external driving field, we recommend the pioneer manuscript 25 .
The qubit operations (gates) are implemented by means of microwave pulses at the qubit transition frequency, where the microwave field couples to the the qubit via an electromagnetic coupling. In this situation, the qubit state is driven through Rabi oscillations.
Therefore, imprecise control of these pulses (phase or amplitude, for example) reflects on the optimal control of the qubit operations, hence some error gate is evidently possible in this case. In the device considered in this manuscript, the error gate is of the order of ∼ 10 −3 , that is, the gate is efficiently implemented with fidelity F ∼ 0.999 (99.9%). More specifically, the fidelity of the gate applied to the qubit used in our first experiment (Table I) is F = 0.99536 (99.536%), since the error gate is 0.00464, and in second experiment we have F = 0.99579 (99.579%), because the error gate is 0.00421 (Table II).
On the other hand, the readout is obtained by measuring the phase or amplitude of the transmitted radiation of a microwave drive field 25 . To do that, a readout microwave interacts with qubit via a dispersive interaction. Then, the measurement of the effective transition frequency of the resonator is used to determinate the qubit state. It is important to mention that, since the measurement is effectively done on the resonator, this process is called quantum nondemolition measurement 42 . Due to the complexity of the measurement process, such process is more sensitive to errors then the qubit operations previously discussed. To the qubit used in our experiment, we have the error given by 0.017 and 0.016 for the first and second experiment, respectively. This means that the fidelity readout is 98, 3% and