1
$\begingroup$

I am trying to create a Qiskit circuit that:

  • starting in state |00⟩ generates a 1/2 * (|00⟩ - |01⟩ - |10⟩ + |11⟩) state

  • starting in state |10⟩ generates a 1/2 * (|00⟩ + |01⟩ - |10⟩ -|11⟩) state

  • starting in state |01⟩ transforms to a 1/2 * (|00⟩ -|01⟩ + |10⟩ - |11⟩) state

  • starting in state |11⟩ transforms to a 1/2 * (|00⟩ + |01⟩ + |10⟩ + |11⟩) state

I do not know where to start and how to think about this problem.

$\endgroup$
3
  • $\begingroup$ I'm not sure, but it seems that the states $|01\rangle$ and $|10\rangle$ are switched. Any way, my answer below is based on the question as it is now. $\endgroup$ Apr 16 at 13:41
  • $\begingroup$ This should remind you the quantum Fourier transform without the phases and the 0, 1 states swapped. Therefore the circuit is just (XX)(HH) $\endgroup$
    – Eelvex
    Apr 16 at 17:30
  • $\begingroup$ related: quantumcomputing.stackexchange.com/q/25980/55 $\endgroup$
    – glS
    Apr 17 at 10:11

2 Answers 2

2
$\begingroup$

Note that $H|0\rangle = \dfrac{|0\rangle + |1\rangle}{\sqrt{2}}$ and $Z|0\rangle = |0\rangle$ and $Z|1\rangle = -|1\rangle$. So from here you can see that

$$ (H\otimes H) |00 \rangle = H|0\rangle \otimes H|0\rangle = \dfrac{|0\rangle + |1\rangle}{\sqrt{2}}\otimes \dfrac{|0\rangle + |1\rangle}{\sqrt{2}} = \dfrac{|00\rangle + |01\rangle + |10\rangle + |11\rangle}{2}$$

then

$$(Z \otimes Z) \dfrac{|00\rangle + |01\rangle + |10\rangle + |11\rangle}{2} = \dfrac{|00\rangle - |01\rangle - |10\rangle + |11\rangle}{2} $$

therefore to create the state $|\psi \rangle = \dfrac{|00\rangle - |01\rangle - |10\rangle + |11\rangle}{2} $ from the initial state $|\psi_0 \rangle = |00\rangle$ you just need to perform the following circuit:

enter image description here


Similarly, if you start with the state $|\psi_0 \rangle = |10\rangle$ and you want to get to the state $|\psi \rangle = \dfrac{|00\rangle + |01\rangle - |10\rangle - |11\rangle}{2} $ then you can use the additional fact that $H|1\rangle = \dfrac{|0\rangle - |1\rangle}{\sqrt{2}}$ and so

$$ (H\otimes H) |10 \rangle = H|1\rangle \otimes H|0\rangle = \dfrac{|0\rangle - |1\rangle}{\sqrt{2}}\otimes \dfrac{|0\rangle + |1\rangle}{\sqrt{2}} = \dfrac{|00\rangle + |01\rangle - |10\rangle - |11\rangle}{2}$$

enter image description here

**Note that the circuit is in little endian convention (read bottom to top).

I will leave the other two cases for you to try.

$\endgroup$
1
  • $\begingroup$ Thanks for the answer. It seems that I need to cover four scenarios in one circuit. Is it possible? $\endgroup$
    – Hamideh
    Apr 16 at 12:35
0
$\begingroup$

One way to do that using Qiskit is to write down the unitary matrix which transforms input states to output states then using QuantumCircuit.unitary()[1] method.

The unitary should be $4\times4$. First column corresponds to the output of the $|00\rangle$ state. Second column corresponds to the output of the $|01\rangle$ state. And so on.

Try to do it yourself then verify the result is: \begin{bmatrix} 0.5 & 0.5 & 0.5 & 0.5 \\ -0.5 & -0.5 & 0.5 & 0.5 \\ -0.5 & 0.5 & -0.5 & 0.5 \\ 0.5 & -0.5 & -0.5 & 0.5 \\ \end{bmatrix}

Now create the circuit:

matrix = [
    [ 0.5,  0.5,  0.5, 0.5],
    [-0.5, -0.5,  0.5, 0.5],
    [-0.5,  0.5, -0.5, 0.5],
    [ 0.5, -0.5, -0.5, 0.5],
]

# Create the circuit:
circ = QuantumCircuit(2)
circ.unitary(matrix, [0, 1])

# Draw it:
circ.decompose().draw('mpl')

To verify the end result you can simulate it using StatevectorSimulator[2]. However, for small circuits like the one we have here, there is a simpler way:

from qiskit.quantum_info import Statevector
from qiskit.quantum_info.operators import Operator

Statevector.from_label('00').evolve(circ).draw('latex')

You can put 01, 10, or 11 instead of 00 to check the result.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.