Quantum Computing Asked on August 18, 2021
I am trying to understand the Hadamard Test by finding the average value of $U_1$, which is a diagonal matrix with $1$ everywhere except on the first element.
I performed the regular Hadamard Test as presented in the wiki page:
and so far so good, everything works as it should.
What is the circuit variant to perform the Hadamard Test to calculate the imaginary part? The wiki page says you only have to start with $frac{1}{sqrt{2}}(|0rangle-i |1rangle)$ instead of $H|0rangle$, I attempted doing the test adding a phase shift of -i on $|0rangle$ by applying $U_s$ = $begin{bmatrix} 1 & 0 0 & -i end{bmatrix}$ on the control qubit after $H$, but all im getting is random measurements
Here is a circuit for calcualating $Im(langlepsi|U |psi rangle)$ (circuit composer from IBM):
Initial state: $$|Psi_0 rangle=|0rangle |psirangle$$
After $S^{dagger} H$ on the first qubit:
$$|Psi_1 rangle=frac{1}{sqrt{2}}(|0rangle - i|1rangle) |psirangle$$
Controlled $U$
$$|Psi_2 rangle=frac{1}{sqrt{2}}(|0rangle |psirangle - i|1rangle U |psirangle)$$
After final Hadamard on the control qubit:
begin{align*} |Psi_3 rangle &=frac{1}{2} big[(|0rangle + |1rangle) |psirangle - i(|0rangle - |1rangle) U |psirangle big] = &=frac{1}{2} big[|0rangle (|psirangle - i U |psirangle) + |1rangle(|psirangle + i U |psirangle) big] end{align*}
The probability of measuring $|0rangle$ and the probability of measuring $|1rangle$:
$$p_0 = frac{1}{4}big[(langle psi | + i langle psi | U^{dagger})(|psirangle - i U |psirangle) big]= frac{1}{4}big[2 - i langlepsi|U|psirangle + i langlepsi|U^{dagger}|psirangle big] p_1 = frac{1}{4}big[(langle psi | - i langle psi | U^{dagger})(|psirangle + i U |psirangle) big]= frac{1}{4}big[2 + i langlepsi|U|psirangle - i langlepsi|U^{dagger}|psirangle big]$$
because $U^dagger U = I$ and $langle psi|psi rangle = 1$. Calculating the expectation value of $sigma_z$:
$$langle sigma_z rangle = p_0 - p_1 = -i frac{langlepsi|U |psi rangle - langlepsi| U^{dagger} |psi rangle}{2} = Im(langlepsi|U |psi rangle)$$
So the circuit works as was described in the Wikipedia page about the Hadamard test.
Correct answer by Davit Khachatryan on August 18, 2021
Here, I think you wanted this link
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[1];
x q[0];
x q[1];
h q[0];
s q[0];
cu1(pi) q[0],q[1];
h q[0];
measure q[0] -> c[0];
Answered by Rahul Pratap Singh on August 18, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP