Skip to content

Commit

Permalink
Add clarifications for Hadamard test
Browse files Browse the repository at this point in the history
  • Loading branch information
casellimarco committed May 30, 2023
1 parent 81c6b7d commit 2bafc96
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,9 @@ Can you tell what is the expected value of the observable $Z$ of the ancilla qub

<!-- Solution: it's just $\braket{\psi U \psi}$ -->

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$,
Expand Down Expand Up @@ -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?
Expand Down

0 comments on commit 2bafc96

Please sign in to comment.