I would like to implement the operation $$ U(a,b) = \exp\left(i \frac{a}{2} (XX + YY) + i \frac{b}{2} (XY - YX) \right) $$
($a,b \in \mathbb{R}$) without using Baker-Campbell-Hausdorf expansion, which at first seems necessary since $[(XY - YX), (XX + YY)] \neq 0$. My intuition is that this can be done in the same way that $\exp(i(aX + bY))$ does not require a BCH expansion to implement. The above operation is generated by these two matrices:
\begin{align} i \frac{a}{2} (XX + YY)\rightarrow i a \begin{pmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{pmatrix} \\ i \frac{b}{2} (XY - YX)\rightarrow i b\begin{pmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & \text{-}i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 0 \end{pmatrix}. \end{align}
Since sum of these matrices is proportional to the operator $(aX - bY)$ in the $(|01\rangle,|10\rangle)$ subspace it seems possible that the operation can be done with a general single-qubit rotation $\text{R}_\hat{n}$ in that subspace. Taking the (unnormalized) unit vector $\hat{n} = a\hat{x} - b\hat{y}$ this rotation is given by
$$ \text{R}_\hat{n} (\theta) = \cos\frac{\theta}{2} + i \sin \frac{\theta}{2} (a X - b Y) $$
so that the operation can be implemented as
$$ U(a, b) = \text{CNOT}^{2\rightarrow 1} \text{CR}_{\hat{n}}(\theta)^{1\rightarrow 2} \text{CNOT}^{2\rightarrow 1} $$
where $\text{CR}_{\hat{n}}(\theta)$ is a controlled version of $\text{R}_\hat{n}$ and $i\rightarrow j$ indicates an operation on qubit $j$ controlled by qubit $i$. My main concern is that since neither $(XY - YX)$ nor $(XX + YY)$ has support in the $|00\rangle, |11\rangle$ subspace that there's something missing or wrong in this process.
My question is, is this a valid decomposition for $U(a, b)$ or is there something wrong in the above reasoning?
scipy.linalg.expm
. $\endgroup$