New answers tagged


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


You can check that the following is equal to a CNOT 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.


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:


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


Have a look at this article - seems like it's exactly what you are looking for.


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

Top 50 recent answers are included