2
$\begingroup$

Havlicek et al. propose a feature map for embedding $n$-dimensional classical data on $n$ qubits: $U_{\phi(x)}H^{\otimes n}$, where $$ U_{\phi(x)} = \exp (i \sum_{S \subseteq [n]} \phi_S(x) \prod_{i \in S} Z_i) \\ \phi_i(x) = x_i, \; \phi_{\{i, j\}}(x) = (\pi - x_0)(\pi - x_1) $$ and $Z_i$ is a $Z$-gate on the $i$-th qubit.

I'm currently considering the 2-dimensional, 2-qubit case, $$ U_{\phi(x)} = \exp(i x_0 Z_0 + i x_1 Z_1 + i (\pi - x_0) (\pi - x_1) Z_0 Z_1), $$ and trying to find out, how do I get from the above definition to the circuit, as it is implemented in Qiskit:

     ┌───┐┌──────────────┐                                           
q_0: ┤ H ├┤ U1(2.0*x[0]) ├──■─────────────────────────────────────■──
     ├───┤├──────────────┤┌─┴─┐┌───────────────────────────────┐┌─┴─┐
q_1: ┤ H ├┤ U1(2.0*x[1]) ├┤ X ├┤ U1(2.0*(π - x[0])*(π - x[1])) ├┤ X ├
     └───┘└──────────────┘└───┘└───────────────────────────────┘└───┘

My reasoning for the first 2 $U1$ rotations is that since $\exp(i \theta Z) = RZ(2 \theta)$ up to global phase and $RZ$ is equivalent to $U1$ up to global phase, we might as well use $U1(2 \phi_i(x))$. Is that correct?

And if so, how do we then get $CX \; U1(2 \phi_{\{0, 1\}}(x)) \; CX$ from $\exp(i \phi_{\{0, 1\}}(x) Z_0 Z_1)$?

$\endgroup$

1 Answer 1

3
$\begingroup$

By the definition of $U1(\lambda) $ in qiskit, it is equivalent to $RZ$ up up a phase factor .

Now note that: $$Z_0 Z_1 = Z \otimes Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} \otimes \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0\\ 0 & 0 & -1 & 0\\ 0 & 0 & 0 & 1\end{pmatrix} $$

since this is diagonal, we have that $$ e^{-i\lambda Z_0Z_1} = \begin{pmatrix} e^{-i\lambda} & 0 & 0 & 0 \\ 0 & e^{i\lambda} & 0 & 0\\ 0 & 0 & e^{i\lambda} & 0\\ 0 & 0 & 0 & e^{-i\lambda}\end{pmatrix} = \begin{pmatrix} R_Z(2\lambda) & \boldsymbol{0}\\ \boldsymbol{0} & X R_Z(2\lambda) X\end{pmatrix} $$

since $XR_Z(2\lambda) X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} e^{-i\lambda} & 0 \\ 0 & e^{i\lambda} \end{pmatrix} \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} = \begin{pmatrix} e^{i\lambda} & 0 \\ 0 & e^{-i\lambda} \end{pmatrix} $

Thus, to implement $e^{-i \lambda Z_0Z_1}$ we would have a circuit like:

enter image description here

Note that this circuit can be written as $CX \cdot (I \otimes R_Z ) \cdot CX$. Also by knowing this, you can check this explicitly as well, by first note that

$$ I \otimes R_Z(2\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} \otimes \begin{pmatrix} e^{-i\lambda} & 0 \\ 0 & e^{i\lambda}\end{pmatrix} = \begin{pmatrix} e^{-i\lambda} & 0 & 0 & 0 \\ 0 & e^{i\lambda} & 0 & 0\\ 0 & 0 & e^{-i\lambda} & 0\\ 0 & 0 & 0 & e^{i\lambda}\end{pmatrix} $$ then $CX \cdot \big(I \otimes RZ(2\lambda) \big) \cdot CX$ is equal to $$ \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0\end{pmatrix} \begin{pmatrix} e^{-i\lambda} & 0 & 0 & 0 \\ 0 & e^{i\lambda} & 0 & 0\\ 0 & 0 & e^{-i\lambda} & 0\\ 0 & 0 & 0 & e^{i\lambda}\end{pmatrix} \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0\end{pmatrix} = \begin{pmatrix} e^{-i\lambda} & 0 & 0 & 0 \\ 0 & e^{i\lambda} & 0 & 0\\ 0 & 0 & e^{i\lambda} & 0\\ 0 & 0 & 0 & e^{-i\lambda}\end{pmatrix} $$

$\endgroup$
4
  • $\begingroup$ Thank you for the answer! Just one more question. Why can we go from $e^{i \lambda Z_0 Z_1}$ (as in $U_{\phi(x)}$) to $e^{-i \lambda Z_0 Z_1}$? Wouldn't that imply that $R_z(\lambda) = R_z(-\lambda)$, which seems to only be true for $\lambda = k \pi, \; k \in \mathbb{Z}$? $\endgroup$
    – lazybvr
    Jun 9, 2021 at 0:10
  • $\begingroup$ I just realize that you are considering $e^{i\lambda ZZ}$ instead of $e^{-i \lambda ZZ}$. In such cases, the $RZ$ rotation gate should sandwiched between the two CNOT gates should be $RZ(-2\lambda)$ instead of $RZ(2 \lambda)$. $\endgroup$
    – KAJ226
    Jun 9, 2021 at 0:48
  • $\begingroup$ That's the issue. The circuit still uses $U1(\lambda)$ instead of $U1(-\lambda)$. Found a relevant article, where they're using the same circuit Qiskit does, however, they define $U1(\lambda) = diag\{1, e^{-i \lambda}\}$, which would solve the sign issue. Could it be that the direction of rotation doesn't really matter? I'm using this feature map to estimate the kernel $K(x, y) = \Phi(x) \Phi(y)$, by measuring $(U_{\phi(y)} H^{\otimes n})^\dagger U_{\phi(x)} H^{\otimes n}$. Since $K(x, y) = K(y, x)$ and $U1(\lambda)^\dagger = U1(-\lambda)$, it seems so? $\endgroup$
    – lazybvr
    Jun 9, 2021 at 12:10
  • $\begingroup$ Or, more simply put (since I've run out of space), we're still going to measure the same overlap $\Phi(x) \Phi(y)$, as long as we're consistently rotating in one direction, be it clockwise or counter-clockwise. What do you think? $\endgroup$
    – lazybvr
    Jun 9, 2021 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.