# Tag Info

## Hot answers tagged circuit-construction

11

The case of 1 qubit turns out to be pretty bad for understanding Grover's algorithm. There are several scenarios for the function you're looking at: Both inputs are solutions to $f(x) = 1$. The classical solution takes one function evaluation, so there is no speedup. Both inputs are not solutions. No matter how many iterations you do, Grover's algorithm is ...

9

Do you mean mapping the state $|0\rangle^{\otimes n} \to \dfrac{1}{\sqrt{2^n}}\sum_{i=0}^{2^n-1} |i\rangle$ ? If that is the case then you can just apply $H^{\otimes n}$ to the state $|0\rangle^{\otimes n}$. That is, you apply a Hadamard gate to each of the qubit. The reason for this is $H |0\rangle = \dfrac{|0\rangle + |1\rangle}{\sqrt{2}}$ and so \begin{...

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

7

I don't know if the MIP* = RE result, and in particular the claim that there exists a nonlocal game $G$ where $\omega^*(G) \neq \omega^{co}(G)$, has any algorithmic implications for quantum computers. There's a couple things to say here. The MIP* = RE result is about what computational problems can be verified using nonlocal games, as opposed to what can be ...

7

As a general rule, you wouldn't bother constructing this: it is just a global phase that has no observable consequence. If you really insist on doing this, introduce an ancilla qubit in the $|1\rangle$ state and apply a $Z$ gate to it. PS "inverse identity gate" is a really bad name for it. The identity operation is its own inverse.

7

You can think of the circuit operation as follows. Remembering that for Hadamard matrix: $H \times H = \mathbb{I}$, your circuit looks like the following: $$H \otimes \mathbb{I} \otimes \mathbb{I}(CCNOT(H|0\rangle \otimes H|0\rangle \otimes |0\rangle ))$$ Let's focus on the inner-most part first: $$H|0\rangle \otimes H|0\rangle \otimes |0\rangle \\ =\frac{... 7 Starting with the state |\psi_0 \rangle = |0\rangle, and we want to get to the state |\psi_f \rangle = \dfrac{|0\rangle + i|1\rangle}{\sqrt{2}} then we must realize that we need to create some sort of a superposition between the state |0\rangle and the state |1\rangle. This is where the Hadamard gate will come into play. The Hadamard gate which ... 6 Step 1: Find the Schmidt decomposition |\psi\rangle=\sum_i\alpha_i|u_i\rangle|v_i\rangle. I won't do this completely here, but$$ \alpha_0=\sqrt{\frac{3+\sqrt{5}}{6}},\qquad |u_0\rangle=|v_0\rangle=\frac{1}{\sqrt{10-2\sqrt{5}}}(2|0\rangle+(\sqrt{5}-1)|1\rangle) $$should be enough to confirm you're going in the right direction. Step 2: Express this as (... 6 The task that you describe in your question — a circuit which flips a single qubit, if and only if the two input states are different — is not possible. We can show this as follows. First, there is no way to distinguish two states which differ only by a global phase, because no quantum operations can distinguish between two state-vectors which only differ in ... 6 If I understand your question correcly, you are asking for a unitary that, in effect, looks at amplitudes in the computational basis, which are assumed to all be real, and if they are positive, make them negative. This, quite simply, is impossible for a unitary. To see this, note that you would have (in the 1-qubit case, although you can do exactly the same ... 6 If one of your controls is in the plus state, or your target is in the zero state, you can decompose inline using four T gates instead of seven T gates. For example, this circuit outputs the same thing as applying a Toffoli: (Of course if you input a state other than |+\rangle for that second qubit, the result won't be correct.) I don't think it's ... 6 No, this is impossible, because it violates the no-cloning theorem. You want to implement the function$$ |A_0\rangle|A_1\rangle|i\rangle|0\rangle \mapsto |A_0\rangle|A_1\rangle|i\rangle|A_i\rangle, $$but if you could do that you could also clone, e.g. by fixing i=0, which would make the function be$$ |A_0\rangle|A_1\rangle|i\rangle|0\rangle \mapsto |A_0\...

6

You can use a single step of amplitude amplification, with a less-than-N oracle, to get to a uniform distribution. Example Quirk Circuit Source: https://arxiv.org/abs/1805.03662

5

I don't know if that's still useful but I've been asking this to myself recently and I've found a simple answer. If you want to prepare the mixed state $$\rho = \frac{1}{d}\sum_{i}^{d} |i\rangle\langle i|$$ you can start by preparing the maximally entangled pure state $$|\varphi\rangle = \frac{1}{\sqrt{d}}\sum_{i}^{d} |i\rangle|i\rangle$$ The density matrix ...

5

We can't implement $e^{iZ_1 \otimes Z_2 \otimes Z_3 \theta}$ with three separate rotations. In other words: $$e^{iZ_1 \otimes Z_2 \otimes Z_3 \theta} \ne e^{i Z_1 \theta} \otimes e^{i Z_2 \theta} \otimes e^{i Z_3 \theta}$$ The implementation of this gate can be found in this answer. The $e^{-iI \otimes I \otimes I\theta} = e^{-i\theta} I \otimes I \otimes I$ ...

5

If you look carefully, the circuit just flips the least significant qubit if the parity of the two most significant qubits is one. So, using qiskit: from qiskit import QuantumCircuit from qiskit.quantum_info import Operator qc = QuantumCircuit(4) qc.cx(2, 0) qc.cx(3, 0) print(qc) U = Operator(qc).data print(U.real) --- Output: ┌───┐┌───┐ q_0: ┤ X ├┤ ...

5

It can't be done in one or two uses of the iSwap because an iSwap is equivalent (up to single qubit rotations) to a SWAP+CZ. A single SWAP+CZ is not a swap. The two swaps in a pair of SWAP+CZs cancel out, leaving you with two CZs (and arbitry single qubit operations around them), which is also not enough to do a swap. But you can do it with three:

5

Note 100% sure if this is what you are asking but when you have a circuit like: and you want to write it as a $4 \times 4$ Unitary matrix $U$ then you can do it as: $U = R_y(a) \otimes R_z(a)$ This can be generalized to any size as well. So if you have then it can be written as an $8 \times 8$ matrix $U$ as $U = R_y(a) \otimes R_z(a) \... 5 The circuit to prepare the state$|\psi \rangle = \dfrac{|01\rangle + |10\rangle}{\sqrt{2}} is as follows: ┌───┐ q_0: ┤ H ├──■─────── └───┘┌─┴─┐┌───┐ q_1: ─────┤ X ├┤ X ├ └───┘└───┘ This can be written in matrix notation as: \begin{align} U &= (I \otimes X)\cdot CNOT \cdot (H\otimes I) \\ &= \begin{pmatrix} 1 & 0 ... 5 You can specify the target basis for instance using transpile: from qiskit import transpile target_basis = ['rx', 'ry', 'rz', 'h', 'cx'] decomposed = transpile(circuit, basis_gates=target_basis, optimization_level=0) # 0 for no optimization, 3 is max Note that the target basis should be complete (e.g. rz h ... 5 Suppose\langle\phi|\psi\rangle = re^{i\theta}$. As you have noticed, if we have access to multiple copies of the state, then we can measure$r$using the SWAP test. Now, consider the state$|\psi'\rangle = e^{-i\theta}|\psi\rangle$and note that $$\langle\phi|\psi'\rangle = e^{-i\theta}\langle\phi|\psi\rangle = e^{-i\theta}re^{i\theta} = r.$$ Since$|\...

4

I did not thought much about that issue, so my answer may not be the best one, but it has the advantage of being quite simple to understand, it is exact even if you restrict yourself to Clifford+T, and can be generalized to more complicated relations. On the other side, this is not a unitary process because you need to repeat it a polynomial number of times ...

4

As Michele Amoretti correctly says, Quantikz is built on top of Tikz. It cannot do anything that Tikz cannot. It is simply intended to provide a wrapper that makes it more convenient for doing the specific tasks associated with drawing quantum circuits. More specifically, it's done in a way that I find most convenient (as the package author!). Mostly it came ...

4

In general, you want to understand the process by which you compute the matrix elements if you were doing it by hand. In the example you give, for instance, you're effectively computing $|i-j|==1$. This has a classical algorithm which you can figure out, and there's your oracle. In this specific instance there are probably some smarter things you can do. For ...

4

By using similar ideas from this answer I have found this circuit: Thought process: The unitary is a permutation matrix that doesn't change bitstrings except $U |100\rangle \rightarrow |011\rangle$ and $U |011\rangle \rightarrow |100\rangle$ (identity action on the rest of the bitstrings). Here I am going to use Qiskit's indexing convention (qubit indexing ...

4

While you can get the unitary matrix representation of a circuit using the unitary simulator as shown in the other answers, there is a much easier way using the Operator class in the qiskit.quantum_info library. import qiskit.quantum_info as qi op = qi.Operator(circ) If you want the numpy array of the operator, this can be obtained via the data attribute (...

4

The circuit to simulate the term $e^{i Z \otimes Z t}$ can be construct as and the circuit to simulate the term $e^{i X \otimes Y t}$ can be construct as Now to simulate $H = X \otimes Y + Z \otimes Z$, we can use Trotter approx with one time slice to get the following circuit to approximate $e^{i (X \otimes Y + Z \otimes Z) t}$ : Now as commented by @...

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

For preference, in a phase estimation algorithm, you would set the state of the second register equal to an eigenstate of the unitary operator $U$, the plan being to find its eigenvalue, which depends on the period $r$. In fact, any of the eigenvectors $|u_s\rangle$ would do for values $s=0,1,\ldots r-1$ as these have eigenvalues related to $s/r$. However, ...

4

This very much depends on whether you know the phase $\alpha$ (which I assume is not intended to be the same as the amplitude $\alpha$!). If you do not know the phase $\alpha$, then the operation that you're asking about is the transpose. This is well known to be physically impossible (it's typically the first example given if you read about completely ...

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