I am using jupyter notebook and qiskit. I have a simple quantum circuit and I want to know how to get the unitary matrix of the circuit without using 'get_unitary' from the Aer unitary_simulator. i.e.: By just using matrix manipulation, how do I get the unitary matrix of the circuit below by just using numpy and normal matrix properties? [![enter image description here][1]][1] I have figured out how to get the unitary matrix of the circuit below: [![enter image description here][2]][2] By using this code: import numpy as np swapcnot = np.array([[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) cnot = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]) layer1 = np.kron(np.eye(2),swapcnot) layer2 = np.kron(swapcnot, np.eye(2)) print(layer2@layer1) However when I try to add another qubit and another cnot gate, I do not get the correct result # The result I should be getting: [![enter image description here][3]][3] [1]: https://i.sstatic.net/0EjHt.png [2]: https://i.sstatic.net/jpcx9.png [3]: https://i.sstatic.net/BWieN.png