\documentclass[11pt]{article}
\usepackage[colorlinks=true]{hyperref}
\usepackage{fullpage}
\usepackage{graphicx}
\input{Qcircuit}
\usepackage{pict2e}
\usepackage[percent]{overpic}
\usepackage{amsmath}
\usepackage{float}
\usepackage{amsfonts}
\usepackage{float}
\usepackage{tikz}
\usepackage[linesnumbered,lined]{algorithm2e}
\makeatletter
\renewcommand{\@algocf@capt@plain}{above}% formerly {bottom}
\makeatother
\usepackage{scrextend}
\usepackage{enumitem}
\setlist[enumerate]{listparindent=\parindent}
%\newcommand{\ket}[1]{|#1\rangle}
%\newcommand{\bra}[1]{\langle#1|}
\newcommand{\proj}[1]{|#1\rangle\!\langle#1|}
\newcommand{\braket}[2]{\langle{#1}|{#2}\rangle}
\newcommand{\ketbra}[2]{|#1\rangle\!\langle#2|}
\usepackage{cleveref}%[nameinlink]
\crefname{lemma}{Lemma}{Lemmas}
\crefname{proposition}{Proposition}{Propositions}
\crefname{definition}{Definition}{Definitions}
\crefname{theorem}{Theorem}{Theorems}
\crefname{conjecture}{Conjecture}{Conjectures}
\crefname{corollary}{Corollary}{Corollaries}
\crefname{section}{Section}{Sections}
\crefname{appendix}{Appendix}{Appendices}
\crefname{figure}{Fig.}{Figs.}
\crefname{equation}{Eq.}{Eqs.}
\crefname{table}{Table}{Tables}
\crefname{algocf}{Algorithm}{Algorithms}
\title{CS333 - Problem Set 9\\\small{Due: Wednesday, May 2nd before class}}
\author{}
\date{}
\parindent=.25in
\begin{document}
\maketitle
\vspace{-1cm}
See final page for hints.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{enumerate}
\item
\begin{enumerate}
\item \textbf{[6 points]} Let $\ket{\psi}$ and $\ket{\phi}$ be any single-qubit states (not necessarily standard basis states), and let $\textsc{swap}$ denote the $2$-qubit gate that swaps its input qubits (i.e., $\textsc{swap}\ket{\eta}\ket{\mu}=\ket{\mu}\ket{\eta}$ for any states $\ket{\mu}$ and $\ket{\eta}$). What is the output state of the following circuit (in terms of $\ket{\psi}$ and $\ket{\phi}$ )?
\begin{align}
\Qcircuit @C=1em @R=.7em @!R {
\lstick{\ket{0}} & \gate{H} & \ctrl{1} & \gate{H} & \qw \\
\lstick{\ket{\psi}} & \qw & \multigate{1}{\textsc{swap}} & \qw & \qw \\
\lstick{\ket{\phi}} & \qw & \ghost{\textsc{swap}} & \qw & \qw
}
\end{align}
\item \textbf{[6 points]} Suppose the top qubit in the above circuit is measured in the standard basis. What is the probability that the measurement result is $0$?
\item \textbf{[6 points]} How do the results of the previous parts change if $\ket{\psi}$ and $\ket{\phi}$ are $n$-qubit states, and $\textsc{swap}$ denotes the $2n$-qubit gate that swaps the first $n$ qubits with the last $n$ qubits?
\item \textbf{[6 points]} What is this circuit used for?
\end{enumerate}
\item Analysis of details of period finding algorithm we skipped in class :)
\begin{enumerate}
\item \textbf{[6 points]} In class, we showed that the probability of getting an outcome $\ket{y}$ in the final measurement of the period finding algorithm is
\begin{align}
Pr(\ket{y})=\frac{1}{Nm_{b^*}}\left|\sum_{m=0}^{m_{b^*}-1}e^{-2\pi i m r y/N}\right|^2.
\end{align}
Using the geometric series formula, and the fact that
\begin{align}
\sin(\theta)=\frac{e^{i\theta}-e^{-i\theta}}{2i},
\end{align}
show that
\begin{align}
Pr(\ket{y})=\frac{\sin^2(\pi r y m_{b^*}/N)}{Nm_{b^*}\sin^2(\pi r y/N)}.
\end{align}
\item \textbf{[6 points]} Plot $Pr(\ket{y})$ (note this function is not continuous!) for $N=400$, $r=7$, and $m_b^*=\lceil N/r \rceil$ using any plotting software (e.g. matplotlib for python, mathematica, etc)
\item \textbf{[6 points]} You should find that there are 6 outcomes that are particularly likely. Take one of these outcomes, divide by $400$ to get $y/N$ and find the congruents of this fraction. Show that the congruent closest to $y/N$ with denominator less than $\sqrt{400}=20$ has denominator equal to $7.$ What does this mean?
\end{enumerate}
\item \textbf{This problem is moved to problem set 10, so you do not need to complete for PS 9.}\\ In class, we showed how to create a quantum error correcting code that protected against an error of the form $X$ on any of the three qubits. Show that this code also protects against any error that is a rotation about the $\hat{x}$ axis of the Bloch sphere. That is, an error of the form:
\begin{align}
X_\theta=\cos(\theta)I+i\sin(\theta)X=
\left(
\begin{array}{cc}
\cos(\theta)& i\sin(\theta)\\
i\sin(\theta)& \cos(\theta).
\end{array}
\right).
\end{align}
To do this, consider the error correcting circuit we looked at in class:
\begin{align}
\Qcircuit @C=1em @R=.7em @!R {
\ustick{A}& \ctrl{3} & \qw & \qw & \qw & \qw \\
\ustick{B}& \qw & \ctrl{2} & \ctrl{3} & \qw & \qw \\
\ustick{C}& \qw & \qw & \qw & \ctrl{2} & \qw \\
\lstick{\ket{0}}& \targ & \targ & \qw & \qw & \meter \\
\lstick{\ket{0}}& \qw & \qw & \targ & \targ & \meter \\
}
\end{align}
\begin{enumerate}
\item \textbf{[6 points]} Suppose that an error $X_\theta$ occurred on the qubit $A$ before running the error correction scheme. So the effective circuit with error is
\begin{align}
\Qcircuit @C=1em @R=.7em @!R {
\ustick{A}& \gate{X_\theta} & \ctrl{3} & \qw & \qw & \qw & \qw \\
\ustick{B}& \qw& \qw & \ctrl{2} & \ctrl{3} & \qw & \qw \\
\ustick{C}& \qw &\qw & \qw & \qw & \ctrl{2} & \qw \\
&\lstick{\ket{0}}& \targ & \targ & \qw & \qw & \meter \\
&\lstick{\ket{0}}& \qw & \qw & \targ & \targ & \meter \\
}
\end{align}
If the input state to the circuit in Eq. (19) is $a\ket{000}_{ABC}+b\ket{111}_{ABC}$, what are the possible measurement outcomes of the final two qubits, and what does the system collapse to in the case of each possible outcome?
\item \textbf{[6 points]} Based on the measurement outcome, what should you do to recover $a\ket{000}+b\ket{111}$
\item \textbf{[6 points]} The calculation is similar if $X_\theta$ occurs on $B$ or $C$. What are the measurement outcomes in each case, and how should you correct the error based on the measurement outcome? (You do not need to do any calculations, just state what happens and what you should do, given the results of part a/b, and the analysis we did in class.)
\item \textbf{[6 points]} Explain why you don't have to know $\theta$ in order to correct the error. Why is the collapse helpful?
\end{enumerate}
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
{\Large{Hints!}}
\begin{enumerate}
\item
\begin{enumerate}
\item Solution: $\frac{1}{2}[\ket{0}(\ket{\psi}\ket{\phi}+\ket{\phi}\ket{\psi})
+\ket{1}(\ket{\psi}\ket{\phi}-\ket{\phi}\ket{\psi})]$
\item Solution: $\frac{1}{4}\left(2+2\left|\braket{\psi}{\phi}\right|^2\right)$. Remember a state is normalized if it's inner product with itself is 1.
\end{enumerate}
\item
\item
\begin{enumerate}
\item Outcome $\ket{00}\rightarrow a\cos(\theta)\ket{000}+b\cos(\theta)\ket{111}$. Outcome, $\ket{10}\rightarrow a\cos(\theta)\ket{100}+b\cos(\theta)\ket{011}$. No other outcomes possible.
\end{enumerate}
\end{enumerate}
\end{document}