From 7a1f8d100175f5112e90373daf891c0c9847fc91 Mon Sep 17 00:00:00 2001 From: casellimarco7 Date: Mon, 8 May 2023 17:53:00 +0200 Subject: [PATCH 1/4] Complexity is linear in number of qubits --- intro.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intro.Rmd b/intro.Rmd index 015b423..b56810b 100644 --- a/intro.Rmd +++ b/intro.Rmd @@ -450,7 +450,7 @@ A function $f :\{0,1\}^n \mapsto \{0,1\}$ is balanced if $f(x)=0$ for half of th (ref:deutsch1992rapid) [@deutsch1992rapid] ::: {.theorem name="Deutsch-Josza (ref:deutsch1992rapid)"} -Assume to have quantum access (as definition \@ref(def:quantum-oracle-access) ) to a unitary $U_f$ that computes the function $f :\{0,1\}^n \mapsto \{0,1\}$, which we are promised to be either constant or balanced. There is a quantum algorithm that decides which is the case with probabiliy $1$, using $U_f$ only once and using $O(\log(n))$ other gates. +Assume to have quantum access (as definition \@ref(def:quantum-oracle-access) ) to a unitary $U_f$ that computes the function $f :\{0,1\}^n \mapsto \{0,1\}$, which we are promised to be either constant or balanced. There is a quantum algorithm that decides which is the case with probabiliy $1$, using $U_f$ only once and using $O(n)$ other gates. ::: ::: {.proof} @@ -498,7 +498,7 @@ as a learning algorithm. ### Bernstein-Vazirani ::: {.theorem name="Bernstein-Vazirani"} -Assume to have quantum access (as definition \@ref(def:quantum-oracle-access) ) to a unitary $U_f$ that computes the function $f :\{0,1\}^n \mapsto \{0,1\}$, which computes $f_a(x) = (x,a) = ( \sum_i^n x_i a_i )\mod 2$ for a secret string $a \in \{0,1\}^n$. There is a quantum algorithm that learns $a$ with probability $1$, using $U_f$ only once and $O(\log(n))$ other gates. +Assume to have quantum access (as definition \@ref(def:quantum-oracle-access) ) to a unitary $U_f$ that computes the function $f :\{0,1\}^n \mapsto \{0,1\}$, which computes $f_a(x) = (x,a) = ( \sum_i^n x_i a_i )\mod 2$ for a secret string $a \in \{0,1\}^n$. There is a quantum algorithm that learns $a$ with probability $1$, using $U_f$ only once and $O(n)$ other gates. ::: ::: {.proof} From 81c6b7d565d90c9f9d1726ed83cb76772b2da922 Mon Sep 17 00:00:00 2001 From: casellimarco7 Date: Mon, 8 May 2023 17:58:46 +0200 Subject: [PATCH 2/4] Fix states and coefficients --- intro.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intro.Rmd b/intro.Rmd index b56810b..255aa8b 100644 --- a/intro.Rmd +++ b/intro.Rmd @@ -506,7 +506,7 @@ The algorithm follows exactly the same steps as the Deutsch-Josza algorithm. The \begin{equation} -\left(\frac{1}{\sqrt{2^n}} \sum_{x\in\{0,1\}^n}(-1)^{f(x)} \ket{x} \right) \ket{-} = \left(\frac{1}{\sqrt{2^n}} \sum_{x\in\{0,1\}^n} (-1)^{a^T x}\ket{x} \right)\ket{-} +\left(\frac{1}{\sqrt{2^n}} \sum_{x\in\{0,1\}^n}(-1)^{f(x)} \ket{x} \right) \ket{-} = \left(\frac{1}{2^n} \sum_{x\in\{0,1\}^n} (-1)^{a^T x}\ket{x} \right)\ket{-} \end{equation} Now we resort again to Lemma \@ref(lem:hadamard-on-bitstring), and we use the fact that the Hadamard it is also a self-adjoint operator (i.e. it is the inverse of itself: $H^2 = I$). Thus applying $n$ Hadamard gates to the first register leads to the state $\ket{a}$ deterministically. From 2bafc9634da17967c960987b3c6fb79ce8e20b85 Mon Sep 17 00:00:00 2001 From: casellimarco7 Date: Mon, 8 May 2023 18:06:02 +0200 Subject: [PATCH 3/4] Add clarifications for Hadamard test --- intro.Rmd | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/intro.Rmd b/intro.Rmd index 255aa8b..1ff08dc 100644 --- a/intro.Rmd +++ b/intro.Rmd @@ -578,10 +578,9 @@ Can you tell what is the expected value of the observable $Z$ of the ancilla qub -However, we might be interested in the imaginary part of -$\braket{\psi|U|\psi}$. To estimate that, we need to slightly change the +With the method described we can estimate the real part of $\braket{\psi|U|\psi}$ however, being it a complex number, in order to fully describe it we need a procedure to estimate also its imaginary part. To estimate that, we need to slightly change the circuit. After the first Hadamard gate, we apply on the ancilla qubit a -phase gate $S$, which gives to the state $\ket{1}$ a phase of $-i$. To get +phase gate $S$, which gives to the state $\ket{1}$ a phase of $-i$. This operation may be interpreted as a 90 degrees rotation, enabling us to swap the real and imaginary axis to then make a measurement on the imaginary one. To get the intuition behind this, let's recall that the imaginary part of a complex number $z=(a+ib)$ is defined as: $\text{Im}(z)= \frac{z-z^\ast}{2i}=\frac{i(z-z^\ast)}{-2}= \frac{-2b}{-2} =b$, @@ -609,8 +608,7 @@ Note that when taking the conjugate of our state, we changed the sign of $i$. We now have only to convince ourselves that $-i\braket{\psi|U|\psi} + i \braket{\psi|U^\dagger|\psi} = i\braket{\psi|U^\dagger -U|\psi}$ is indeed the real number corresponding to -$2\text{Im}(\braket{\psi| U|\psi})$, and thus the whole equation can be a -probability. +$2\text{Im}(\braket{\psi| U|\psi})$, and thus the probability of state 0 is expressed in function of the imaginary part of $\braket{\psi| U|\psi}$. ::: {.exercise} Can you check if the $S$ gate that we do after the first Hadamard can be performed before the last Hadamard gate instead? From 0ad3da151407a1d7cf8bb7c43b2e4d8b82d8a8b1 Mon Sep 17 00:00:00 2001 From: casellimarco7 Date: Tue, 30 May 2023 19:32:17 +0200 Subject: [PATCH 4/4] Fix rebase --- intro.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intro.Rmd b/intro.Rmd index 1ff08dc..1c62e18 100644 --- a/intro.Rmd +++ b/intro.Rmd @@ -506,7 +506,7 @@ The algorithm follows exactly the same steps as the Deutsch-Josza algorithm. The \begin{equation} -\left(\frac{1}{\sqrt{2^n}} \sum_{x\in\{0,1\}^n}(-1)^{f(x)} \ket{x} \right) \ket{-} = \left(\frac{1}{2^n} \sum_{x\in\{0,1\}^n} (-1)^{a^T x}\ket{x} \right)\ket{-} +\left(\frac{1}{\sqrt{2^n}} \sum_{x\in\{0,1\}^n}(-1)^{f(x)} \ket{x} \right) \ket{-} = \left(\frac{1}{\sqrt{2^n}} \sum_{x\in\{0,1\}^n} (-1)^{a^T x}\ket{x} \right)\ket{-} \end{equation} Now we resort again to Lemma \@ref(lem:hadamard-on-bitstring), and we use the fact that the Hadamard it is also a self-adjoint operator (i.e. it is the inverse of itself: $H^2 = I$). Thus applying $n$ Hadamard gates to the first register leads to the state $\ket{a}$ deterministically.