# Implementation of the refined Deutsch-Jozsa algorithm on a 3-bit NMR quantum computer

## Abstract

We implemented the refined Deutsch-Jozsa algorithm on a 3-bit nuclear magnetic resonance quantum computer, which is the meaningful test of quantum parallelism because qubits are entangled. All of the balanced and constant functions were realized exactly. The results agree well with theoretical predictions and clearly distinguish the balanced functions from constant functions. Efficient refocusing schemes were proposed for the soft $`z`$-pulse and J-coupling and it is proved that the thermal equilibrium state gives the same results as the pure state for this algorithm.

A quantum computer which was just a theoretical concept has been realized recently by nuclear magnetic resonance (NMR). Several methods have been proposed such as ion trap , quantum dot , cavity QED , and Si-based nuclear spins  to realize quantum computers but NMR  has given the most successful results. Several quantum algorithms have been implemented by NMR quantum computers among which the Deutsch-Jozsa (D-J) algorithm  has been studied most because it is the simplest quantum algorithm that shows the power of a quantum computer over a classical one. Most of quantum algorithms, including the D-J algorithm, have been implemented only for functions of one and two bits. The successful implementation of a quantum algorithm depends heavily on the number of basic operations which increases with the number of qubits due to finite coherence time. Moreover, more than 2-bit operations require more than two-body interactions which do not exist in nature. It is possible to avoid such interactions, though not easy, but it increases again the number of total basic gates and coherence may break down during the computation. There have been few works that have performed real three-bit operations  so far.

The D-J algorithm determines whether an $`n`$-bit binary function,

$$f:\{0,1\}^n\{0,1\},$$
(1)   
is a constant function which always gives the same output, or a balanced function which gives 0 for half of inputs and 1 for the remaining half. The D-J algorithm gives answer by only one evaluation of the function while a classical algorithm requires $`(2^{n1}+1)`$ evaluations in the worst case. The function is realized in quantum computation by unitary operation,

$$U|x|y=|x|yf(x),$$
(2)   
where $`x`$ is an $`n`$-bit argument of the function and $`y`$ is one-bit. If $`|y`$ is in the superposed state, $`(|0|1)/\sqrt{2}`$, then the result of the operation,

$$U|x(\frac{|0|1}{\sqrt{2}})=(1)^{f(x)}|x(\frac{|0|1}{\sqrt{2}}),$$
(3)   
carries information about the function encoded in the overall phase. If $`|x`$ is also prepared in the superposition of all its possible states, $`(|0+|1+\mathrm{}|2^n1)/\sqrt{2^n}`$, by applying an $`n`$-bit Hadamard operator $`H`$ to $`|x=|0`$, the relative phases of the $`2^n`$ states change depending on $`f`$. If $`f`$ is a constant function, then the relative phases are all same and additional application of $`H`$ restores $`|x`$ to $`|0`$. If $`f`$ is a balanced function, $`|x`$ cannot be restored to $`|0`$ by this operation. It is obvious that $`|y`$, being in the superposed state, $`(|0|1)\sqrt{2}`$, plays a central role in the algorithm but it is redundant in the sense that its state does not change.

This redundancy is removed in the refined D-J algorithm  where the following unitary operator is used.

$$U_f|x=(1)^{f(x)}|x.$$
(4)   
It has been shown that $`U_f`$ is always reduced to a direct product of single-bit operators for $`n2`$. In this case, $`n`$ classical computers can do the same job by simultaneous evaluations because qubits are never entangled. Therefore, meaningful tests of the D-J algorithm can occur if and only if $`n>2`$. Recently, a realization of the D-J algorithm for $`n=4`$ has been reported , but in that work, only one balanced function was evaluated and the corresponding $`U_f`$ is reducible to a direct product of four single-bit operators. In this study, we investigated the refined D-J algorithm with 3-bit arguments to find out the pulse sequences of $`U_f`$’s, and implemented the algorithm on an NMR quantum computer for all the functions.

There are $`{}_{8}{}^{}\text{C}_{4}^{}=70`$ balanced and two constant functions among all 3-bit binary functions. We index the functions with their outputs, $`f(0)\mathrm{}f(7)`$, expressed as hexadecimal numbers. For example, $`f_{\mathrm{𝟷}𝙴}`$ denotes the function of which the outputs are given by $`f(0)\mathrm{}f(7)=00011110`$. Note that $`U_{f_𝚡}=U_{f_{\mathrm{𝙵𝙵}𝚡}}`$, where x is a hexadecimal number equal to or less than FF. The difference of overall phase cannot be distinguished in the experimental implementations. Therefore, there are 35 distinct unitary operators corresponding to the balanced functions, and one operator corresponding to the constant functions. Since the unitary operator corresponding to the constant functions, $`U_{f_{\mathrm{𝟶𝟶}}}`$, is just the unity matrix, there are 35 non-trivial and distinct $`U_f`$’s to be implemented.

