Is there a way to map the Cu3 gate to represent a unitary matrix whose elements are complex in nature

I have this 2*2 unitary matrix one looks like U =[ -0.2840 - 0.5319i, -0.0000 - 0.7978i; -0.0000 - 0.7978i ,-0.2840 + 0.5319i] I want to represent this unitary matrix by a CU3 gate which looks like

Can someone suggest a faster way to determine all the angles? Is there any open-source code that I can use to determine these angles? Thank you for any help and suggestions.

• Just a brief side note: The matrix you've put up seems to be the one for IBM's U3 gate, not the controlled-U3 (=CU3). The controlled version would be represented by a 4x4 matrix, since it acts on two qubits. Commented Mar 22, 2022 at 12:07

2 Answers

You can essentially just read off those angles. Consider the top-left matrix element $$U_{00}=-0.2840-0.5319i=e^{i\gamma}\cos(\theta/2).$$ If you take the mod-square, you get $$|U_{00}|^2=0.2840^2+0.5319^2=\cos^2(\theta/2).$$ From there, $$e^{i\gamma}=U_{00}/\cos(\theta/2).$$ Alternatively, $$\tan\gamma=\frac{-0.5319}{-0.2840}.$$

You can use Qiskit's OneQubitEulerDecomposer class as follows:

from qiskit.quantum_info.synthesis.one_qubit_decompose import OneQubitEulerDecomposer
import numpy as np

unitary = np.array([
[-0.284 - 0.5319j, -0.0 - 0.7978j],
[ -0.0 - 0.7978j ,-0.284 + 0.5319j]
])

decomposer = OneQubitEulerDecomposer('U3')
theta, phi, lambda_, gamma = decomposer.angles_and_phase(unitary)