Figure 1: Representing the numbers 12 and 345 as frequency spectra, transforming them to time signals and multiplying. |
Thoughts
on the practical and philosophical ideas that shape our world.
Sunday, 21 April 2024
Fast (Fourier) multiplication
Tuesday, 12 March 2024
Visualizing the discrete Fourier transform
Figure 1: Yearly lunar satellite path (green) |
Synthesis (the inverse discrete Fourier transform)
- The Sun is stationary. The Sun's position in space will be the origin (0,0) for the green dot coordinates.
- The Earth is orbiting the Sun in an anti-clockwise direction at 1 cycle per year and its initial (x,y) coordinates are (20,0) relative to the Sun.
- The Moon is orbiting the Earth in an anti-clockwise direction at 2 cycles per year and its initial coordinates are (12,0) relative to the Earth.
- The satellite is orbiting the Moon in a clockwise direction at 1 cycle per year and its initial coordinates are (9,0) relative to the Moon.
Figure 2: Spring, summer, fall, winter, spring (the satellite time signal is derived from the initial relative body positions) |
Synthesis: To calculate a seasonal satellite position, rotate the bodies up to that season from their initial relative positions and sum their resulting relative positions. More generally, to calculate the signal amplitude at a particular time, rotate the initial frequency amplitudes over that time and sum the resulting amplitudes.
Analysis (the discrete Fourier transform)
Figure 3: Sun, Earth, Moon, satellite (the initial relative body positions are derived from the satellite time signal) |
Analysis: To calculate a body's initial relative position, rotate each seasonal satellite position back by the amount that the body has rotated up to that season and average the resulting satellite positions. More generally, to calculate an initial frequency amplitude, rotate each time signal amplitude back by that frequency over that time period and average the resulting amplitudes.
Summary
"The big insight: our signal is just a bunch of time spikes! If we merge the recipes for each time spike, we should get the recipe for the full signal."
Thanksgiving: The Fourier Transform - Sean Carroll
"Fourier transforms are just a fancy version of changes of coordinates."
Intuitive Guide to Fourier Analysis: ch1, ch2, ch3, ch6 - Langton, Levin
Fourier Analysis - Steve Brunton, YouTube
Signals & Systems 2020 - Andrew Reader, YouTube
Seeing Circles, Sines and Signals - Jack Schaedler
Footnotes
\[T = F B^{-1}\]
\[F = T B\]
For a specific time signal or frequency spectrum component, the formulae are:
\[T_t = \sum_{f=0}^{N-1} F_f \cdot e^{i (2\pi / N) t f}\]
\[F_f = \frac{1}{N} \sum_{t=0}^{N-1} T_t \cdot e^{-i (2\pi / N) f t}\]
[8] The transform can also be extended to two or more dimensions. To compute a 2D DFT for four time points, create a 4x4 matrix for the 2D time signal. Compute the 1D DFT for each row to create an interim matrix \(M_{2D}\). Then compute the 1D DFT for each column in \(M_{2D}\) to create the 2D frequency spectrum. The columns represent the cycles in the first dimension (0, 1, 2 and -1) and the rows represent the cycles in the second dimension (also 0, 1, 2 and -1).
In the example below, the time signal \(T_{2D}\) starts at 1 (the top-left cell) and spins at 1 cycle per unit time in the horizontal direction and 2 cycles per unit time in the vertical direction. After applying the 2D DFT, the frequency spectrum \(F_{2D}\) has a spike in the cell at the second column and the third row, representing 1 cycle in the horizontal dimension and 2 cycles in the vertical dimension, as expected.
\(T_{2D} = \begin{bmatrix}1 & i & -1 & -i\\-1 & -i & 1 & i\\1 & i & -1 & -i\\-1 & -i & 1 & i\end{bmatrix} M_{2D} = \begin{bmatrix}0 & 1 & 0 & 0\\0 & -1 & 0 & 0\\0 & 1 & 0 & 0\\0 & -1 & 0 & 0\end{bmatrix} F_{2D} = \begin{bmatrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 1 & 0 & 0\\0 & 0 & 0 & 0\end{bmatrix} \)
[9] Given the required rotations 1, i, -1 and -i on the complex plane, the following equations calculate the IDFT (frequency spectrum to time samples) and DFT (time samples to frequency spectrum) respectively for the satellite path and cycles.
Figure 4: Synthesis: the solid green time signal is the sum of the component sine waves that represent the motions of the orbiting bodies |
Figure 5: Analysis: the orbit positions in each transformed image cancel out revealing the position of the stationary body |
Thursday, 29 February 2024
Dissecting von Neumann's elephant
Figure 1: Von Neumann's elephant |
"With four parameters I can fit an elephant, and with five I can make him wiggle his trunk."
Figure 2: Epicycles and coordinates |
Figure 3: Signal timeline (side-on) and complex plane (front-on) viewpoints |
"Everything should be made as simple as possible (but not simpler)."
Saturday, 24 February 2024
Visualizing von Neumann's elephant
Figure 1: This is not an elephant |
John von Neumann once remarked to fellow physicist Enrico Fermi: [1]
"With four parameters I can fit an elephant, and with five I can make him wiggle his trunk."
Von Neumann was pointing out the danger of relying on too many input parameters to model a data set - which may then fail to fit additional data or predict future observations.
Figure 2: 128 sample points |
One approach would be to find a number of points on the green line, as per Figure 2, and then join the points with straight lines.
Figure 3: Satellite path in green |
Figure 4: Drawing an elephant from 128 epicycles (zoomed-in detail on right) |
Figure 5: (top row) 50 epicycles, 20 epicycles, (bottom row) 16 epicycles, 8 epicycles |
Monday, 13 March 2023
The CHSH game
Figure 1: Playing the CHSH game |
The game is repeated many times. What classical strategy maximizes their probability for winning and what is that probability? Have a go at answering it, then check below.
Figure 2: Playing the CHSH game (quantum strategy) |
Figure 3: Entangled particle pair |
Now let's try a specific quantum strategy (see Figure 2). For each game, Alice and Bob share a single entangled particle pair (see Figure 3).
Alice and Bob agree beforehand to each measure their particle at an
angle that depends on the coin flips. On heads, Alice's measurement
angle will be 0°, on tails 45°. On heads, Bob's measurement angle will
be 22.5°, on tails -22.5°. They each measure their particle and report
the "+1" or "-1" result.[2]
In three of the cases, at least one of the coins will be heads and the
difference in Alice and Bob's measurement angles is 22.5°. QM
predicts that they will measure the same result cos2(22.5°)
≈ 85% of the time.[3] In the double-tails case, the difference in Alice
and Bob's measurement angles is 67.5°. QM predicts that they will
measure a different result sin2(67.5°) ≈ 85% of the time. Thus Alice and Bob win the game on average 85% of the time.
So the quantum strategy is better than the best possible classical
strategy, violating the Bell inequality. That's Bell's Theorem (one of
many variants). So at least one of the classical assumptions is
incorrect (hidden variables, locality, or statistical independence).
As an alternative presentation of the CHSH inequality, consider the following two-qubit observable composed of the various single-qubit observables that Alice and Bob can measure.
O = AHBH + AHBT + ATBH – ATBT
Each term specifies the product of a particular pair of measurements that Alice and Bob perform. For example, suppose when Alice's coin was heads, she measured -1 (with the 0° angle measurement) and when Bob's coin was tails, he measured +1 (with the -22.5° measurement). Thus the product AHBT would be -1 * + 1 = -1. Since the measured values are always either +1 or -1, a product term must also be either +1 or -1.
Note that it's not possible to make the four measurements jointly because they don't commute. However let's assume that each of the measurement pairs do have definite values even if they are not measured. This assumption is called realism (or hidden variables). Let's further assume that no communication occurs between Alice and Bob's particle. This assumption is called locality.
Now consider that observable O can be factored as:
O = (AH + AT)BH + (AH - AT)BT
Note that one of the parenthesized quantities must be equal to zero. That's because Alice's two possible measurement results (±1) would either add to 0 (if different) or subtract to 0 (if equal). So the maximum possible value for observable O is 2. This equation (and inequality) can be written as:
|E(O)| = |E(AHBH) + E(AHBT) + E(ATBH) – E(ATBT)| ≤ 2
where E specifies the expectation value. The expectation value for observable O can be empirically determined by running the experiment many times (using a new entangled particle pair and coin pair each time) and then summing the expectation values for each term.
The formula for the expectation value is:
E(ab) = (+1)cos2(θ) + (-1)sin2(θ) = cos(2*θ)
where θ is the relative angle between Alice and Bob’s measurements. So:
|E(O)| = |E(22.5°) + E(22.5°) + E(22.5°) – E(67.5°)|
= |1/√2 + 1/√2 + 1/√2 – -1/√2| = 2√2 ≈ 2.828 ≰ 2
thus violating the CHSH inequality.[4]
As noted with the CHSH game, the Bell inequality depends on three assumptions. The first is locality (or no spooky action at a distance), which means that Alice and Bob have no way of communicating and thus potentially influencing the results. The second is hidden variables (or realism or counterfactual definiteness or non-contextuality), which means that there are definite values for the spin angles even if measurements are not performed at those angles. The third is statistical independence (or free-will or no conspiracy), which means that the coin flips are random and independent.
--
References:
Introduction to Quantum Information Science Lecture Notes, Lecture 13: Hidden Variables, Bell’s Inequality, Lecture 14: Nonlocal Games - Scott Aaronson
Quantum Randomness - American Scientist, Scott Aaronson
Bell's Inequality: The weirdest theorem in the world | Nobel Prize 2022 - Qiskit (video)
Bell's Theorem - Brilliant
--
[1] Enumeration of all possible deterministic strategies for the CHSH game:
==================================
| Strategy | Coin| Say | Win | Win |
| | A B | A B | | % |
==================================
| | H H | + + | Yes | |
| Heads:+1 | H T | + + | Yes | 75% |
| Tails:+1 | T H | + + | Yes | |
| | T T | + + | No | |
----------+-----+-----+-----+-----
| | H H | - - | Yes | |
| Heads:-1 | H T | - - | Yes | 75% |
| Tails:-1 | T H | - - | Yes | |
| | T T | - - | No | |
----------+-----+-----+-----+-----
| | H H | + + | Yes | |
| Heads:+1 | H T | + - | No | 25% |
| Tails:-1 | T H | - + | No | |
| | T T | - - | No | |
----------+-----+-----+-----+-----
| | H H | - - | Yes | |
| Heads:-1 | H T | - + | No | 25% |
| Tails:+1 | T H | + - | No | |
| | T T | + + | No | |
==================================
Figure 4: Quantum circuit |
\(\begin{aligned}\hspace{20 mm}|\Psi\rangle = 0.653|00\rangle - 0.271|01\rangle + 0.271|10\rangle + 0.653|11\rangle\end{aligned}\)
The results "+1" and "-1" map to the \(|0\rangle\) and \(|1\rangle\) basis states respectively. The terms that represent Alice and Bob getting the same results are the \(|00\rangle\) and \(|11\rangle\) terms. Squaring the amplitudes for those terms and adding them gives 85% which is the expected win percentage for the AHBH measurement combination.
To view the state vectors for each measurement combination, click on the circuit diagram link in Figure 4 and use the following rotations (which will produce the associated state vector):
AHBH = 0° | 22.5° = RY(0 * pi/8 * 2) | RY( 1 * pi/8 * 2)
\(\begin{aligned}\hspace{10 mm}|\Psi\rangle = 0.653|00\rangle - 0.271|01\rangle + 0.271|10\rangle + 0.653|11\rangle\end{aligned}\)
\(\begin{aligned}\hspace{10 mm}|\Psi\rangle = 0.653|00\rangle + 0.271|01\rangle - 0.271|10\rangle + 0.653|11\rangle\end{aligned}\)
ATBH = 45° | 22.5° = RY(2 * pi/8 * 2) | RY( 1 * pi/8 * 2)
\(\begin{aligned}\hspace{10 mm}|\Psi\rangle = 0.653|00\rangle + 0.271|01\rangle - 0.271|10\rangle + 0.653|11\rangle\end{aligned}\)
ATBT = 45° | -22.5° = RY(2 * pi/8 * 2) | RY(-1 * pi/8 * 2)
\(\begin{aligned}\hspace{10 mm}|\Psi\rangle = 0.271|00\rangle + 0.653|01\rangle - 0.653|10\rangle + 0.271|11\rangle\end{aligned}\)
Note that on the Bloch sphere representation, orthogonal vectors are antiparallel. So the RY multiplier is π/8 * 2 (45°) rather than just π/8 (22.5°) because RY will internally divide the angle by 2.
[3] The measurement bases for each angle are:
0° \(\begin{aligned}\hspace{14 mm}\{ |0\rangle, |1\rangle \}\end{aligned}\)
45° \(\begin{aligned}\hspace{12 mm}\{ |\frac{\pi}{4}\rangle, |\frac{3\pi}{4}\rangle \}\end{aligned}\)
22.5° \(\begin{aligned}\hspace{9 mm}\{ |\frac{\pi}{8}\rangle, |\frac{5\pi}{8}\rangle \}\end{aligned}\)
-22.5° \(\begin{aligned}\hspace{8 mm}\{ |-\frac{\pi}{8}\rangle, |\frac{3\pi}{8}\rangle \}\end{aligned}\)
where
\(\begin{aligned}\hspace{20 mm}|\frac{\pi}{4}\rangle = cos(\frac{\pi}{4})|0\rangle + sin(\frac{\pi}{4})|1\rangle, |3\frac{\pi}{4}\rangle = cos(3\frac{\pi}{4})|0\rangle + sin(3\frac{\pi}{4})|1\rangle\end{aligned}\)
\(\begin{aligned}\hspace{20 mm}|\frac{\pi}{8}\rangle = cos(\frac{\pi}{8})|0\rangle + sin(\frac{\pi}{8})|1\rangle, |5\frac{\pi}{8}\rangle = cos(5\frac{\pi}{8})|0\rangle + sin(5\frac{\pi}{8})|1\rangle\end{aligned}\)
\(\begin{aligned}\hspace{20 mm}|-\frac{\pi}{8}\rangle = cos(-\frac{\pi}{8})|0\rangle + sin(-\frac{\pi}{8})|1\rangle, |\frac{3\pi}{8}\rangle = cos(\frac{3\pi}{8})|0\rangle + sin(\frac{3\pi}{8})|1\rangle\end{aligned}\)
and (see calculator)
\(\begin{aligned}\hspace{20 mm}cos(\frac{\pi}{4}) = \frac{\sqrt{2}}{2} = 0.7071..., sin(\frac{\pi}{4}) = \frac{\sqrt{2}}{2} = 0.7071... \end{aligned}\)
\(\begin{aligned}\hspace{20 mm}cos(\frac{\pi}{8}) = \frac{\sqrt{2 + \sqrt{2}}}{2} = 0.9238..., sin(\frac{\pi}{8}) = \frac{\sqrt{2 - \sqrt{2}}}{2} = 0.3826... \end{aligned}\)
Figure 5: Classical and quantum predictions |
Tuesday, 21 February 2023
Bell states and measurements
Figure 1: John Bell |
The four Bell states are:
Circuit 1:\(|\Phi^+\rangle\) |
\(\begin{aligned}\hspace{20 mm}|\Phi^+\rangle = \frac{|00\rangle + |11\rangle}{\sqrt2}\end{aligned}\)
Circuit 2: \(|\Phi^-\rangle\) |
\(\begin{aligned}\hspace{20 mm}|\Phi^-\rangle = \frac{|00\rangle - |11\rangle}{\sqrt2}\end{aligned}\)
Circuit 3: \(|\Psi^+\rangle\) |
\(\begin{aligned}\hspace{20 mm}|\Psi^+\rangle = \frac{|01\rangle + |10\rangle}{\sqrt2}\end{aligned}\)
Circuit 4: \(|\Psi^-\rangle\) |
\(\begin{aligned}\hspace{20 mm}|\Psi^-\rangle = \frac{|01\rangle - |10\rangle}{\sqrt2}\end{aligned}\)
All circuits are implemented with a Hadamard gate followed by a controlled NOT gate. Some circuits also utilize the Pauli-X (NOT) gate and Pauli-Z gate.[1]
Note that in some circuit editors, the Pauli-X gate may be rendered with a squared-X symbol rather than a circled-plus symbol as rendered here. Also, this is just one of many possible implementation of the Bell states.[2]
Measurements
By default, measurements are in the Z-basis.
To measure in the X-basis, use a Hadamard gate which rotates the state onto the X-axis.
Figure 2: The Hadamard gate interchanges the X- and Z-axes, and inverts the Y-axis |
To measure in the Y-basis use an inverse S gate (S†) followed by a Hadamard gate which rotates the state onto the Y-axis.
Figure 3: The S† gate performs a quarter turn clockwise about the Z-axis |
The quantum circuits for measuring in the three Pauli bases:
Figure 4: Measuring in Pauli bases |
--
[1] Description of circuits (where Zn and Xn act on qubit q[n]):
\(\begin{aligned}\hspace{5 mm}|\Phi^+\rangle = CNOT \cdot H_0 |00 \rangle\end{aligned}\)
\(\begin{aligned}\hspace{5 mm}|\Phi^-\rangle = Z_1 \cdot CNOT \cdot H_0 |00 \rangle\end{aligned}\)
\(\begin{aligned}\hspace{5 mm}|\Psi^+\rangle = X_0 \cdot CNOT \cdot H_0 |00 \rangle\end{aligned}\)
\(\begin{aligned}\hspace{5 mm}|\Psi^-\rangle = X_0 \cdot Z_1 \cdot CNOT \cdot H_0 |00 \rangle\end{aligned}\)
[2] An alternative set of circuits for creating Bell states.
Figure 5: Alternative Bell state circuits |