Lecture 018 - Hadamard Test

To measure the rotational degree of a operation U

  1. one way is to analyze the method to produce the rotation U
  2. and the other way is to look at the result of applying the rotation U.

or, do some transformation on U and then apply, for example, controlled-U.

Since determine the outcome of a computation without running it is not computable, we need to look at the result of rotation. Therefore we need to put in qubits to the rotation machine and observe the output qubit.

Rotation angle measured in z=0 plane is not the angle of rotation applied to one of the vector.

Rotation angle measured in z=0 plane is not the angle of rotation applied to one of the vector.

Facts about Rotation:

Hadamard Test allow us to measure the rotation U performed on |start\rangle giving only one copy of |start\rangle repeatedly without collapse |start\rangle to deterministic state.

Quantum Phase Estimation

Although Q.P.E. is about complex unitrary eigenvectors and values. This is not what we study today.

Some Motivation

Some Motivation

In Grover, we can:

Given an unknown |start\rangle, how to you use it to do measurement against |start\rangle multiple times?

Hadamard Test

def measureAgainstMysteryStart(U, |start>)
  Make T
  H on T
  If T then U on |start>
  H on T
  Measure T
  return |start> # that is rotated

Note that we can easily make Controll-U operation by replacing every suboperation s in U with Controll-s.

U|\text{start}\rangle = U\begin{bmatrix} a\\ b\\ c\\ d\\ \end{bmatrix} = \begin{bmatrix} e\\ f\\ g\\ h\\ \end{bmatrix}

Then we have:

Pr\{T=0\} = \left(\frac{a+e}{2}\right)^2 + \left(\frac{b+f}{2}\right)^2 + \left(\frac{c+g}{2}\right)^2 + \left(\frac{d+h}{2}\right)^2 = \langle\text{avg}|\text{avg}\rangle = \left(\cos\frac{\theta}{2}\right)^2\\ \text{and state rotate to }\frac{|\text{avg}\rangle}{\cos(\theta/2)}\\ Pr\{T=1\} = \left(\frac{a-e}{2}\right)^2 + \left(\frac{b-f}{2}\right)^2 + \left(\frac{c-g}{2}\right)^2 + \left(\frac{d-h}{2}\right)^2 = \langle\text{disp}|\text{disp}\rangle = \left(\sin\frac{\theta}{2}\right)^2\\ \text{and state rotate to }\frac{|\text{disp}\rangle}{\sin(\theta/2)}\\

Notice that all vectors |avg\rangle, |disp\rangle, |start\rangle, U|start\rangle are all in the same rotational plane. Therefore, we can reuse |start\rangle for the next test (only remake T) for testing the same operation. Moreover, observe |avg|\rangle \perp |disp\rangle.

Problems of Hadamard Test

Plot of klzzwxh:0009

Plot of y=\cos\left(\frac{\theta}{2}\right)^{2}

However, using above method, we can't distinguish between \pi + \delta and \pi - \delta. This is because our probability is squared (see above image: the x value is \theta of our rotation and the y axis is Pr\{T = 1\}).

From the above formula, Hadamard Test can distinguish rotation by 0 degrees and rotation by 180 degrees, since in the case of 0 degrees Pr\{T = 0\} = 1 and in the case of 180 degrees Pr\{T = 0\} = 0.

Q: This is strange: since rotation in a 2D plane by 180^\circ will always negate the entire vector, and there is no way to tell the difference between |v\rangle and -|v\rangle. Therefore there shouldn’t be a way to tell the difference between 0^\circ and 180^\circ rotation.

A: Suppose I have a qubit in state |v\rangle and a quantum operator U, which I promise to be either the identity operator or the Minus operator. Then, I would argue that it is possible to determine which one U is. We can see this when we do "If A then U." We know the "If A then Minus" is a useful operator, as in it helps us do things (e.g. Grover's). However, "If A then identity" is not a useful operator. So we can determine U by simply observing the side effects of using Controlled-U. (When you make a controlled version, "doing nothing" is different from "invert but only certain axis") So in summary, we don't have to test an operation by just applying it, we can transform our operation (make it a controlled version) and then test it.

Revolver Resolver

The exact Revolver Resolver pseudocode is very hard to write

- you don't have to consider side effect of Hadamard Test that rotate the original |start\rangle depending on the measuring outcome

// TODO: psdo code

Input:

Output: \theta with d digits of accuracy

Complexity: d measurements, O(1) use of \{U^{2^0}, U^{2^1}, ..., U^{2^k}\} for 2^k = 10^d (total O(d) different rotations, instead of 2^{d-1} we learned from last class)

O(nd\log d + d) if we can efficiently power matrix, O(10^d\log d + d) otherwise.

Standard Form

Any algorithm can be put into standard form: 1. make all qubits at the beginning 2. then do only quantum operations 3. then only measure at the end

Table of Content