# Quantum gate: Phase shift

I dont undestand how to apply a phase shift gate to a qubit. By example how to map $|\psi_0\rangle = \cos (30^\circ) |0\rangle + \sin (30^\circ) |1\rangle$ to $|\psi_1\rangle = \cos(-15^\circ) |0\rangle + \sin(-15^\circ) |1\rangle$

-

A phase gate will not map between the two vectors you give. A phase gate changes the phase of the $\left|1\right>$ component, which is not what you want since for your example all components are real.

Your two vectors lie in the X-Z plane of the Bloch sphere. To map from your first vector to your second vector, you need to rotate about the Y axis. The following unitary does the job, with $\theta=(-15)-30=-45$. $$\left[ \begin{array}[rr] \textrm{cos}(\theta) & -\textrm{sin}(\theta) \\ \textrm{sin}(\theta) & \textrm{cos}(\theta) \end{array} \right]$$

-

So, you have two vectors. Let $|0\rangle = \begin{pmatrix} 1 \\ 0 \\ \end{pmatrix}$ and $|1\rangle = \begin{pmatrix} 0 \\ 1 \\ \end{pmatrix}$. So, your initial vector is $\begin{pmatrix} cos \frac{\pi}{6} \\ sin \frac{\pi}{6} \\ \end{pmatrix}$ and final vector is $\begin{pmatrix} cos \frac{-\pi}{12} \\ sin \frac{-\pi}{12} \\ \end{pmatrix}$. The phase difference between these two vectors, $\theta$ is $cos^{-1} \left[ \frac{\begin{pmatrix} cos \frac{\pi}{6} \\ sin \frac{\pi}{6} \\ \end{pmatrix} . \begin{pmatrix} cos \frac{-\pi}{12} \\ sin \frac{-\pi}{12} \\ \end{pmatrix}}{|\begin{pmatrix} cos \frac{\pi}{6} \\ sin \frac{\pi}{6} \\ \end{pmatrix}| | \begin{pmatrix} cos \frac{-\pi}{12} \\ sin \frac{-\pi}{12} \\ \end{pmatrix}|} \right]$. Evaluate $\theta$ and plug in the value in \begin{pmatrix} 1 & 0 \\ 0 & e^{i\theta} \\ \end{pmatrix}. The resulting matrix will be your gate.

-
That unitary does not map the first vector into the second one. In fact, no phase gate will do it. – Dan Stahlke Mar 15 '13 at 12:58
@DanStahlke, if I can determine the phase different of the two vectors, why can't I plug it into the formula of the phase gate? – Omar Shehab Mar 15 '13 at 17:00
The two vectors don't differ by a phase, at least not by the type of phase relevant to the phase gate. The phase gate rotates the Bloch sphere about the Z axis, but the two vectors differ by a rotation about the Y axis. – Dan Stahlke Mar 15 '13 at 20:50
@DanStahlke, if the convert the given vectors into polar coordinates and normalize will the phase different work then? – Omar Shehab Mar 17 '13 at 20:44
Omar: if you note that the magnitudes of $\cos(30^\circ)$ and $\cos(-15^\circ)$ are different from one another, you can see that the only diagonal matrices which could yield the required transformation are ones where the entries have modulus different from $1$. Such matrices aren't unitary, and so in particular they are not valid phase gates. Because the magnitude of the components differ, a more general rotation matrix is required. – Niel de Beaudrap Mar 20 '13 at 14:02