How to measure in any basis
Let’s try this for ourselves. Which operator U do we need to apply to a qubit to measure it in the X basis? What about the Y basis?
So we try to find an operator U such that U† ZU equals X. It turns out that if we take U=H (the Hadamard gate), we obtain:
One way to get to this answer is to solve the following linear algebra problem:
Then solving for a, b, c and d will lead you to the Hadamard gate.
If we want to measure in the Y basis, we can solve a similar equation and end up with the following matrix:
One way to see this is that if we apply this gate to the Z basis states, we end up with the following:
The resulting states we can recognize as the eigenstates of the Y basis.
Second part of the question: What does the 0 state collapse to if we measure it in the X basis using our protocol?
If we measure the 0 state in the X basis it will collapse to one of the eigenstates of the X basis. So it will either collapse in the plus or minus state.