# Two-level unitary gates are decomposed into single-qubit gates and CNOT gates

I am currently studying the following from the book 'QUANTUM COMPUTING: From Linear Algebra to - Mikio Nakahara' and trying to apply it to Qiskit.

But there is one point that I don't quite understand. I used the following U matrix for decomposition.

$$U = \begin{pmatrix} 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & -\frac{\sqrt{2}}{2} & -\frac{\sqrt{2}}{2} \\\\ 0 & 0 & \frac{\sqrt{2}}{2} & -\frac{\sqrt{2}}{2} \end{pmatrix}$$

I have calculated two cases for $$\theta$$, $$\lambda$$, and $$\mu$$. Two cases are $$(\pi/4, \pi, \pi)$$ and $$(-3\pi/4, 0, 0)$$

The reason for adding '-' to the ry and rz gates in the first case applied to Qiskit is because the rotation direction of the ry and rz gates in the textbook I am referring to is opposite to that in Qiskit.

%matplotlib inline
import numpy as np
from qiskit import *
from qiskit.extensions import *
from qiskit.quantum_info import Statevector

matrix = np.array([
[1,0,0,0],
[0,1,0,0],
[0,0,-np.sqrt(2)/2,-np.sqrt(2)/2],
[0,0,np.sqrt(2)/2,-np.sqrt(2)/2]
])

theta = np.pi/4
lambda_val = np.pi
mu = np.pi

alpha = lambda_val + mu
beta = 2*theta
gamma = lambda_val - mu

qc = QuantumCircuit(2)
qc.rz((alpha-gamma)/2, 0)
qc.cx(1, 0)
qc.ry(beta/2, 0)
qc.rz((alpha+gamma)/2, 0)
qc.cx(1, 0)
qc.rz(-alpha, 0)
qc.ry(-beta/2, 0)

ket = Statevector(qc)
ket.draw('latex')


In this case output is $\frac{\sqrt{2}}{2}|00\rangle - \frac{\sqrt{2}}{2}|01\rangle$
and this code is the second case $(-3\pi/4, 0, 0)$

%matplotlib inline
import numpy as np
from qiskit import *
from qiskit.extensions import *
from qiskit.quantum_info import Statevector

matrix = np.array([
[1,0,0,0],
[0,1,0,0],
[0,0,-np.sqrt(2)/2,-np.sqrt(2)/2],
[0,0,np.sqrt(2)/2,-np.sqrt(2)/2]
])

theta = -3*np.pi/4
lambda_val = 0
mu = 0

alpha = lambda_val + mu
beta = 2*theta
gamma = lambda_val - mu

qc = QuantumCircuit(2)
qc.rz((alpha-gamma)/2, 0)
qc.cx(1, 0)
qc.ry(beta/2, 0)
qc.rz((alpha+gamma)/2, 0)
qc.cx(1, 0)
qc.rz(-alpha, 0)
qc.ry(-beta/2, 0)

ket = Statevector(qc)
ket.draw('latex')


second case's output is $$|00\rangle$$

Intuitively, it's evident that the first case seems to be incorrect. However, upon checking with $$\theta$$, $$\lambda$$, and $$\mu$$, the U matrix seems to be correct. Therefore, I don't understand what the difference is. Can you please help me understand?