The NMR Hamiltonian of the weakly interacting three spin system is given by

$$=\underset{i}{\overset{3}{}}\mathrm{\Delta }\omega _iI_{iz}+\underset{i<j}{\overset{3}{}}\pi J_{ij}2I_{iz}I_{jz}$$
(5)   
in the rotating frame, where $`I_{iz}`$ is the $`z`$-component of the angular momentum operator of spin $`i`$. The first term represents the precession of spin $`i`$ about $`z`$-axis due to the chemical shift, $`\mathrm{\Delta }\omega _i`$, and the second term the spin-spin interaction between spin $`i`$ and $`j`$ with coupling constant $`J_{ij}`$. This Hamiltonian provides six unitary operators, $`I_{iz}(\theta )=\mathrm{exp}[ı\theta I_{iz}]`$ and $`J_{ij}(\theta )=\mathrm{exp}[ı\theta 2I_{iz}I_{jz}]`$. In combination with $`I_{iz}(\theta )`$, two other operators $`I_{ix}(\theta )`$ and $`I_{iy}(\theta )`$ produced by rf pulses can perform any single-bit operations. The coupling operator $`J_{ij}(\theta )`$ can be used to make a controlled-not operation. The combination of single-bit operations and controlled-not operations can generate any unitary operations .

Table I shows the sequences of the realizable operators for all the 35 non-trivial distinct $`U_f`$’s. In the table, the notations $`I_1`$, $`I_2`$ and $`I_3`$ were replaced by $`I`$, $`S`$ and $`R`$, respectively for convenience. Some of $`U_f`$’s are irreducible and require three-body interaction. The sequences of realizable operators in the table were obtained by following a general implementation procedure using generator expansion . This method includes the coupling order reduction technique which replaces an $`n`$-body interaction operator for $`n>2`$ by two-body ones. It is noticed that all $`U_f`$’s consist of the operators of the single-spin rotations about $`z`$-axis and spin-spin interactions only. From now on, we call pulses corresponding to these operators the soft $`z`$-pulse and J-coupling, respectively.

The balanced functions are classified into four types depending on the number of $`J_{ij}(\theta )`$’s included in their operation sequences. It is easy to see that no qubits are entangled in type-I functions and therefore, obviously they are not the cases of meaningful tests. In type-II functions, only two qubits out of three are entangled. So, type-II functions can be said to be the stepping stones to meaningful tests. In type-III and IV functions, all three qubits are entangled and the functions of these types can be tested only by a three-bit quantum computer. Therefore, the realization of type-III and IV functions demonstrates true quantum parallelism. Each sequence in Table I is not unique for a given function but we believe that they are optimal ones for implementation of the refined D-J algorithm.

The whole operation sequence for implementation of the refined D-J algorithm is given by $`H`$-$`U_f`$-$`H`$-$`D`$ to be read from left to right. The first and second $`H`$’s were realized by hard $`\pi /2`$ and $`\pi /2`$ pulses about $`y`$-axis, respectively. Since the read-out operation $`D`$ can be realized by a hard $`\pi /2`$ pulse about $`y`$-axis, the second $`H`$ and $`D`$ cancel each other to make the sequence $`H`$-$`U_f`$.

The superposed input state is generated by the Hadamard operation on the pure state $`|0`$. Therefore, it is usually necessary to convert the thermally equilibrated spin state into the effective pure state. In the case of the refined D-J algorithm, however, the thermal equilibrium state gives the same results with the pure state. The deviation density matrix of the thermal equilibrium state, $`\rho _{\text{th}}`$, is approximated by

$$\rho _{\text{th}}=I_{1z}+I_{2z}+I_{3z}$$
(6)   
for the Hamiltonian of Eq. 5, and the density matrix of $`|0`$, $`\rho _\text{p}`$, is given by

$$\begin{array}{ccc}\hfill \rho _\text{p}& =& I_{1z}+I_{2z}+I_{3z}\hfill \\ & & +2I_{1z}I_{2z}+2I_{2z}I_{3z}+2I_{1z}I_{3z}+4I_{1z}I_{2z}I_{3z}\hfill \\ & =& \rho _{\text{th}}+\mathrm{\Delta }\rho .\hfill \end{array}$$
(7)   
The hard $`\pi /2`$ pulse for $`H`$ transforms terms of $`\rho _{\text{th}}`$ into single-quantum coherence and terms of $`\mathrm{\Delta }\rho `$ into multiple-quantum coherence . Since the sequences for $`U_f`$’s consist of only the soft $`z`$-pulse(s) and J-coupling(s) which are dependent only on the $`z`$-components of spin angular momentums, $`U_f`$’s do not change the order of quantum coherence. As single-quantum coherence is only observable, $`\rho _{\text{th}}`$ and $`\rho _\text{p}`$ give the same results for this case. In general, the thermal equilibrium state gives the same results with the pure state if the operation sequence after the first Hadamard operator does not change the order of quantum coherence.

