HZH = X and Friends
The Hadamard gate exchanges the computational () basis and the basis. A useful consequence is that conjugating by turns it into :
You can check it by multiplying the matrices, but the idea is cleaner: flips the sign of (a reflection about the -axis), while swaps the - and -axes. Doing "swap axes → reflect about → swap back" is the same as reflecting about , which is exactly what does.
This is your first taste of building one operation out of others — the heart of compiling quantum programs onto a fixed gate set.
Try it
Implement using only and . This exercise grades the whole operation (its unitary matrix), so doing nothing won't pass — you must actually realize .
Run your code to see the quantum state.
Sign in on the full site to ask questions and join the discussion.