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 ...


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 ...


9

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 - ...


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 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

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 | \...


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

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(...


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 ...


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

This is known as "Phase Kickback" in quantum computing. It is a trick that uses in a many quantum algorithms. The phase of the target qubit can kickback to the control-qubit and changes the phase of it. Take a look here: Phase Kickback


3

Short answer: both can be correct, depending on the state to which the CNOT gate is applied. At the first slide the presentation talks about the effect of CNOT gate on basis states. And indeed, if the input to the CNOT gate is a basis state, it only changes the state of the target qubit. At the second slide, the CNOT gate is applied to a superposition of ...


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

This is because the CNOT gate created an an entangled state and the system after the CNOT gate can't be written individually. That is, you can't stay that your first qubit is in the state $\dfrac{|0\rangle + |1\rangle}{\sqrt{2}}$ anymore. That is consider the circuit: Here $q_0 $ and $q_1$ both start in the state $|0\rangle$. So you start with the initial ...


3

I received a great answer to my question here, through the Xanadu Discussion Forum: I’d say that your approach of having a quantum function that depends on the number of wires, creating separate QNodes and devices is a good one. PennyLane doesn’t have any further conveniences for such a use case, other than creating a QNodeCollection which you’ve mentioned. ...


3

Let $\rho$ be an arbitrary single-qubit state. Since $\rho$ is Hermitian it has real eigenvalues and an orthonormal eigenbasis in which it is diagonal $$ \rho = \lambda_1 |\psi\rangle\langle\psi| + \lambda_2 |\psi^\perp\rangle\langle\psi^\perp| $$ and since it has unit trace $\lambda_1 + \lambda_2 = 1$. Thus we can find an angle $\beta$ such that $\lambda_1 =...


3

The short answer is that the circuit drawer does not have a way to label "sections". However, you can pass an arbitrary matplotlib.axes.Axes to the Matplotlib circuit drawer (only to that circuit drawer) where you can set and position your labels by hand. For your particular case, it looks something like this: from matplotlib.pyplot import figure ...


3

Yes, that is right. If you think about it, $CNOT|x\rangle |s\rangle = |x\rangle|x \oplus s \rangle \ $. Thus, giving a secret bitstring $s = s_1 s_2 \cdots s_n$ where $s_i \in \{0,1\}$, then whenever $s_i$ is non-zero ($s_i = 1$), performing a CNOT gate between the ancilla qubit and the $ith$ qubit in your input qubits (note that you have $n$ input qubits ...


3

The Hadamard gate is its own inverse. Hence, the two Hadamards on the first qubit cancel, leaving the control qubit in state $|0 \rangle$. The bottom Hadamard gate will put the target qubit in the state $\frac{1}{\sqrt{2}} (|0\rangle + |1\rangle)$. Since the control qubit is still in state $|0\rangle$, the CNOT will do nothing to the target. Your output ...


3

The entanglement measure that you quote from IBM is equivalent to the "linear entropy" of the reduced system. The idea is that, if you have a pure quantum state and you trace out one of the subsystems, the resulting state will be pure if the original state had no entanglement. Conversely, if the resulting state is not pure, you know the original ...


3

The reason for this is that the actual oracle used in the algorithm is not obtained from oracle.to_operator(). If you look up the code for Grover's algorithm, you can see the following: grover_operator = GroverOperator(oracle=oracle, state_preparation=state_preparation, reflection_qubits=...


3

Two states that are the same up to a global phase are physically indistinguishable; some even go as far as to say that they are exactly the same state. Any $U_{1}$ and $U_{2} = e^{i\alpha}U_{1}$ will thus give physically indistinguishable states, meaning that there is nothing that $U_{2}$ can do that $U_{1}$ cannot. Would a quantum processor restricted to ...


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