# Tag Info

@ahelwer has provided a smart construction, and I will provide a more brute-force method as a complementary for beginners like me. It actually starts out by listing all the possible 16 moves. Let x,y=0,1,2,3, then all the possible moves are $x=0, \quad y=(0123)\rightarrow(0123) \\ x=1, \quad y=(0123)\rightarrow(1230) \\ x=2, \quad y=(0123)\rightarrow(2301) ... 1 The question comes in two parts. Firstly, for the top circuit, can you find the gates$A$,$B$and$C$such that$ABC=I$and$CXBXA=R_x(\theta)$or$R_y(\theta)$. Secondly, can you reduce either of these to the lower circuit with$AB=I$and$XBXA=R_x(\theta)$or$R_Y(\theta)$. The first of these is detailed in the bit of Nielsen and Chuang just before the ... 2 Note:$I_k$is unit matrix of order$k$in the following text. First step of the algorithm is$H \otimes H \otimes I_2 \otimes I_2$as you mentioned. A controlled gate$U$with$n$qubits between the control qubit and the target qubit can expressed as a matrix $$CU_{n} = \begin{pmatrix} I_{\frac{N}{2}} & O_{\frac{N}{2}} \\ O_{\frac{N}{2}} & I_{\... 0 You can use Ry (y-rotation gate). Its general matrix is$$ Ry(\theta) = \begin{pmatrix} \cos(\theta/2) & -\sin(\theta/2) \\ \sin(\theta/2) & \cos(\theta/2) \end{pmatrix} $$Applying the gate on |0\rangle state, you get a state$$ |\psi\rangle = \cos(\theta/2)|0\rangle + \sin(\theta/2)|1\rangle $$Hence \cos(\theta/2) = \frac{1}{\sqrt{3}} ... 0 Here is an implementation of a circuit producing state |\psi\rangle = \frac{1}{\sqrt{3}}(|00\rangle + |01\rangle + |10\rangle) on IBM Q: Note that \theta = 1.2310 for \mathrm{Ry} on q_0. \theta = \frac{\pi}{4} and \theta = -\frac{\pi}{4} for first and second \mathrm{Ry} on q_1. The \mathrm{Ry} on q_0 prepares qubit in superposition |... 3 Consider some simpler cases, (j,j+1) for general j. Then you can do you want with plugging in j=i, j=i+1, j=i+3 and j=i+4 and concatenating the circuits appropriately and then simplifying. So how to do (j,j+1)? That is conjugate to (0,1), so just consider that for now. (0,1) would be NOT but controlled on making sure all the higher places ... 2 A brute force solution :). You can also obtain CCH via qiskit's basic gates with help of get_controlled_circuit method. from qiskit import * from qiskit.aqua.utils.controlled_circuit import get_controlled_circuit q_reg = QuantumRegister(3, 'q') qc_h = QuantumCircuit(q_reg) qc_ch = QuantumCircuit(q_reg) qc_cch = QuantumCircuit(q_reg) qc_h.h(q_reg) ... 2 Summarization based on discussion with user met927: Transpiled circuit form depends on used backend - it is different for simulator and real quantum processor: On simulator, the \mathrm{CH} gate is transpiled to the circuit shown above On real quantum processor, the gate is implemented with two \mathrm{U2} gates and \mathrm{CNOT} (i.e. like in the ... 4 Assuming you've got Toffoli and single-qubit rotations, you can implement the following: This basically works because if either of the controls is not |1\rangle, the Toffoli does nothing and the two single-qubit unitaries cancel each other. Whereas, if both controls are |1\rangle, then the net gate on the target qubit is$$ (\cos\frac{\pi}{8}I+i\sin\... 4 Nielsen and Chuang book may be confusing; I will try to explain. Any classical algorithm can be presented as a circuit consisting of$NOT$and$AND$gates; this means that if we can make quantum gates computing$NOT$and$AND$, and make fanout, we can run any classical algorithm on quantum computer.$NOT$is reversible and we have quantum$NOT$gate; many ... 1 Based on paper Five Two-Bit Quantum Gates are Sucient to Implement the Quantum Fredkin Gate provided by Norbert Schuch, I realized that there is a more efficient implementation in terms of number of gates. Here is a result: Matrix of CNOT acting on$|q_1\rangle$controlled by$|q_2\rangle\$ is \begin{equation} CNOT_{2}= \begin{pmatrix} 1 & 0 & 0 &...