The soft $`z`$-pulse and J-coupling were implemented by the time evolution under the Hamiltonian of Eq. 5 with refocusing $`\pi `$-pulses applied at suitable times during the evolution period. Since the refocusing $`\pi `$-pulse has the effect of time reversal, it can be used to make one term in the Hamiltonian evolve while the other terms “freeze” . We optimized this refocusing scheme as illustrated in Fig. 1 which shows the soft $`z`$-pulse on spin 1 and J-coupling between spin 1 and 2 as examples. The evolution time, $`T`$, is $`\theta /\mathrm{\Delta }\omega _i`$ for the soft $`z`$-pulse and $`\theta /(\pi J_{ij})`$ for the J-coupling. Previous schemes divide the evolution period into eight periods and require six pulses, or suffer from TSETSE effect  because soft pulses exciting more than one but not all spins were used. Since the difficulty of experiment increases exponentially with increasing number of pulses, especially soft pulses, our scheme greatly enhances the possibility of successful implementation. Axes of successive $`\pi `$-pulses were chosen in the way to cancel imperfections of pulses. For example, four $`\pi `$-pulses in Fig. 1(a) were applied along $`x`$, $`x`$, $`x`$, and $`x`$-axes, respectively.

In our experiment, <sup>13</sup>C nuclear spins of 99% carbon-13 labeled alanine (CH<sub>3</sub>CH(NH<sub>2</sub>)CO<sub>2</sub>H) in D<sub>2</sub>O solvent were used as qubits. NMR signals were measured by using a Bruker DRX300 spectrometer. The chemical shifts of three different carbon spins are about 5670, $`3780`$, and $`6380`$ Hz, and coupling constants $`J_{12}`$, $`J_{23}`$, and $`J_{13}`$ are 54.06, 34.86, and 1.03 Hz, respectively. Protons were decoupled during the whole experiments. Gaussian shaped soft $`\pi `$-pulses were 2 ms in length and hard pulses were about a few microsecond. The length of the total pulse sequence was about 600 ms in the worst case.

We implemented all the 35 balanced and one constant functions exactly. Fig 2 shows the results for the four functions belonging to different types shown in Table I. The lines of the spectra for the remaining functions also indicate as clearly as ones in the figure whether they are positive or negative. The balanced functions are distinguished from the constant function because some of the lines are negative. The peaks of spin 1 and 3 show up as doublets in Fig 2(a), (b) and (c) while that of spin 2 is quartet because $`J_{13}`$ is very small compared to $`J_{12}`$ and $`J_{23}`$. Fig 2(d) shows, however, that the peaks of spin 1 and 3 are in fact quartet also. They look dispersive doublets because the neighboring lines split a little by $`J_{13}`$ have different signs. These results agree well with the theoretical predictions obtained from

$$\text{Tr}(e^{ıt/\mathrm{}}\rho e^{ıt/\mathrm{}}I_+),$$
(8)   
where $`\rho `$ is the density matrix transformed by the operation sequence $`H`$-$`U_f`$ from $`\rho _{\text{th}}`$ and $`I_+=I_x+ıI_y`$.

In the implementation of the soft $`z`$-pulses and J-couplings shown in Fig. 1, the end of pulse sequence ($`t=T`$) can be clearly defined for the J-coupling but not for the soft $`z`$-pulse, because the last pulse of soft $`z`$-pulse is a soft pulse which is much longer than a hard pulse. Therefore, whole pulse sequence was arranged to finish with the J-coupling. Our refocusing scheme decreases the length of the total pulse sequence and therefore, reduces signal decay due to decoherence. Imperfection of soft pulses is thought to be the main source of the phase error and the decay of signal amplitude of some lines. This imperfection is more serious in the J-coupling than in the soft $`z`$-pulse because out-of-phase multiplets are produced in the former while in-phase multiplets are produced in the latter. Therefore, it is very important to calibrate soft pulses exactly especially for long sequences.

In summary, we implemented the complete refined D-J algorithm with 3-bit arguments which involves entanglement. All the operations were realized by the time evolution under Hamiltonian with refocusing $`\pi `$-pulses. The operation sequences best for our implementation were found using generator expansion. Experimental pulse sequences were made as simple as possible by using the thermal equilibrium state and the new refocusing scheme.