The Quantum Engineer
The Quantum Engineer›Quantum Mechanics Without Drowning in Physics

measure qubit 0, outcome |1>: amplitudes where bit0 == 1 survive

Everything a quantum engineer needs of quantum mechanics, expressed as postulates, a qubit, gates, and measurement — with numpy instead of derivations.

for name, M in [("XY", X @ Y), ("YZ", Y @ Z), ("ZX", Z @ X)]: print(name, "->", np.round(M, 2).tolist()) # each equals i times the third Pauli

H = np.array([[1, 1], [1, -1]], dtype=complex)/np.sqrt(2) print(np.allclose(H @ X @ H, Z)) # H X H = Z -> True


mask = np.array([0, 1, 0, 1], dtype=bool)         # order: |00>,|01>,|10>,|11>
psi_post = np.where(mask, psi, 0)
psi_post /= np.linalg.norm(psi_post)
print(np.round(psi_post, 3))                      # [0, 0.707, 0, 0.707] -> qubit1 still |+>

Contents