← All modules 02 Gates and interference

SESAME · Day 1 · Module 02

Gates and
interference

Quantum gate

A reversible operation on one or more qubits that transforms their state.

Quantum circuit

Specifies the operations, the qubits they act on and their order. Usually drawn as a diagram.

We use sequences of gates to carry out a quantum computation.

Opening / From a state difference to a recorded result

Can the same gate make these inputs distinguishable?

Plus

\[|+\rangle=\frac{|0\rangle+|1\rangle}{\sqrt2}\]

Minus

\[|-\rangle=\frac{|0\rangle-|1\rangle}{\sqrt2}\]

Direct computational-basis readout: \(P(0)=P(1)=1/2\) for both inputs.

Yes. After the same gate, plus can give 0 with certainty and minus can give 1 with certainty.

Gates / Circuits / Interference

A circuit’s measurement probabilities depend on how its gates change and combine amplitudes.

01 Ideal gates transform a qubit’s amplitudes reversibly.

02 A circuit fixes which operations act on each qubit and in what order.

03 Interference turns relative phase into different measurement probabilities.

01 / Gates · 1.1

A gate applies a linear transformation to the qubit’s state.

\[U(\alpha|0\rangle+\beta|1\rangle)=\alpha U|0\rangle+\beta U|1\rangle\]

For example: X

\[X=\begin{pmatrix}0&1\\1&0\end{pmatrix}\]

\(X|0\rangle=|1\rangle\), \(X|1\rangle=|0\rangle\)

Swap the amplitudes

\[X\begin{pmatrix}\alpha\\\beta\end{pmatrix}=\begin{pmatrix}\beta\\\alpha\end{pmatrix}\]

The same rule applies to every input.

The gate acts without reading \(\alpha\) and \(\beta\) from the qubit.

01 / Gates · 1.2

Unitary gates preserve normalization and have inverses.

\[U^\dagger U=I\]

\(U^\dagger\): transpose and complex conjugate.

Apply \(U\), then \(U^\dagger\): recover the input.

For example: Z

\[Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}\]

Change the second amplitude’s sign.

Change the sign twice

\[|+\rangle\xrightarrow{Z}|-\rangle\xrightarrow{Z}|+\rangle\]

\(Z^2=I\)

The total probability stays 1. Individual probabilities can change.

01 / Gates · 1.2 / Geometric connection

Ideal single-qubit gates rotate the state point.

Two examples

\[X|0\rangle=|1\rangle\]
\[Z|+\rangle=|-\rangle\]

Gates can also have adjustable rotation angles.

An inverse gate reverses the ideal transformation.

|0⟩|1⟩|−⟩|+⟩

01 / Gates · 1.3

The Hadamard gate combines the two input amplitudes.

Starting from 0, H gives us a way to prepare a superposition.

\[H=\frac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}\]
\[H|0\rangle=\frac{|0\rangle+|1\rangle}{\sqrt2}=|+\rangle\]
\[H|1\rangle=\frac{|0\rangle-|1\rangle}{\sqrt2}=|-\rangle\]

First row: add. Second row: subtract. Scale both by \(1/\sqrt2\).

From zero, H prepares the plus state on every run.

02 / Circuits · 2.1

Each quantum wire follows one qubit through a sequence of operations.

q₀|0⟩ H Z |0⟩ |+⟩ |−⟩

Wire: the same qubit.

Box: an operation.

Time: left to right →

The output of one gate is the input to the next.

The intermediate states are written for our calculation. There is no measurement between these gates.

02 / Circuits · 2.2

The input and measurement specify the calculation we need.

q₀|0⟩ c0 0 or 1 H
\[|0\rangle\xrightarrow{H}|+\rangle,\qquad P(1)=\frac12\]

q₀: the qubit remains available.

c0: the classical record, 0 or 1.

The state afterwards matches the record: \(|0\rangle\) or \(|1\rangle\).

Our examples start in zero and request a final computational-basis readout.

02 / Circuits · 2.3

Changing gate order can change the state we obtain.

A / H, then Z

q₀|0⟩ H Z
\[|0\rangle\xrightarrow{H}|+\rangle\xrightarrow{Z}|-\rangle\]
\[ZH|0\rangle=Z(H|0\rangle)\]

B / Z, then H

q₀|0⟩ Z H
\[|0\rangle\xrightarrow{Z}|0\rangle\xrightarrow{H}|+\rangle\]
\[HZ|0\rangle=H(Z|0\rangle)\]

Different states. The same direct readout probabilities: \(P(0)=P(1)=1/2\).

Keep the relative sign. A later operation can use it.

02 / Circuits · 2.3 / Prediction

Which gate acts first?

\[ZH|0\rangle\]

H acts first. It is next to the input vector.

\[Z\bigl(H|0\rangle\bigr)\]

Z acts on the state H produces.

Next: make the phase difference affect the result we read.

03 / Interference · 3.1

Contributions to the same outcome can reinforce or cancel.

\[H\begin{pmatrix}\alpha\\\beta\end{pmatrix}=\frac1{\sqrt2}\begin{pmatrix}\alpha+\beta\\\alpha-\beta\end{pmatrix}\]

Each output amplitude receives contributions from both input amplitudes.

q₀|0⟩ H H |0⟩ |+⟩ |?⟩

Apply the second H to both terms of plus.

