Suppose that we have one-qubit unitary $U$ that maps $$ \left| 0 \right> \longmapsto \frac{1}{\sqrt{2}} \left| 0 \right> + {\frac{1+i}{2}} \left| 1\right> $$ and $$ \left| 1 \right> \longmapsto {\frac{1-i}{2}} \left| 0 \right> - \frac{1}{\sqrt{2}} \left| 1\right> $$ What is $U$?
2 Answers
Firstly simply rewrite probability amplitudes of returned states as columns of a matrix: $$ U = \begin{pmatrix} \frac{1}{\sqrt{2}} & \frac{1-i}{2} \\ \frac{1+i}{2} & -\frac{1}{\sqrt{2}} \end{pmatrix} $$ Now do some algebra $$ U = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & \frac{1-i}{\sqrt{2}} \\ \frac{1+i}{\sqrt{2}} & -1 \end{pmatrix} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & \mathrm{e}^{-i\frac{\pi}{4}} \\ \mathrm{e}^{i\frac{\pi}{4}} & -1 \end{pmatrix} $$
There is a quantum gate called $\mathrm{U2}$: $$ \mathrm{U2}(\phi,\lambda)= \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & -\mathrm{e}^{i\lambda} \\ \mathrm{e}^{i\phi} & \mathrm{e}^{i(\phi+\lambda)} \end{pmatrix} $$
Setting $\phi=\frac{\pi}{4}$ and $\lambda = \frac{3}{4}\pi$ you have a resut since $\phi+\lambda =\pi$, so $\mathrm{e}^{i(\phi+\lambda)} = \mathrm{e}^{i\pi} = -1$ and $-\mathrm{e}^{i\lambda}=-\mathrm{e}^{i\frac{3}{4}\pi} = -\frac{-1+i}{\sqrt{2}}$.
Conclusion: $U=\mathrm{U2}\big(\frac{\pi}{4},\frac{3}{4}\pi\big)$
-
$\begingroup$ I like how you started from the beginning and never skipped a step, well done! $\endgroup$ Jan 8, 2020 at 21:05
Just to expand on the detail of why writing out the columns works:
Start by writing the action of the unitary: \begin{align*} U|0\rangle=\frac{1}{\sqrt{2}}|0\rangle+\frac{1+i}{2}|1\rangle \\ U|1\rangle=\frac{1-i}{2}|0\rangle-\frac{1}{\sqrt{2}}|1\rangle \end{align*} Before proceeding, it's always worth checking that both sides are correctly normalised. In this case, they are.
Now take the inner product of each equation with $\langle 0|$: $$ \langle 0|U|0\rangle=\frac{1}{\sqrt{2}}\qquad\langle 0|U|1\rangle=\frac{1-i}{2} $$ Similarly, using $\langle 1|$, you get $$ \langle 1|U|0\rangle=\frac{1+i}{2}\qquad\langle 1|U|1\rangle=-\frac{1}{\sqrt{2}}. $$ So, these identify all four matrix elements, which you can just insert: $$ U=\left(\begin{array}{cc} \frac{1}{\sqrt{2}} & \frac{1-i}{2} \\ \frac{1+i}{2} & -\frac{1}{\sqrt{2}} \end{array}\right). $$ (I should say that I always get muddled between the two off-diagonal elements. So I have to stop and think about, for example, $\langle 0|U|1\rangle$, and which element is selected by doing the inner product $\left(\begin{array}{cc}1 & 0\end{array}\right)U\left(\begin{array}{c} 0 \\ 1 \end{array}\right)$: top row, right-hand column.)
Don't forget to check that your answer is reasonable by verifying $UU^\dagger=I$.