Skip to content

Commit

Permalink
Quantum Chapter Changes (#208)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
Incompleteusern and vEnhance authored Nov 14, 2023
1 parent b0b19cd commit 1306af6
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 28 deletions.
4 changes: 2 additions & 2 deletions tex/quantum/circuits.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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
\[
Expand All @@ -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
Expand Down
55 changes: 34 additions & 21 deletions tex/quantum/shor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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})$
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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}$
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -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. \]
Expand Down
16 changes: 11 additions & 5 deletions tex/quantum/vectors.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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 \]
Expand All @@ -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
Expand Down Expand Up @@ -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}

0 comments on commit 1306af6

Please sign in to comment.