I want to build/prepare a qubit transforming from $\vert 0 \rangle$ into a magic state. How do I do that? the particular magic state I have in mind is the following,
$$ |\varphi\rangle = \frac{1}{\sqrt{2}}(|0\rangle+e^{\frac{i\pi}{4}}|1\rangle)$$
Quantum Computing Stack Exchange is a question and answer site for engineers, scientists, programmers, and computing professionals interested in quantum computing. It only takes a minute to sign up.
Sign up to join this communityFirst, use a Hadamard gate to create the superposition $$\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$ If you write down what you want next, you will find that you need to act with the unitary gate with matrix $$\begin{pmatrix}1&0\\0&e^{i\pi/4}\end{pmatrix}$$ which is exactly the $P$ gate with argument $\frac{\pi}{4}$. So your circuit will look something like this:
Alternatively, you could use Qiskit with initialize
function and then decompose the resulting circuit until you get something that can be implemented with gates in the composer. The $P$ gate is also equivalent (up to a global phase) to the $R_z$ gate so you could also use that one.