How to represent controlled quantum circuits as matrices?

690 Views Asked by At

I'm trying to implement (actually, simulate) the quantum algorithm by Harrow, Hassidim and Lloyd - http://arxiv.org/abs/0811.3171 - to solve linear systems of equations using a simple $2\times2$ case in Scilab. By entering the matrix $A$ and a vector $\vec{b}$, the algorithm should output the vector $\vec{x}$.

The simplified circuit for this case is described by Cao et all. - http://arxiv.org/abs/1110.2232 - (sorry, I have no permission to post more links), and uses controlled gates for Hamiltonian Simulation and rotation over the eigenvalues of $A$.

I was able to implement the controlled HAM-SIM gates, represented by

$\hskip2in$Hamiltonian Simulation gates

using matrices like $\begin{bmatrix}\mathbb{I}&\cdots&0\\\vdots&\ddots&\vdots\\0&\cdots&U\end{bmatrix}$ where $U = e^{iA\frac{t_0}{denom}}$, but I'm having trouble representing the rotation matrices:

$\hskip2in$Rotation gates

Since they will be applied at the first qubit and controlled by other qubits, I could not figure out the structure of the matrix required to apply the expected transformation.

For example, the second controlled-rotation matrix would apply the transformation $\left|000\right\rangle \rightarrow \left|000\right\rangle$; $\left|001\right\rangle \rightarrow R_y(\frac{2\pi}{2^{m-1}})\left|0\right\rangle \otimes \left|01\right\rangle$; and so on.

1

There are 1 best solutions below

0
On BEST ANSWER

I would approach this by brute force. Look at how this transformation would act on the basis and construct the matrix from there. Since you know that ∣000⟩→∣000⟩ you know that the first column of your matrix will be [1, 0, 0, 0, 0, 0, 0, 0, 0], and since ∣001⟩ is the second basis vector you're able to fill in the second column of the transformation matrix.