I have this unitary matrix and i need to find the decomposition with the small number of c-not. I tried to use Quantum Shannon Decomposition but the simple form of the matrix make me think that there is a better decomposition
2 Answers
The automatic method in cirq gets it down to 12:
import cirq
import numpy as np
ops = cirq.three_qubit_matrix_to_operations(
cirq.LineQubit(0),
cirq.LineQubit(1),
cirq.LineQubit(2),
np.array([
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 1],
]),
)
print(cirq.Circuit(ops).to_text_diagram(transpose=True, use_unicode_characters=False))
It uses some CZs and some CNOTs but those are easily changed into each other.
0 1 2
| | |
Ry(0.25pi) PhX(-0.583)^0.5 |
| | |
| @------------------@
| | |
| PhX(-0.583)^0.5 PhX(-0.75)
| | |
| Z^(-5/12) |
| | |
@------------@ |
| | |
Ry(-0.25pi) | |
| | |
@-------------------------------@
| | |
Ry(0.25pi) | PhX(-0.963)^0.712
| | |
@------------@ |
| | |
Ry(-0.25pi) PhX(0.703)^0.388 |
| | |
Rz(-0.25pi) @------------------@
| | |
| PhX(0.932)^0.427 PhX(0.892)^0.24
| | |
| @------------------@
| | |
| PhX(0.703)^0.388 PhX(-0.253)^0.712
| | |
| Z^-0.195 Z^0.811
| | |
X------------@ |
| | |
Rz(-0.083pi) | |
| | |
X-------------------------------@
| | |
Rz(-0.583pi) | |
| | |
X------------@ |
| | |
Rz(0.25pi) PhX(0.935)^0.388 |
| | |
X-------------------------------@
| | |
| | PhX(-0.868)^0.288
| | |
| @------------------@
| | |
| PhX(-0.294)^0.427 PhX(-0.723)^0.24
| | |
| @------------------@
| | |
| PhX(-0.0654)^0.612 PhX(-0.578)^0.712
| | |
| Z^-0.814 Z^0.198
| | |
If you only use classical operations, I think it requires more than CNOTs. I think it needs at least three Toffolis.
If it suffices to have a high-fidelity approximation, you can use Qiskit's Approximate Quantum Compiler. Using this method, I got this decomposition which uses 9 CNOTs only and has a gate fidelity $> 0.999999999$.
And here is the circuit in OpenQasm:
OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
u(2.3561895,2.7463326e-06,-1.5707699) q[0];
u(1.5576622,-0.78531077,1.5576213) q[1];
u(3.1415867,-2.5716362,-1.1092422) q[2];
cx q[2],q[1];
u(1.5839314,-0.01313166,2.3562805) q[1];
u(2.3318564e-05,0.92545391,-pi) q[2];
cx q[2],q[0];
u(1.5708005,2.3561906,-1.5707922) q[0];
cx q[1],q[0];
u(1.5707911,-5.1910088e-06,0.78537627) q[0];
u(1.5445421,-0.78505374,0) q[1];
u(6.4580157e-07,-2.6046094,0) q[2];
cx q[2],q[1];
u(1.5445416,0.026227559,-0.78505262) q[1];
u(1.570798,-2.5261149,0) q[2];
cx q[2],q[0];
u(0.78540632,3.1415487,6.2187325e-05) q[0];
cx q[1],q[0];
u(2.3561864,-3.1415688,-3.1415589) q[0];
u(1.5708042,-pi,-pi) q[1];
u(pi/3,2.1862712,0) q[2];
cx q[2],q[1];
u(2.3036819,-pi/2,-pi/2) q[1];
u(0.78539973,2.6396889e-06,-pi) q[2];
cx q[2],q[0];
u(1.5707977,pi,2.3562036) q[0];
cx q[1],q[0];
u(pi/2,-pi,-5.4768189e-06) q[0];
u(1.5707942,2.3562523,-pi) q[1];
u(1.5707951,1.993468e-05,0) q[2];
This method is described in the paper "Best Approximate Quantum Compiling Problems" by Madden and Simonetto.