7

I want to build a circuit which will implement $e^{iAt}$, where $ A= \begin{pmatrix} 1.5 & 0.5\\ 0.5 & 1.5\\ \end{pmatrix} $ and $t= \pi/2 $. We see that $A$ can be written as, $A=1.5I+0.5X$. Since $I$ and $X$ commute, $e^{iAt}=e^{i(1.5I)t}e^{i(0.5X)t}$.

Evaluating manually, I get $e^{iAt}=1/2\begin{pmatrix} e^{2it}+e^{it} & e^{2it}-e^{it}\\ e^{2it}-e^{it} & e^{2it}+e^{it}\\ \end{pmatrix}.$

Question

How can I decompose the matrix $"1/2\begin{pmatrix} e^{2it}+e^{it} & e^{2it}-e^{it}\\ e^{2it}-e^{it} & e^{2it}+e^{it}\\ \end{pmatrix}"$ into elementary quantum gates

Omkar
  • 341
  • 1
  • 9

3 Answers3

7

There is actually a nice way to do this in Qiskit, since it has decompositions for single-qubit unitaries built in. The QuantumCircuit.squ method takes a unitary 2x2 matrix $U$ and a qubit and computes the decomposition

$$ U = R_Z(\alpha) R_Y(\beta) R_Z(\gamma) $$

This is a common decomposition, you can find a proof here https://arxiv.org/pdf/quant-ph/9503016.pdf in Lemma 4.1.

Here's how to do it in Qiskit:

import numpy as np
from scipy.linalg import expm
from qiskit import QuantumCircuit, QuantumRegister

# define your matrix
A = np.array([[1.5, 0.5],
              [0.5, 1.5]])
t = np.pi / 2

# expm is a matrix exponential 
U = expm(1j * t * A)

# create a 1 qubit circuit
q = QuantumRegister(1, name='q')
circuit = QuantumCircuit(q)

# apply a single-qubit unitary gate, this will do the decomposition
circuit.squ(U, q[0])

# print the circuit components
print(circuit.decompose().decompose().draw())

This will print

        ┌──────────┐┌───────────┐┌───────────┐
q_0: |0>┤ Rz(pi/2) ├┤ Ry(-pi/2) ├┤ Rz(-pi/2) ├
        └──────────┘└───────────┘└───────────┘

So your decomposition would be $$ e^{iAt} = R_Z\left(\frac{\pi}{2}\right) R_Y\left(-\frac{\pi}{2}\right) R_Z\left(\frac{-\pi}{2}\right) $$

with

$$ R_Y(\theta) = \begin{pmatrix} \cos(\theta / 2) & -\sin(\theta / 2) \\ \sin(\theta / 2) & \cos(\theta / 2) \end{pmatrix} $$ and $$ R_Z(\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\lambda} \end{pmatrix} $$

You can also drop the last RZ gate if you don't care about the global phase. That's also supported in Qiskit using the up_to_diagonal argument:

# apply a single-qubit unitary gate, this will do the decomposition
circuit.squ(U, q[0], up_to_diagonal=True)

# print the circuit components
print(circuit.decompose().decompose().draw())

which produces

        ┌──────────┐┌───────────┐
q_0: |0>┤ Rz(pi/2) ├┤ Ry(-pi/2) ├
        └──────────┘└───────────┘

Here's the implementation in Qiskit: https://qiskit.org/documentation/_modules/qiskit/extensions/quantum_initializer/squ.html.

Cryoris
  • 2,993
  • 8
  • 15
4

You want to implement $$ e^{i3\pi/4}e^{iX\pi/4}. $$ I would rewrite this as $$ e^{i3\pi/4}He^{iZ\pi/4}H. $$ This is the same as $$ -HS^\dagger H $$ in standard gate terminology.

If you're only implementing the gate $e^{iAt}$, then you can neglect the global phase and just implement $HS^\dagger H$. Both of these gates are readily implemented in qiskit as sdg and h. OK, you can probably implement the basic rotation directly using rx(pi/2,), but this construction is far more relevant in the following case (keeping the global phase a little nicer):

If you're wanting to use this inside something like the HHL algorithm where you actually need controlled-$e^{iAt}$, then you implement controlled-$HS^\dagger H$, and follow it up with a $Z$ gate on the control qubit in order to get the no-longer-global phase correct. Furthermore, note that something like HHL required controlled-$e^{i2^kAt}$ for various integers $k$. Well, we've done the $k=0$ case. But from the way I've written things, I think it makes it more obvious that for $k=1$, you're just doing controlled-not ($HS^\dagger HHS^\dagger H=HZH=X$). And you don't have to do anything at all for larger $k$ ($X^{2^{k-1}}=I$ for $k\geq 2$).

DaftWullie
  • 62,671
  • 4
  • 55
  • 140
3

I think this is enough $e^{iAt}= e^{i(1.5I)t} e^{i(0.5X)t}$ for constructing the circuit. From rx and u3: $$R_x(-t) = e^{i(0.5X)t} \qquad R_x(\theta) = u3(\theta, -\pi/2, \pi/2)$$ The $e^{i(1.5I)t}$ is a global phase gate that can be implemented via the following circuit for q[0] qubit. Here is the whole circuit for the $e^{iAt}$:

# Rx part
circuit.u3(-t, -pi/2, pi/2)

# Global phase part
circuit.u1(1.5t, q[0])
circuit.x(q[0])
circuit.u1(1.5t, q[0])
circuit.x(q[0])

The more general approach can be found in this paper (especially 4.1 Trotter decomposition).

Davit Khachatryan
  • 4,461
  • 1
  • 11
  • 22