Quantum Computing Asked by bg827 on February 18, 2021
The Hadamard gate allows us to construct an equal superposition of states. If one wants to construct an arbitrary superposition e.g. $alphavert 0rangle + betavert 1rangle + ..$, how does one create the corresponding unitary?
Such a unitary should act on $vert 0rangle$ and output the desired state. Also, in more generality, it should take in $vert 0rangle^{otimes n}$ and output some coherent superposition state of my choice.
I ask this question since many quantum algorithms encode a classical vector $(x_1, x_2,… x_n)$ into a quantum state $sum_i x_ivert irangle$ but this step itself seems hard to achieve.
If you want to generate a state $|psirangle$ from $|0rangle$, you can use any unitary whose first column is $|psirangle$ (assuming you are using a convention in which $|0rangle$ represents the first row/column, as is usually done).
More generally, if you are looking for a unitary $U$ such that $U|psirangle=|phirangle$ for some given $|psirangle$ and $|phirangle$, you can choose any $U$ of the form $$ U = |phirangle!langlepsi| + U'$$ where $U'=sum_j |phi_jrangle!langle psi_j|$ for any choice of orthonormal bases ${|phi_jrangle}_j$ and ${|psi_jrangle}_j$ which span the spaces $|phirangle_perp$ and $|psirangle_perp$, respectively.
Correct answer by glS on February 18, 2021
To create arbitrary one qubit state you can use combination of $Rz$ and $Ry$ gates. $Ry(theta)$ gate takes state $|0rangle$ to $cos(theta/2)|0rangle + sin(theta/2)|1rangle$. By setting angle $theta$ you achive desired probabilities of states $|0rangle$ and $|1rangle$. If you now apply $Rz(varphi)$ gate you get state $mathrm{e}^{-ivarphi/2}cos(theta/2)|0rangle + mathrm{e}^{ivarphi/2}sin(theta/2)|1rangle$ which is equivalent to $$ cos(theta/2)|0rangle + mathrm{e}^{ivarphi}sin(theta/2)|1rangle $$ because global phase can be neglected. Hence by setting angles $varphi$ you can set any phase you want. Overall, the state above is the most general description of a qubit. So, this method allows you to prepare one qubit in any state you want.
Note that on IBM Q you can employ gate $U3$ instead.
To prepare multiqubit state is more difficult. You can follow a method in this article: Transformation of quantum states using uniformly controlled rotations.
In Qiskit, you can use a method initialize
to set a quantum circuit input state:
quantumState = [
1 / math.sqrt(2) * complex(1, 0),
1 / 2 * complex(1, 1)]
q = QuantumRegister(1, name = 'q')
c = ClassicalRegister(1, name = 'c')
circuit = QuantumCircuit(q,c)
circuit.initialize(quantumState, [q[0]])
In this case, one qubit state is prepared, however, matrix quantumState
can be for example
[1 / math.sqrt(2), 0, 0, 1 / math.sqrt(2)]
for Bell state $frac{1}{sqrt{2}}(|00rangle+|11rangle)$.
Answered by Martin Vesely on February 18, 2021
Short answer: Really good question! We know how to do it in exponential time (details below) but there is a lot of ongoing research on how to do it in polynomial time.
Longer answer: If you want to use gates, you can always encode it in exponentially many time steps using a combination of controlled $R_x, R_y$ and $R_z$ gates. As an example, try creating the state $$sqrt{frac{1}{8}}|00rangle + sqrt{frac{1}{8}}|01rangle + sqrt{frac{5}{8}}|10rangle + sqrt{frac{1}{8}}|11rangle$$ using only $R_y$ and controlled-$R_y$ gates. However for a general case with more quibts this can quickly turn into a very long circuit! There are some ways to load the right state in polynomial time given certain assumptions about the state. But this is an ongoing research question that many of us are working on! For a few ideas out there you can see e.g. the following references:
Answered by Rajiv Krishnakumar on February 18, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP