# Question About Measuring an Operator For Quantum Neural Network Paper

I'm currently reading the paper: https://arxiv.org/pdf/1802.06002.pdf

I'm a little bit stuck on the step of how to determine the following quantity:

Where U is a unitary operator acting on $$|z,1\rangle$$. The paper states the following:

I'm completely confused with the transition between expression 27 to the expression right after. How does applying a Hadamard to the auxiliary qubit result in the expression:

$$\frac{1}{2}(|z,1\rangle + iU|z,1\rangle |0\rangle) + \frac{1}{2}(|z,1\rangle-iU|z,1\rangle |1\rangle)$$ Shouldn't it result in $$\frac{1}{2}(|z,1\rangle |0\rangle + iU|z,1\rangle |0\rangle) + \frac{1}{2}(|z,1\rangle |0\rangle -iU|z,1\rangle |1\rangle)$$

And if this is the case, I'm confused as to how the probability of the auxiliary qubit being 1 is $$\frac{1}{2}-\frac{1}{2}Im(\langle z, 1|U|z,1\rangle)$$. Could someone explain why this is the case, and perhaps what I'm missing here?


Applying $$H$$ to the auxiliary qubit results in:

$$\frac{1}{2}(\ket{z,1}(\ket{0}+\ket{1}) + iU\ket{z,1}(\ket{0}-\ket{1}))$$

$$= \frac{1}{2}(\ket{z,1} + iU\ket{z,1})\ket{0} + \frac{1}{2}(\ket{z,1} - iU\ket{z,1})\ket{1}$$

Then the probability of having one on the auxiliary qubit is

$$p(1) = ||P_1\ket{\psi}||^2$$

where $$\ket{\psi}$$ is the whole state and $$P_1 = I \otimes \ket{1}\bra{1}$$.