From 1306af6f98898ebd3a08ce5a62d3e8128abf23e7 Mon Sep 17 00:00:00 2001 From: Incompleteusern <58920010+Incompleteusern@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:53:32 -0700 Subject: [PATCH] Quantum Chapter Changes (#208) * fixes * fix unintended changes * bruh? * dont expand tabs * more spacing * GHZ text * Text on Shor's * another typo * a * Some other shor comments * more? * typo by me * changes * Trailing whitespace * Rewrite comment on Nobel prize * Cleanup shor.tex --------- Co-authored-by: Evan Chen --- tex/quantum/circuits.tex | 4 +-- tex/quantum/shor.tex | 55 +++++++++++++++++++++++++--------------- tex/quantum/vectors.tex | 16 ++++++++---- 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/tex/quantum/circuits.tex b/tex/quantum/circuits.tex index 3006ee0e..6bb9796d 100644 --- a/tex/quantum/circuits.tex +++ b/tex/quantum/circuits.tex @@ -658,7 +658,7 @@ \section{Deutsch-Jozsa algorithm} \] since $H\ket0 = \frac{1}{\sqrt2}(\ket0+\ket1)$ while $H\ket1 = \frac{1}{\sqrt2}(\ket0-\ket1)$, - so minus signs arise exactly if $x_i = 0$ and $y_i = 0$ simultaneously, + so minus signs arise exactly if $x_i = 1$ and $y_i = 1$ simultaneously, hence the term $(-1)^{x_1 y_1 + \dots + x_n y_n}$. Swapping the order of summation, we get \[ @@ -682,7 +682,7 @@ \section{Deutsch-Jozsa algorithm} \] To see this, note that the result is clear for $y_1 = \dots = y_n = 0$; otherwise, if WLOG $y_1 = 1$, then the terms for $x_1 = 0$ exactly cancel - the terms for $x_1 = 0$, pair by pair. + the terms for $x_1 = 1$, pair by pair. Thus in this state, the measurements all result in $\ket0 \dots \ket0$. \ii On the other hand if $f$ is balanced, we derive that diff --git a/tex/quantum/shor.tex b/tex/quantum/shor.tex index ec4e055f..0a37328f 100644 --- a/tex/quantum/shor.tex +++ b/tex/quantum/shor.tex @@ -2,6 +2,10 @@ \chapter{Shor's algorithm} OK, now for Shor's Algorithm: how to factor $M = pq$ in $O\left( (\log M)^2 \right)$ time. +This is arguably the reason agencies such as the US's National +Security Agency have been diverting millions of dollars toward +quantum computing. + \section{The classical (inverse) Fourier transform} The ``crux move'' in Shor's algorithm is the so-called quantum Fourier transform. @@ -32,7 +36,14 @@ \section{The classical (inverse) Fourier transform} \] \end{definition} The reason this operation is important is because it lets -us detect if the $x_i$ are periodic: +us detect if the $x_i$ are periodic. +More generally, given a sequence of $1$'s appearing with period $r$, +the amplitudes will peak at inputs which are divisible by $\frac{N}{\gcd(N,r)}$. +Mathematically, we have that +\[ + x_k = \sum_{j=0}^{N-1} y_j \omega_N^{-jk}. +\] + \begin{example} [Example of discrete inverse Fourier transform] Let $N = 6$, $\omega = \omega_6 = \exp(\frac{2\pi i}{6})$ @@ -52,8 +63,6 @@ \section{The classical (inverse) Fourier transform} thus this reveals the periodicity of the original sequence by $\frac N3 = 2$. \end{example} -More generally, given a sequence of $1$'s appearing with period $r$, -the amplitudes will peak at inputs which are divisible by $\frac{N}{\gcd(N,r)}$. \begin{remark} The fact that this operation is called the ``inverse'' Fourier transform is mostly a historical accident @@ -62,8 +71,9 @@ \section{The classical (inverse) Fourier transform} (not-inverted) Fourier transform. \end{remark} If we apply the definition as written, computing the transform takes $O(N^2)$ time. -It turns out that by an algorithm called the \vocab{fast Fourier transform} -(whose details we won't discuss), one can reduce this to $O(N \log N)$ time. +It turns out that by a classical algorithm called the \vocab{fast Fourier transform} +(whose details we won't discuss, but it effectively ``reuses'' calculations), +one can reduce this to $O(N \log N)$ time. However, for Shor's algorithm this is also insufficient; we need something like $O\left( (\log N)^2 \right)$ instead. This is where the quantum Fourier transform comes in. @@ -82,6 +92,7 @@ \section{The quantum Fourier transform} where $x = x_n x_{n-1} \dots x_1$ in binary. For example, if $n = 3$ then $\ket{6}$ really means $\ket1 \otimes \ket1 \otimes \ket 0$. + Likewise, we refer to $0.x_1x_2 \dots x_n$ as binary. \end{abuse} Observe that the $n$-qubit space now has an orthonormal basis $\ket0$, $\ket1$, \dots, $\ket{N-1}$ @@ -128,8 +139,8 @@ \section{The quantum Fourier transform} In short, expand everything. \end{proof} -So by using mixed states, we can deal with the quantum Fourier transform -using this ``multiplication by tensor product'' trick that isn't possible classically. +So by using mixed states, the quantum Fourier transform +can use this ``multiplication by tensor product'' trick that isn't possible classically. Now, without further ado, here's the circuit. Define the rotation matrices @@ -143,8 +154,7 @@ \section{The quantum Fourier transform} } \] \begin{exercise} - Show that in this circuit, the image of $\ket{x_3x_2x_1}$ - (for binary $x_i$) is + Show that in this circuit, the image of $\ket{x_3x_2x_1}$ is \[ \Big(\ket0+\exp(2\pi i \cdot 0.x_1) \ket1\Big) \otimes \Big(\ket0+\exp(2\pi i \cdot 0.x_2x_1) \ket1\Big) @@ -155,15 +165,15 @@ \section{The quantum Fourier transform} For general $n$, we can write this as inductively as \[ - \Qcircuit @C=1em @R=.7em { - \lstick{\ket{x_n}} & \multigate{5}{\text{QFT}_{n-1}} & \gate{R_n} & \qw & \qw & \cdots & & \qw & \qw & \cdots & & \qw & \qw & \rstick{\ket{y_1}} \qw \\ - \lstick{\ket{x_{n-1}}} & \ghost{\text{QFT}_{n-1}} & \qw & \gate{R_{n-1}} & \qw & \cdots & & \qw & \qw & \cdots & & \qw & \qw & \rstick{\ket{y_2}} \qw \\ - \lstick{\vdots\ \ } & \pureghost{\text{QFT}_{n-1}} & & & & & & & & & & & & \rstick{\ \ \vdots} \\ - \lstick{\ket{x_i}} & \ghost{\text{QFT}_{n-1}} & \qw & \qw & \qw & \cdots & & \gate{R_i} & \qw & \cdots & & \qw & \qw & \rstick{\ket{y_{n-i+1}}} \qw \\ - \lstick{\vdots\ \ } & \pureghost{\text{QFT}_{n-1}} & & & & & & & & & & & & \rstick{\ \ \vdots} \\ - \lstick{\ket{x_2}} & \ghost{\text{QFT}_{n-1}} & \qw & \qw & \qw & \cdots & & \qw & \qw & \cdots & & \gate{R_2} & \qw & \rstick{\ket{y_{n-1}}} \qw \\ - \lstick{\ket{x_1}} & \qw & \ctrl{-6} & \ctrl{-5} & \qw & \cdots & & \ctrl{-3} & \qw & \cdots & & \ctrl{-1} & \gate{H} & \rstick{\ket{y_n}} \qw - } + \Qcircuit @C=1em @R=.7em { + \lstick{\ket{x_n}} & \multigate{5}{\text{QFT}_{n-1}} & \gate{R_n} & \qw & \qw & \cdots & & \qw & \qw & \cdots & & \qw & \qw & \rstick{\ket{y_1}} \qw \\ + \lstick{\ket{x_{n-1}}} & \ghost{\text{QFT}_{n-1}} & \qw & \gate{R_{n-1}} & \qw & \cdots & & \qw & \qw & \cdots & & \qw & \qw & \rstick{\ket{y_2}} \qw \\ + \lstick{\vdots\ \ } & \pureghost{\text{QFT}_{n-1}} & & & & & & & & & & & & \rstick{\ \ \vdots} \\ + \lstick{\ket{x_i}} & \ghost{\text{QFT}_{n-1}} & \qw & \qw & \qw & \cdots & & \gate{R_i} & \qw & \cdots & & \qw & \qw & \rstick{\ket{y_{n-i+1}}} \qw \\ + \lstick{\vdots\ \ } & \pureghost{\text{QFT}_{n-1}} & & & & & & & & & & & & \rstick{\ \ \vdots} \\ + \lstick{\ket{x_2}} & \ghost{\text{QFT}_{n-1}} & \qw & \qw & \qw & \cdots & & \qw & \qw & \cdots & & \gate{R_2} & \qw & \rstick{\ket{y_{n-1}}} \qw \\ + \lstick{\ket{x_1}} & \qw & \ctrl{-6} & \ctrl{-5} & \qw & \cdots & & \ctrl{-3} & \qw & \cdots & & \ctrl{-1} & \gate{H} & \rstick{\ket{y_n}} \qw +} \] \begin{ques} Convince yourself that when $n=3$ the two circuits displayed are equivalent. @@ -209,7 +219,7 @@ \section{Shor's algorithm} and we randomly select $x = 2$, and want to find its order $r$. Let $n = 13$ and $N = 2^{13}$, and start by initializing the state \[ \ket\psi = \frac{1}{\sqrt N} \sum_{k=0}^{N-1} \ket k. \] - Now, build a circuit $U_x$ (depending on $x=2$!) + Now, build a circuit $U_x$ (depending on $x$) which takes $\ket k \ket 0$ to $\ket k \ket{x^k \bmod M}$. Applying this to $\ket\psi \otimes \ket0$ gives \[ U(\ket\psi\ket0) = @@ -287,12 +297,15 @@ \section{Shor's algorithm} \frac{1152}{2033}, \; \dots \] - So $\frac{17}{30}$ is a very good approximation, + So $\frac{17}{30}$ is a good approximation, hence we deduce $s = 17$ and $r = 30$ as candidates. And indeed, one can check that $r = 30$ is the desired order. \end{example} -This won't work all the time (for example, we could get unlucky and +This won't work all the time\footnote{% + Not to mention the general issue of noise, but that's for + engineers to worry about. +} (for example, we could get unlucky and measure $j=0$, i.e.\ $s=0$, which would tell us no information at all). But one can show that we succeed any time that \[ \gcd(s,r) = 1. \] diff --git a/tex/quantum/vectors.tex b/tex/quantum/vectors.tex index fbe11153..aa480cf4 100644 --- a/tex/quantum/vectors.tex +++ b/tex/quantum/vectors.tex @@ -244,12 +244,15 @@ \section{Observations} \qquad \sigma_y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}. \] + These matrices are important because: \begin{ques} Show that these three matrices, plus the identity matrix, form a basis for the set of Hermitian $2 \times 2$ matrices. \end{ques} -So the Pauli matrices are a natural choice of basis. +So the Pauli matrices are a natural choice of basis.\footnote{Well, + natural due to physics reasons. +} Their normalized eigenvectors are \[ \zup = \ket0 = \pair10 \qquad \zdown = \ket1 = \pair01 \] @@ -258,7 +261,7 @@ \section{Observations} \[ \yup = \frac{1}{\sqrt2}\pair1i \qquad \ydown = \frac{1}{\sqrt2}\pair1{-i} \] which we call ``$z$-up'', ``$z$-down'', -``$x$-up'', ``$x$-down'', ``$y$-up'', ``$y$-down''. +``$x$-up'', ``$x$-down'', ``$y$-up'', ``$y$-down'' respectively. (The eigenvalues are $+1$ for ``up'' and $-1$ for ``down''.) So, given a state $\ket\psi \in \CC^{\oplus 2}$ we can make a measurement with respect to any of these three bases @@ -476,12 +479,15 @@ \section{Entanglement} \] As for the paradox: what happens if you multiply all these measurements together? \begin{hint} - $-1$, $1$, $1$, $1$. + $1$, $1$, $1$, $-1$ respectively. When we multiply them all together, we get that $\id^A \otimes \id^B \otimes \id^C$ has measurement $-1$, which is the paradox. What this means is that the values of the measurements - are created when we make the observation, - and not prepared in advance. + can't be prepared in advance independently. + In other words, this contradicts certain local hidden-variable theories. + + This was one of several results for which Zeilinger won a (shared) + Nobel Prize in 2022. \end{hint} \end{problem}