# Parametric circuit to prepare the most general single-qubit state [closed]

I am highly confused with this statement and spent a lot of time understanding it.

• Would be able to link where you found/saw this statement, so we can have more context for this? Feb 18 at 14:17

Let $$\rho$$ be an arbitrary single-qubit state. Since $$\rho$$ is Hermitian it has real eigenvalues and an orthonormal eigenbasis in which it is diagonal

$$\rho = \lambda_1 |\psi\rangle\langle\psi| + \lambda_2 |\psi^\perp\rangle\langle\psi^\perp|$$

and since it has unit trace $$\lambda_1 + \lambda_2 = 1$$. Thus we can find an angle $$\beta$$ such that $$\lambda_1 = \cos^2\frac{\beta}{2}$$ and $$\lambda_2 = \sin^2\frac{\beta}{2}$$. The first eigenvector can be expanded in the computational basis as

$$|\psi\rangle = \cos\frac{\theta}{2}|0\rangle + e^{i\phi}\sin\frac{\theta}{2}|1\rangle$$

and the other one is fixed up to global phase by orthonormality

$$|\psi^\perp\rangle = -\sin\frac{\theta}{2}|0\rangle + e^{i\phi}\cos\frac{\theta}{2}|1\rangle.$$

Thus, we see that $$\rho$$ is completely described by three parameters: $$\beta, \theta$$ and $$\phi$$.

Now, recall that

$$R_Y(\theta) = \begin{pmatrix} \cos\frac{\theta}{2} &-\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} &\cos\frac{\theta}{2} \end{pmatrix} \\ R_Z(\phi) = \begin{pmatrix} e^{-\frac{i\phi}{2}} & 0 \\ 0 & e^{\frac{i\phi}{2}} \end{pmatrix}$$

and so

$$U(\theta, \phi) = R_Z(\phi) R_Y(\theta) \equiv\begin{pmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ e^{i\phi}\sin\frac{\theta}{2} & e^{i\phi}\cos\frac{\theta}{2} \end{pmatrix}$$

where $$\equiv$$ denotes equivalence up to unobservable global phase. We see that $$U|0\rangle = |\psi\rangle$$ and $$U|1\rangle = |\psi^\perp\rangle$$.

This means that we can prepare a qubit in the $$\rho$$ state by first initializing a data qubit in the $$|0\rangle$$ state, applying $$X$$ gate with probability $$\lambda_2$$, applying $$R_Y(\theta)$$ and finally applying $$R_Z(\phi)$$. In practice, we can realize the probabilistic $$X$$ gate using the CNOT gate targeting the data qubit and controlled by an auxiliary qubit prepared in the state $$\cos\frac{\beta}{2}|0\rangle + \sin\frac{\beta}{2}|1\rangle$$. The preparation can be performed using $$R_Y(\beta)$$. After the CNOT gate the state of the two qubits is $$\cos\frac{\beta}{2}|0\rangle|\psi\rangle + \sin\frac{\beta}{2}|1\rangle|\psi^\perp\rangle$$. Finally, we discard the auxiliary qubit leaving the data qubit in the state

$$\mathrm{tr}_1\left[\left(\cos\frac{\beta}{2}|0\rangle|\psi\rangle + \sin\frac{\beta}{2}|1\rangle|\psi^\perp\rangle\right)\left(\cos\frac{\beta}{2}\langle 0|\langle\psi| + \sin\frac{\beta}{2}\langle 1|\langle\psi^\perp|\right)\right] =\\ \cos^2\frac{\beta}{2}|\psi\rangle\langle\psi| + \sin^2\frac{\beta}{2} |\psi^\perp\rangle\langle\psi^\perp| = \rho.$$

In summary, the circuit is:

1. Prepare a data and auxiliary qubits in $$|00\rangle$$ state.
2. Apply $$R_Y(\beta)$$ to the auxiliary qubit.
3. Apply CNOT with the auxiliary qubit as control and data qubit as target.
4. Apply $$R_Y(\theta)$$ to the data qubit.
5. Apply $$R_Z(\phi)$$ to the data qubit.
Alternatively, we can measure the auxiliary qubit after $$R_Y(\beta)$$ and replace CNOT with a classically controlled $$X$$ gate. We discard measurement result after using it to control the $$X$$ gate.