# qml.templates.subroutines.DoubleExcitationUnitary¶

DoubleExcitationUnitary(weight, wires1=None, wires2=None)[source]

Circuit to exponentiate the tensor product of Pauli matrices representing the double-excitation operator entering the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz. UCCSD is a VQE ansatz commonly used to run quantum chemistry simulations.

The CC double-excitation operator is given by

$\hat{U}_{pqrs}(\theta) = \mathrm{exp} \{ \theta (\hat{c}_p^\dagger \hat{c}_q^\dagger \hat{c}_r \hat{c}_s - \mathrm{H.c.}) \},$

where $$\hat{c}$$ and $$\hat{c}^\dagger$$ are the fermionic annihilation and creation operators and the indices $$r, s$$ and $$p, q$$ run over the occupied and unoccupied molecular orbitals, respectively. Using the Jordan-Wigner transformation the fermionic operator defined above can be written in terms of Pauli matrices (for more details see arXiv:1805.04340):

$\hat{U}_{pqrs}(\theta) = \mathrm{exp} \Big\{ \frac{i\theta}{8} \bigotimes_{b=s+1}^{r-1} \hat{Z}_b \bigotimes_{a=q+1}^{p-1} \hat{Z}_a (\hat{X}_s \hat{X}_r \hat{Y}_q \hat{X}_p + \hat{Y}_s \hat{X}_r \hat{Y}_q \hat{Y}_p + \hat{X}_s \hat{Y}_r \hat{Y}_q \hat{Y}_p + \hat{X}_s \hat{X}_r \hat{X}_q \hat{Y}_p - \mathrm{H.c.} ) \Big\}$

The quantum circuit to exponentiate the tensor product of Pauli matrices entering the latter equation is shown below (see arXiv:1805.04340):

As explained in Seely et al. (2012), the exponential of a tensor product of Pauli-Z operators can be decomposed in terms of $$2(n-1)$$ CNOT gates and a single-qubit Z-rotation referred to as $$U_\theta$$ in the figure above. If there are $$X$$ or:math:Y Pauli matrices in the product, the Hadamard ($$H$$) or $$R_x$$ gate has to be applied to change to the $$X$$ or $$Y$$ basis, respectively. The latter operations are denoted as $$U_1$$, $$U_2$$, $$U_3$$ and $$U_4$$ in the figure above. See the Usage Details section for more details.

Parameters
• weight (float) – angle $$\theta$$ entering the Z rotation acting on wire p

• wires1 (Iterable or Wires) – Wires of the qubits representing the subset of occupied orbitals in the interval [s, r]. Accepts an iterable of numbers or strings, or a Wires object, with minimum length 2. The first wire is interpreted as s and the last wire as r. Wires in between are acted on with CNOT gates to compute the parity of the set of qubits.

• wires2 (Iterable or Wires) – Wires of the qubits representing the subset of unoccupied orbitals in the interval [q, p]. Accepts an iterable of numbers or strings, or a Wires object. Must be of minimum length 2. The first wire is interpreted as q and the last wire is interpreted as p. Wires in between are acted on with CNOT gates to compute the parity of the set of qubits.

Raises

ValueError – if inputs do not have the correct format

Notice that:

1. $$\hat{U}_{pqrs}(\theta)$$ involves eight exponentiations where $$\hat{U}_1$$, $$\hat{U}_2$$, $$\hat{U}_3$$, $$\hat{U}_4$$ and $$\hat{U}_\theta$$ are defined as follows,

$\begin{split}[U_1, && U_2, U_3, U_4, U_{\theta}] = \\ && \Bigg\{\bigg[H, H, R_x(-\frac{\pi}{2}), H, R_z(\theta/8)\bigg], \bigg[R_x(-\frac{\pi}{2}), H, R_x(-\frac{\pi}{2}), R_x(-\frac{\pi}{2}), R_z(\frac{\theta}{8}) \bigg], \\ && \bigg[H, R_x(-\frac{\pi}{2}), R_x(-\frac{\pi}{2}), R_x(-\frac{\pi}{2}), R_z(\frac{\theta}{8}) \bigg], \bigg[H, H, H, R_x(-\frac{\pi}{2}), R_z(\frac{\theta}{8}) \bigg], \\ && \bigg[R_x(-\frac{\pi}{2}), H, H, H, R_z(-\frac{\theta}{8}) \bigg], \bigg[H, R_x(-\frac{\pi}{2}), H, H, R_z(-\frac{\theta}{8}) \bigg], \\ && \bigg[R_x(-\frac{\pi}{2}), R_x(-\frac{\pi}{2}), R_x(-\frac{\pi}{2}), H, R_z(-\frac{\theta}{8}) \bigg], \bigg[R_x(-\frac{\pi}{2}), R_x(-\frac{\pi}{2}), H, R_x(-\frac{\pi}{2}), R_z(-\frac{\theta}{8}) \bigg] \Bigg\}\end{split}$
2. For a given quadruple [s, r, q, p] with $$p>q>r>s$$, seventy-two single-qubit and 16*(len(wires1)-1 + len(wires2)-1 + 1) CNOT operations are applied. Consecutive CNOT gates act on qubits with indices between s and r and q and p while a single CNOT acts on wires r and q. The operations performed across these qubits are shown in dashed lines in the figure above.

An example of how to use this template is shown below:

import pennylane as qml
from pennylane.templates import DoubleExcitationUnitary

dev = qml.device('default.qubit', wires=5)

@qml.qnode(dev)
def circuit(weight, wires1=None, wires2=None):
DoubleExcitationUnitary(weight, wires1=wires1, wires2=wires2)
return qml.expval(qml.PauliZ(0))

weight = 1.34817
print(circuit(weight, wires1=[0, 1], wires2=[2, 3, 4]))