Two equivalent ways to compute the probability of a measurement outcome in a different basis. The math says the same thing; the framing differs.
We have a quantum state $\ket{\psi}$ and want to find the probability of a specific measurement outcome, say $\ket{+}$.
The core formula is:
$$P(\text{outcome } \ket{x}) = |\braket{x}{\psi}|^2$$This is the inner product (bracket) between the target outcome and the state, squared. Simple in principle — let's make sure it's simple in practice too.
Three bases, two states each. These are the building blocks:
For each example, the left card uses the inner product (pen-and-paper approach) and the right card shows the gate-then-measure circuit equivalent. Both always produce the same answer.
Compute $\braket{+}{0}$:
Apply $H$ to $\ket{0}$, then read off $P(\ket{0})$:
Compute $\braket{+}{+}$:
Apply $H$ to $\ket{+} = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\end{pmatrix}$:
Compute $\braket{+}{-}$:
Apply $H$ to $\ket{-} = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\-1\end{pmatrix}$:
Compute $\braket{+}{\psi}$:
Now take the modulus squared. For a complex number $a + bi$: $|a+bi|^2 = a^2 + b^2$.
Apply $H$ to $\ket{\psi} = \begin{pmatrix}1/2\\i\sqrt{3}/2\end{pmatrix}$:
The amplitude for $\ket{0}$ is $\alpha = \frac{1+i\sqrt{3}}{2\sqrt{2}}$.
The Hadamard gate maps the X-basis to the Z-basis:
$$H\ket{+} = \ket{0}, \qquad H\ket{-} = \ket{1}$$So the probability of measuring $\ket{+}$ (an X-basis outcome) is the same as applying $H$ first and then measuring $\ket{0}$ (a Z-basis outcome). In general, for any basis change $U$ that maps $\ket{x} \to \ket{0}$:
$$P(\text{outcome } \ket{x}) = |\braket{x}{\psi}|^2 = |\bra{0}U\ket{\psi}|^2 = P(\text{outcome } \ket{0} \text{ after } U)$$The gate-then-measure pattern is just a change of basis implemented physically on the qubit, so that a standard Z-measurement gives you the answer you wanted in the other basis.
Both give identical probabilities, always. Exercises use inner products; circuits use gates. Same math, different packaging.