<s>[INST] 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$
 [/INST] 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.
</s>