03 / Interference · 3.1 / H, then H

Add the contributions before calculating probabilities.

\[H|+\rangle=\frac{H|0\rangle+H|1\rangle}{\sqrt2}\]

From the first input term

\[\frac{H|0\rangle}{\sqrt2}=\frac{|0\rangle+|1\rangle}{2}\]

From the second input term

\[\frac{H|1\rangle}{\sqrt2}=\frac{|0\rangle-|1\rangle}{2}\]
OutcomeAdd contributions to its amplitudeThen take the squared magnitude
\(0\)\(\frac12+\frac12=1\)\(P(0)=|1|^2=1\)
\(1\)\(\frac12-\frac12=0\)\(P(1)=|0|^2=0\)

Final state: \(|0\rangle\). The measurement records 0 with certainty.

03 / Interference · 3.2 / H, Z, H

Z changes the relative sign before the last H.

q₀|0⟩ H Z H |0⟩ |+⟩ |−⟩ |?⟩

Before Z

\[|+\rangle=\frac{|0\rangle+|1\rangle}{\sqrt2}\]

\(P(0)=P(1)=1/2\)

After Z

\[|-\rangle=\frac{|0\rangle-|1\rangle}{\sqrt2}\]

\(P(0)=P(1)=1/2\)

These are predicted readout probabilities. No measurement is inserted here.

03 / Interference · 3.2 / The last H

A relative sign changes which contributions cancel.

\[H|-\rangle=\frac{H|0\rangle-H|1\rangle}{\sqrt2}\]

From the first input term

\[\frac{H|0\rangle}{\sqrt2}=\frac{|0\rangle+|1\rangle}{2}\]

From the second input term

\[-\frac{H|1\rangle}{\sqrt2}=\frac{-|0\rangle+|1\rangle}{2}\]
OutcomeAdd contributions to its amplitudeThen take the squared magnitude
\(0\)\(\frac12-\frac12=0\)\(P(0)=|0|^2=0\)
\(1\)\(\frac12+\frac12=1\)\(P(1)=|1|^2=1\)

Final state: \(|1\rangle\). The measurement records 1 with certainty.

03 / Interference · 3.2 / The opening question

The same H gate makes plus and minus distinguishable.

Plus input

q₀|+⟩ c0 0 H
\[H|+\rangle=|0\rangle\]

Record 0 with certainty.

Minus input

q₀|−⟩ c0 1 H
\[H|-\rangle=|1\rangle\]

Record 1 with certainty.

Relative phase can change the result we read.

H followed by this readout gives the plus/minus measurement probabilities.
In an algorithm, we arrange gates so that useful results become likely.

03 / Interference · 3.3 / Checking a circuit

What happens if we measure between the two H gates?

Without the middle measurement

q₀|0⟩ c0 0 H H

Final result: 0 with certainty.

With the middle measurement

q₀|0⟩ c0 0 or 1 c1 0 or 1 H H

What state enters the last H?

The middle measurement leaves \(|0\rangle\) or \(|1\rangle\), each with probability \(1/2\).

03 / Interference · 3.3 / After the middle measurement

The last H now receives one reference state or the other.

Middle record 0 / Probability ½

\[|0\rangle\xrightarrow{H}|+\rangle\]
\[P(\text{final }1\mid\text{middle }0)=\frac12\]

Middle record 1 / Probability ½

\[|1\rangle\xrightarrow{H}|-\rangle\]
\[P(\text{final }1\mid\text{middle }1)=\frac12\]
\[P(\text{final }1)=\frac12\cdot\frac12+\frac12\cdot\frac12=\frac12\]

Ignoring the middle record does not undo the state change.

No later gate depends on the middle record.

03 / Interference · 3.3 / Superposition and random preparation

Equal direct readout probabilities can hide different preparations.

Prepare a fresh input for each run.

PreparationDirect readout: \(P(1)\)H, then readout: \(P(1)\)
Prepare \(|+\rangle\)\(1/2\)\(0\)
Prepare \(|-\rangle\)\(1/2\)\(1\)
Randomly prepare \(|0\rangle\) or \(|1\rangle\), equally often\(1/2\)\(1/2\)

Amplitudes combine within a superposition.
Probabilities combine across randomly selected preparations.

Gates / Circuits / Interference

A circuit’s measurement probabilities depend on how its gates change and combine amplitudes.

01 Ideal gates transform a qubit’s amplitudes reversibly.

02 A circuit fixes which operations act on each qubit and in what order.

03 Interference turns relative phase into different measurement probabilities.

Exercise / Worked circuit

What is the probability of measuring 1?

Start in \(|0\rangle\). Use a final computational-basis measurement.

q₀|0⟩ c0 0 or 1 H
\[H|0\rangle=|+\rangle=\frac{|0\rangle+|1\rangle}{\sqrt2}\]
\[P(1)=\left|\frac1{\sqrt2}\right|^2=\frac12=\boxed{0.50}\]

Exercise / Your turn

Find the final probability of measuring 1 in each circuit.

Start in \(|0\rangle\). Follow the state after each gate. Submit a decimal.

01 q₀|0⟩ c0 0 or 1 X
02 q₀|0⟩ c0 0 or 1 H H
03 q₀|0⟩ c0 0 or 1 H Z H

Next: Joint states and entanglement →