14

The depth of a circuit is the longest path in the circuit. The path length is always an integer number, representing the number of gates it has to execute in that path. For example, the following circuit has depth 3: if you look at the second qubit, there are 3 gates acting upon it. First by the CNOT gate, then by the RZ gate, then by another CNOT gate. A ...


10

Correct, unitarity is a sufficient and necessary condition. From Nielson and Chuang page 18: Amazingly, this unitary constraint is the only constraint on quantum gates. Any unitary matrix specifies a valid quantum gate! The interesting implication is that in contrast to the classical case, where only one non-trivial single bit gate exists - the NOT gate - ...


9

Consider a quantum circuit on one qubit initialized in the state $|0\rangle$ and consisting of two Hadamard gates where we can insert a measurement between the Hadamards. The input state is $|0\rangle$, so the state after the first Hadamard gate is $$ H|0\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) $$ which is an equal superposition of $|0\rangle$ and ...


8

You certainly could use Grover's search. You would create 2 registers. This first, of 3 qubits, would effectively store the $\{s_0,s_1,s_2\}$. This is the standard register for Grovers on which you apply the Grover iterator. Then, you'd have a second register of at least 3 qubits. You construct the search oracle by evaluating the matrix multiplication on the ...


7

As Davit Khachatryan's answer points out, the task is impossible / ill-defined, since the desired target state is generally not normalized and it depends on the relative global phases of the two initial states. However, it is possible to rephrase the question so that is meaningful and has an interesting answer. The two problems -- sensitivity to the global ...


7

Right. But when you build a quantum computer, you want to have a certain set of gates that you want to implement, and all other gates (unitary matrices) can be built from that set of gates. This is known as a universal set. Surprisingly (or not), it is quite small. One example of a universal set is: $G = \{H, S, T, CNOT \}$ where $$H = \dfrac{1}{\sqrt{2}}\...


7

You can add a barrier before the measure from qiskit import * circuit_three = QuantumCircuit(5, 5) circuit_three.h(0) for i in range(1, 5): circuit_three.cx(0, i) circuit_three.barrier() <--- add this line for i in range(0, 5): <--- side note: this can be replaced by circuit_three.measure_all() circuit_three.measure(i, i) circuit_three.draw(...


7

The same could be said about any classically computable function. We could use the Cook-Levin theorem to unroll any Turing machine into a single but complicated $n$-input gate, and then claim it's $o(1)$. Thus because we don't want this silly exception, usually when speaking of $\mathrm{BQP}$ or $\mathrm{P}$ in a circuit model, we have to limit our gate set ...


6

It's a fantastic question because the typical measurement intuition we apply no longer is sufficient - it's really necessary to formalize measurement. Specifically, we create a set of nonlinear operators $M_\psi = |\psi \rangle \langle \psi |$, where the probability of measuring $\psi$ on an arbitrary state $|\phi\rangle $ is $\langle \phi | M^\dagger M | \...


6

As mentioned in the other answer, the Hadamard gate is a pi rotation (180 degree) around the $X + Z$ axis. That is, it is a 180 degree rotation around the purple axis indicated in the below figure: And the $Rx(\pi/2)$ follows by a $Rz(\pi/2)$ then follow by $Rx(\pi/2)$ does exactly this rotation as well. To have better visualization of this, suppose I ...


6

The first diagram is a generic construction showing how it is possible to build a $\mathsf{CC}\mathbf{U}$ gate, which is the gate that applies $\mathbf{U}$ to the third qubit only if both first qubits are in state $|1\rangle$. It uses the controlled version of the $\mathbf{V}$ gate (and its inverse), which is a gate such that: $$\mathbf{V}^2=\mathbf{U}$$ You ...


6

You could almost do it. In fact, the following circuit would work: You can convince yourself that what you do is in fact applying the unitary $\mathbf{VUV^\dagger}$, which will allow you to evaluate the real part of $\langle\psi|\mathbf{V^\dagger UV}|\psi\rangle$. Indeed, the standard Hadamard test allows you to evaluate the real part of $\langle\psi|\...


6

If you are trying to implement a fault-tolerant quantum computation, you need to implement unitary gates that act on logical qubits. You typically have a finite set of these gates available, and what you really care about is making your operations in such a way as to keep the fault-tolerant threshold as small as possible. If you calculate a fault-tolerant ...


5

The picture has two parts: The first goes until the dots. It is simply three $|0\rangle$ states. (The ground state.) You will recognize that the same picture -- but only until the dot -- is used in panel b) and c) of the same figure. After the dot, there is a second part of the circuit -- starting with the open half-circles -- which describes the measurement/...


5

A counterexample that shows that this is not possible in the general case (here I am neglecting post-selection possibility discussed in the comments of the question and in the accepted answer): $$ C_1 = X \qquad C_2 = -X$$ Or one can take $C_2 = R_y(- \pi)$ and all mentioned below equations will reamin true. So: $$C_1 |0\rangle = |1\rangle = |\psi \rangle \...


5

At the start of the circuit you're right that you only need two parameters. This is actually easy to show if you decompose into a sequence of rotations starting with a Z rotation, because Z rotations have no effect on $|0\rangle$, so clearly that Z rotation angle would be irrelevant. But in the middle of a circuit, a gate is likely operating on a state that ...


