2
$\begingroup$

I apologize for a simple question, should be quite trivial. How do I construct a circuit for preparing such a state? $$ |0\rangle^n \mapsto \cos(\theta)|0...0\underset{i}{1}0...0\rangle + \sin(\theta) |0...0\underset{j}{1}0...0\rangle \ , $$ where the $i$th and $j$th qubits are in the $|1\rangle$ state.

$\endgroup$
3
$\begingroup$

Here is an example of such circuit for five qubits.

Circuit

A gate $Ry$ acting on qubit $q_1$ prepares superposition

$$ \cos(\theta/2)|0\rangle + \sin(\theta/2)|1\rangle. $$

When qubit $q_1$ is in state $|0\rangle$ (with probability $\cos^2(\theta/2)$), qubit $q_3$ is in state $|1\rangle$ thanks to gate $X$.

When qubit $q_1$ is in state $|1\rangle$ (with probability $\sin^2(\theta/2)$), qubit $q_3$ is in state $|0\rangle$ thanks to gate $X$ and CNOT gate (two negation is equal to no negation).

Other qubits are not changed and remain in state $|0\rangle$. As a result, the circuit produce state $$ \cos(\theta/2)|00010\rangle + \sin(\theta/2)|01000\rangle. $$

You can construct similar circuit for any positions $i$ and $j$ simply by putting $Ry$ gate with proper parameter $\theta$ on one qubit, gate $X$ on second qubit and then "connect" them with CNOT gate.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Thanks, exactly what I needed! $\endgroup$ – mavzolej Apr 15 at 15:01

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.