4

This is actually very easy in Cirq. The controlled_by method can be used to automatically make any given gate controlled by an arbitrary number of control qubits. Here is a simple example for creating an X gate with 5 controls: import cirq qb = [cirq.LineQubit(i) for i in range(6)] cnX = cirq.X.controlled_by(qb[0], qb[1], qb[2], qb[3], qb[4]); circuit = ...


3

Yes, any classical algorithm can be implemented as a quantum circuit with almost same efficiency. At first, we make our algorithm reversible (just include input as part of the output). Then represent it as a classical logic circuit and then modify this circuit such that it will contain only reversible classical logical gates https://en.wikipedia.org/wiki/...


3

One problem is that you are resetting the $\left|z\right\rangle$ register after applying the Controlled X(z, y) operation. Right before you reset, your $\left|z\right\rangle$ register is entangled with the other two registers, such that resetting in that way collapses any superposition on the $\left|x\right\rangle \left|y\right\rangle$ registers. While that'...


3

You could do something like: assume the most significant bit of $s$ is 1. write a function that says "if the most significant bit of $x$ is 0, return $x$. if the most significant bit of $x$ is 1, return $x\oplus s$. This is easily implemented because you start by doing a transversal set of cNOT gates to copy $x$ from the input register to the output ...


2

AHusain's answer is absolutely correct, but perhaps lacks some detail. The circuit that you want to implement is Basically, the key is to realise that you want to apply phase $e^{i\alpha}$ to the basis elements $|00\rangle$ and $|11\rangle$, and $e^{-i\alpha}$ otherwise. In other words, you care about the parity of the two bits. If you can compute that ...


2

Unfortunately this is not currently possible on the IBM devices. What you should really do is only have four classical channels and send your first two measurements to the first two classical channels, and the second two measurements to the second two classical channels. You then only execute the circuit once. However, you can try this and it still won't ...


1

$$ \begin{align} \Pr(\text{“0"}) & = \frac{1}{4} ( 2 + \left\langle \psi , \phi \mid \phi, \psi \right\rangle + \left\langle \phi , \psi \mid \psi , \phi \right\rangle ) \\ & = \frac{1}{4} ( 2 + \left\langle \psi \mid \phi \right\rangle \left\langle\phi \mid \psi\right\rangle + \left\langle \phi \mid \psi \right\rangle \left\langle\psi \...


1

When you measure, you choose a bit where the result should go. If you measure to the same bit multiple times, then the results of all but the last will not be recorded. To get the results you want, you'll need to declare more bits. For example, you could use a couple of two-bit classical registers: one for the first pair of bits, and the other for the ...


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