# Tag Info

## Hot answers tagged circuit-construction

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

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 $|\... 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 ... 4 You can check that the following is equal to a CNOT gate (the mid-part being the controlled$Z$-gate) The first Hadamard gate rotates$q_1$to the$X$-basis. In that basis, the$Z$-gate acts like a bit flip (the same way the$X$-gate acts in the$Z$-basis). The second Hadamard rotates$q_1$back to$Z$-basis. 2 @Durd3nT answered the question nicely. But here is another way to see it, and hopefully it will be useful for future purposes... All you need to know is the identity$X = HZH$. Then now you can see that$CNOT (CX)$can be rewritten as $$CX = \big( I \otimes H \big) CZ \big( I \otimes H \big)$$ This is because when the controlled-qubit is in the state$|0\...

1

Based on the advice by DaftWullie, I added Hadamards on the target and one of the control qubits. The trick is that the Toffoli gate is in fact a controlled CNOT. So we can leave one of control qubit unchanged and consider the rest of the gate as a CNOT. Then, we can apply the same approach as in the case of an "upside-down" CNOT. Here are the ...

1

Have a look at this article https://qibo.readthedocs.io/en/stable/tutorials/hash-grover/README.html - seems like it's exactly what you are looking for.

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