# What are some examples of measuring qubits in different basis states?

What are some examples of measuring qubits in different basis states (it's known that preferable choices are the computation basis states $$|0\rangle$$, $$|1\rangle$$ and the Bell basis states $$|+\rangle$$, $$|-\rangle$$ on a two-qubit system)?

Context: I am an undergraduate sophomore working on quantum information with a professor so this isn't for a class. Over break, I was given the task of writing a Mathematica function that provides a numerical modeling procedure for measuring a qubit. The function's inputs are the quantum state, measurement basis, and which qubit to measure. The outputs of the function are the post-measurement state of the qubit, and what the outcome of the measurement is (being $$|0\rangle$$ or $$|1\rangle$$) by running a similar function to a density probability. That being said, I am still in the process of learning this material. Thank you.

• Hi, Frank. Welcome to Quantum Computing SE! Please review How to write a good question? I've edited your question this time, but it would be quite annoying for us to do it on your behalf every time. – Sanchayan Dutta Jan 2 '19 at 9:16
• are you asking about measuring a single qubit in different bases, or about measuring systems composed of several qubits? – glS Jan 2 '19 at 16:39

The way that you phrase the question makes it sound like you're given a pure state, $$|\psi\rangle$$ of $$n$$ qubits, and you are tasked with performing a single qubit projective measurement on a given qubit, $$k$$. That's adding in a little precision to your statement which may not be accurate, so please clarify if it's not (because you also mention a Bell basis measurement).
Probably the easiest way to specify a one-qubit measurement is to accept 3-component real vector $$\underline{n}=(n_x,n_y,n_z)$$ which satisfies $$\underline{n}\cdot\underline{n}=1$$. This corresponds to a measurement observable $$M=n_xX+n_yY+n_zZ$$, where $$X,Y,Z$$ are the standard Pauli matrices.
To calculate the probability of getting the $$\pm1$$ measurement outcomes on qubit $$k$$, you calculate $$p_{\pm}=\frac12\pm\langle\psi|\mathbb{I}^{\otimes(k-1)}\otimes M\otimes\mathbb{I}^{\otimes(n-k)}|\psi\rangle,$$ and the post-measurement state is $$\left(|\psi\rangle\pm\mathbb{I}^{\otimes(k-1)}\otimes M\otimes\mathbb{I}^{\otimes(n-k)}|\psi\rangle\right)/\sqrt{p_{\pm}},$$ depending on which of the two outcomes was obtained.