4

If the first qubit is in state $|1\rangle$, i.e. the input state $|100\rangle$ then resulting GHZ state is $\frac{1}{\sqrt{2}}(|000\rangle - |111\rangle)$, i.e. the phase is $\pi$. To have phase $0$, $Z$ has to be applied but this gate is not allowed. But you can use controlled $Z$ which is composed only with $H$ and $CNOT$. The circuit is this A part ...


4

You can also just convert it to matrix representation and show that the two matrix are the same. Circuit 1: This have $q_1$ as the controlled qubit and so it has the matrix representation as unitary matrix $U_1$: \begin{align} U_1 = CNOT_{q_1, q_0} &= I \otimes |0\rangle\langle0| + X \otimes |1 \rangle \langle 1| = \begin{pmatrix} 1 & 0 & 0 &...


4

I am not sure why, but you cannot add controls to $T$ or $S$ (and their inverses) in the composer. What you can do is instead use the Phase gate (which you can add a control to) and set these angles for identical behaviour: $P(\pi/2) = S$ $P(\pi/4) = T$ $P(-\pi/2) = S^\dagger$ $P(-\pi/4) = T^\dagger$


4

Qiskit includes an adder in the circuit library. Here is a quick introduction to it. Let's say you wan to add two numbers, one of them is three-bit-long, the other one two-bit-long numbers. You will need a 5 qubit adder. That's the first parameter to qiskit.circuit.library.WeightedAdder. The second parameter is the weight of each of these qubits. Because the ...


4

First of all, let us consider an arbitrary unitary $U$. If we first apply $U$ and then measure a POVM $\{E_a\}$, then this is equivalent to doing nothing and measuring the POVM $\{U^\dagger E_a U\}$ instead since $\mathrm{Pr}[a|\rho] = \mathrm{tr}\left( E_aU \rho U^\dagger \right) = \mathrm{tr}\left( U^\dagger E_a U \rho \right)$. In particular, a Pauli ...


4

I think the concept you are searching for is classically controlled gate, also known as conditional gate. A conditional gate only has an effect if a classical value matches a predefine result. In your case, $U2$ is conditioned by $\sigma_1$, for example. You can model that in Qiskit in the following way. First, define your $U$s from qiskit import ...


4

Any gate in the circuit can be seen as an element of SU(2), ignoring the global phase. Hence Hadamard gate can be changed into $$\sqrt{1/2}\begin{pmatrix} i & i\\ i & -i \end{pmatrix}.$$ And any element of SU(2) $\begin{pmatrix} a & b\\ -b^* & a^* \end{pmatrix}$can be changed into SO(3) with the formula below, which you can find it in some ...


4

The Hadamard and the CZ gates don't commute with each other. So, it is not possible to just push it back straightforwardly. If you are still interested in obtaining a unitary U such that: $H.CZ=CZ.U$, that is possible. In particular, you can use the propagation relations $$H=\frac{X+Z}{\sqrt{2}}\;,\quad CZ_{a,b}\,X_a\,CZ_{a,b}=X_aZ_b$$ to arrive at the ...


4

tl;dr Indeed, if at any point one would need to compute and store $2^n\times2^n$ unitary of the circuit in memory that would be infeasible and render the quantum computation obsolete (it may still be useful for benchmarking NISQ computers though). Transpilation mostly works either with individual 1- and 2-qubit gates or with the whole circuit but not as a ...


4

Let me try to reformulate your question: Given a Universal Set of Quantum Gates $\mathcal{G}$; and some $n$-bit Unitary $U$. Can we find some $q$ such that $q$ is the minimum number of gates selected from $\mathcal{G}$ to have the effect of $U$ on $n$ qubits? (Note: I changed some variables since typically $n$ is the number of bits and $N=2^n$ is the ...


4

Theoretical lower bound In contrast to the answer by Bertrand, I will assume that along with a $CNOT$ gate we have arbitrary single-qubit unitaries on our disposal. In this case, one can derive the theoretical lower bound on the number of $CNOTs$ neseccary to decompose an arbitrary $n$-qubit unitary $$ L:=\#\text{CNOTs} \geq \frac14\left(4^n-3n-1\right) \...


3

Applying a NOT gate to every qubit in an $n$ bit register performs the transformation $f(x) = 2^n - 1 - x$. In this case that's $f(x) = 16-1-x = -x \pmod{15}$. So the NOT gates are equivalent to negating. The triplets of CNOTs are performing swaps and the swaps implement a right-rotate: An $n$ bit right-rotate is equivalent to multiplying by the ...


3

When initializing the registers for the quantum circuit you need to set the parameter 'name'. For example: f_in = QuantumRegister(n, name='f_in') ###add other registers here### qc = QuantumCircuit(f_in, ...) qc.draw(ouput='mpl') Gives the output:


3

Let's take a look at the part of the diffusion operator between the columns of Hadamard gates. This part is supposed to perform a conditional phase shift, giving a phase of $-1$ to the state $|0...0\rangle$ and leaving the rest of the basis states unmodified. For the first circuit, the bottom 3 wires are controls, wrapped in NOT gates, i.e., they are anti-...


Only top voted, non community-wiki answers of a minimum length are eligible