2

Is there there any way to create a known quantum state in Qiskit (or any other platform) comprising of two or more than two bit?

For example if I want to create $\frac{1}{\sqrt{3}}[|00\rangle+|01\rangle+|11\rangle]$. What I want to do is to know the unitary transformation ( or the quantum circuit) to prepare this (or any valid) quantum state for me.

glS
  • 24,708
  • 5
  • 34
  • 108

1 Answers1

1

As Martin Vesely mentioned in the comments, you can use the initialize function to perform such a task. For instance, to create the state you desire, you can do the following:

import numpy as np
from qiskit import QuantumCircuit
from qiskit.transpiler.passes import Decompose

qc = QuantumCircuit(2) initial_state = np.array([1, 1, 0, 1], dtype=float) initial_state /= np.linalg.norm(initial_state) qc.initialize(initial_state) qc.decompose().decompose().decompose().decompose().draw("mpl")

which draws the following output:

Decomposed circuit

To know how does qiskit create this unitary, have a look at this answer.

Tristan Nemoz
  • 6,137
  • 2
  • 9
  • 32