In Quantum Algorithm Implementations for Beginners is an example of the Quantum PCA with an given 2 x 2 covariance matrix $\sum$.
The steps for state preparation are given in the paper. The steps are:

  • calculate covariance matrix $\sum$ from the data

  • compute density matrix $\rho = \frac{1}{Tr(\sum)}*\sum$

  • calculate two-qubit pure quantum state $| \psi \rangle$
  • calculate the unitary operator $U_{prep}$

I wanna comprehend the example from the paper. So far I got the density matrix $\rho$. I would be glad if someone could explain me how to calculate the quantum state $| \psi \rangle$ and futhermore $U_{prep}$.

  • $\begingroup$ if you are referring to the description given in pag.46, it says "In the first step, one’s classical computer converts the raw data vectors into a covariance matrix Σ, then normalizes this matrix to form ρ = Σ/Tr(Σ), then purifies it to make a pure state |ψi$\rangle$, and finally computes the unitary Uprep needed to prepare |ψi from a pair of qubits each initially in the |0i state.". So are you asking what does it mean to purity a state? $\endgroup$ – glS Jan 31 '20 at 10:00
  • $\begingroup$ yeah exactly, I thought it would be something like amplitude-encoding so that $\rho_{11} = \alpha_{11}$ for Quantum state $| 00 \rangle$ and so on. But I think this is wrong. So I need a bit help here. $\endgroup$ – rexrayne Jan 31 '20 at 15:46
  • $\begingroup$ you can try to have a look at the Wikipedia page to know what purification means. In a few words, it means to find a pure state whose reduced density matrix equals your $\rho$. $\endgroup$ – glS Jan 31 '20 at 16:35

In an article Towards Pricing Financial Derivatives with an IBM Quantum Computer PCA is implemented in a practical way with an example.

Operator $U_{prep}$ is realized with $\mathrm{U3}$ gates but parameters for some gates presented in the article seems wrong (maybe typo). See this thread for more information, correct $\mathrm{U3}$ parameters values and a way how to implement PCA on IBM Q.

EDIT: How to find parameters $\theta$, $\phi$ and $\lambda$ for implementation of $U_{prep}$ with $\mathrm{U3}$ gate.

$\mathrm{U3}$ gate has this form:

$$ \mathrm{U3}= \begin{pmatrix} \cos(\theta/2) & -\mathrm{e}^{i\lambda}\sin(\theta/2) \\ \mathrm{e}^{i\phi}\sin(\theta/2) & \mathrm{e}^{i(\phi+\lambda)}\cos(\theta/2) \end{pmatrix}. $$

Firstly, you have to factor out some complex number (denote $c$) from $U_{prep}$ in order to have a real number on position $u_{11}$. After that you can easily calculate $\theta$ from $\cos(\theta/2)$. Then, it is not problem to find $\phi$ from $\mathrm{e}^{i\phi}\sin(\theta/2)$ and finnaly $\lambda$ from $\mathrm{e}^{i(\phi+\lambda)}\cos(\theta/2)$.

The number $c$ factored out in the first step is a global phase. It is not important in case $\mathrm{U3}$ is used in its single qubit form. But if the gate is used as controlled one, the global phase cannot be neglected. So, you will have controlled $\mathrm{U3}$ and controlled global phase gate.

  • $\begingroup$ Thank you for this paper. I tried to comprehend this as well, but I have a problem with equation 16. I used the formula: $\mathrm{e}^{2\pi i \rho}$ but I calculated the values: $[-0.6340 - 0.7733i -0.4751 + 0.8799i; -0.4751 + 0.8799i -0.6340 + 0.7733i]$ with matlab. Did I miss something? I didn´t found something about this in the thread you linked. $\endgroup$ – rexrayne Jan 31 '20 at 18:08
  • $\begingroup$ First of all, did you use function exp or expm? Because expm returns matrix exponential. Exp is standard exponential function applied on each elements separately. Moreover, I also calculated matrix exponential in MatLab and it differed from the one in paper by global phase (i.e. all matrix elements were multiplied by same number) which can be ignored. $\endgroup$ – Martin Vesely Jan 31 '20 at 19:34
  • $\begingroup$ Thank you, you are right, I didn´t use expm, then the values are correct. Just one last question how do I calculate from the $U_{prep}$ the parameters $\lambda, \phi , \theta $? $\endgroup$ – rexrayne Feb 1 '20 at 20:10
  • $\begingroup$ @rexrayne: Please see edited answer above. $\endgroup$ – Martin Vesely Feb 3 '20 at 10:37

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.