# How to avoid error when applying certain combinations of degree of freedom rotations using a quantum circuit?

When applying each of the six degree of freedom rotations (or certain combinations of them) in an SO(4) using quantum gates, the results I expected are produced. For example, the following circuit in Craig Gidney's Quirk tool demonstrates rotations in three degrees of freedom, along with some displays of the resulting matrices expressed as percentages:

However, when applying some combinations of rotations, such as the following, results I didn't expect are produced in the final matrix:

In contrast, the results I am expecting are the following: $$\begin{bmatrix} .73 & .07 & .13 & .07 \\ .00 & .73 & .15 & .13 \\ .13 & .07 & .73 & .07 \\ .15 & .13 & .00 & .73 \end{bmatrix}$$

For convenience, here is a link to the Quirk circuit with all six degree of freedom rotations, albeit with an unexpected final result. The results I expect are the following:

$$\begin{bmatrix} .62 & .01 & .08 & .29 \\ .11 & .80 & .01 & .08 \\ .13 & .07 & .80 & .01 \\ .15 & .13 & .11 & .62 \end{bmatrix}$$

I don't know enough about using ancilla bits and uncomputation techniques to apply them to this, but I suspect that it might explain part of the unexpected results. Any advice would be greatly appreciated.

## 1 Answer

Since you haven't told us how you've tried to do the calculation, I don't know where you're making the mistake. (I'm also unfamiliar with Quirk, which seems to be using an unusual ordering of basis elements in the output matrix. If anything looks inconsistent in the following answer, try swapping the middle two rows/columns, and adding a transpose!)

The first important thing is to not use the percentage values in the transition matrices. These correspond to probabilities, but to do any further work, we need to know about probability amplitudes. So, the unitary output of your first sequence of gates is $$\left( \begin{array}{cccc} \frac{\sqrt{2+\sqrt{2}}}{2} & \frac{1}{4} \left(-2+\sqrt{2}\right) & 0 & -\frac{i}{2 \sqrt{2}} \\ 0 & \frac{1}{4} \left(2+\sqrt{2}\right) & -\frac{1}{2} i \sqrt{2-\sqrt{2}} & -\frac{i}{2 \sqrt{2}} \\ 0 & -\frac{i}{2 \sqrt{2}} & \frac{\sqrt{2+\sqrt{2}}}{2} & \frac{1}{4} \left(-2+\sqrt{2}\right) \\ -\frac{1}{2} i \sqrt{2-\sqrt{2}} & -\frac{i}{2 \sqrt{2}} & 0 & \frac{1}{4} \left(2+\sqrt{2}\right) \\ \end{array} \right)$$ Now we can apply the final sequence of gates; an $X$ on qubit 1, a controlled-$Y^{1/4}$ and another $X$ on qubit 1. You get the output unitary $$\left( \begin{array}{cccc} \frac{1}{4} \left(2+\sqrt{2}\right) & -\frac{1}{2} \sqrt{1-\frac{1}{\sqrt{2}}} & -\frac{i}{2 \sqrt{2}} & -\frac{1}{2} i \sqrt{\frac{1}{2} \left(2-\sqrt{2}\right)} \\ 0 & \frac{1}{4} \left(2+\sqrt{2}\right) & -\frac{1}{2} i \sqrt{2-\sqrt{2}} & -\frac{i}{2 \sqrt{2}} \\ -\frac{i}{2 \sqrt{2}} & -\frac{1}{2} i \sqrt{\frac{1}{2} \left(2-\sqrt{2}\right)} & \frac{1}{4} \left(2+\sqrt{2}\right) & -\frac{1}{2} \sqrt{1-\frac{1}{\sqrt{2}}} \\ -\frac{1}{2} i \sqrt{2-\sqrt{2}} & -\frac{i}{2 \sqrt{2}} & 0 & \frac{1}{4} \left(2+\sqrt{2}\right) \\ \end{array} \right)$$ The mod-square of each element is then $$\left( \begin{array}{cccc} \frac{1}{16} \left(2+\sqrt{2}\right)^2 & \frac{1}{8} \left(2-\sqrt{2}\right) & \frac{1}{8} & \frac{1}{8} \left(2-\sqrt{2}\right) \\ 0 & \frac{1}{16} \left(2+\sqrt{2}\right)^2 & \frac{1}{4} \left(2-\sqrt{2}\right) & \frac{1}{8} \\ \frac{1}{8} & \frac{1}{8} \left(2-\sqrt{2}\right) & \frac{1}{16} \left(2+\sqrt{2}\right)^2 & \frac{1}{8} \left(2-\sqrt{2}\right) \\ \frac{1}{4} \left(2-\sqrt{2}\right) & \frac{1}{8} & 0 & \frac{1}{16} \left(2+\sqrt{2}\right)^2 \\ \end{array} \right).$$ Numerically, these are the same as given in the question: $$\left( \begin{array}{cccc} 0.729 & 0.0732 & 0.125 & 0.0732 \\ 0 & 0.729 & 0.146 & 0.125 \\ 0.125 & 0.0732 & 0.729 & 0.0732 \\ 0.146 & 0.125 & 0 & 0.729 \\ \end{array} \right)$$