# Demystifying Quantum Gate Fidelity for Electronics Engineers
## 5 Brief Case Studies
### CNOT Quantum Gate  
As for the CNOT quantum gate operator, its ideal matrix \(A_{\text{CNOT}}\) is obtained from the matrix \(\mathbf{A}_{\omega\text{R}\text{I},\mathbf{J}}\)[22]:  
\[A_{\omega\text{R}\text{I},\mathbf{J}}= \begin{bmatrix}-j&\mathbf{0}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&-j&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\text{\it cos}\left(\frac{\theta}{2}\right)&-j\text{\it sin} \left(\frac{\theta}{2}\right)\\ \mathbf{0}&\mathbf{0}&-j\text{\it sin}\left(\frac{\theta}{2}\right)&\text{\it cos} \left(\frac{\theta}{2}\right)\end{bmatrix}  \tag{50}\]  
by forcing the rotation angle of the qubit state vector \(\theta=\mathbf{\pi}\) and by factorizing and neglecting the global phase term \(-j\):  
\[A_{\text{CNOT}}= \begin{bmatrix}\mathbf{1}&\mathbf{0}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{1}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\mathbf{0}&\mathbf{1}\\ \mathbf{0}&\mathbf{0}&\mathbf{1}&\mathbf{0}\end{bmatrix}  \tag{51}\]  
As in the previous case, let the actual rotation angle be affected by an error \(\varepsilon\), so that \(\theta=\pi+\varepsilon\). Equation (50) yields the actual matrix \(A_{\text{CNOT}}\) of the CNOT quantum gate operator:  
\[A_{\text{CNOT}} = \begin{bmatrix}-j&\mathbf{0}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&-j&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\text{\it cos}\left(\frac{\pi}{2}+\frac{\varepsilon}{2}\right)& -j\text{\it sin}\left(\frac{\pi}{2}+\frac{\varepsilon}{2}\right)\\ \mathbf{0}&\mathbf{0}&-j\text{\it sin}\left(\frac{\pi}{2}+\frac{\varepsilon}{2} \right)&\text{\it cos}\left(\frac{\pi}{2}+\frac{\varepsilon}{2}\right)\end{bmatrix}  \tag{52}\] \[= \begin{bmatrix}-j&\mathbf{0}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&-j&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&-\text{\it sin}\left(\frac{\varepsilon}{2}\right)&-j\text{\it cos }\left(\frac{\theta}{2}\right)\\ \mathbf{0}&\mathbf{0}&-j\text{\it cos}\left(\frac{\theta}{2}\right)&-\text{\it sin} \left(\frac{\varepsilon}{2}\right)\end{bmatrix} =- \begin{bmatrix}j&\mathbf{0}&\mathbf{0 }&\mathbf{0}\\ \mathbf{0}&j&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\text{\it sin}\left(\frac{\varepsilon}{2}\right)&j\text{\it cos }\left(\frac{\theta}{2}\right)\\ \mathbf{0}&\mathbf{0}&j\text{\it cos}\left(\frac{\theta}{2}\right)&\text{\it sin} \left(\frac{\varepsilon}{2}\right)\end{bmatrix} \]  
Since the entries of the matrix \(A_{\text{CNOT}}\) are real values, \(A_{\text{CNOT}}=A_{\text{CNOT}}^{\dagger}\). Thus, from Equations (51) and (52), you obtain:  
\[A_{\text{CNOT}}^{\dagger}A_{\text{CNOT}}=- \begin{bmatrix}1&\mathbf{0}& \mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{1}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\mathbf{0}&\mathbf{1}\\ \mathbf{0}&\mathbf{0}&\mathbf{1}&\mathbf{0}\end{bmatrix}\begin{bmatrix}j&\mathbf{0}&\mathbf{0}&\mathbf{0} \\ \mathbf{0}&j&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\text{\it sin}\left(\frac{\varepsilon}{2}\right)&j\text{\it cos }\left(\frac{\theta}{2}\right)\\ \mathbf{0}&\mathbf{0}&j\text{\it cos}\left(\frac{\theta}{2}\right)&\text{\it sin} \left(\frac{\varepsilon}{2}\right)\end{bmatrix} = \tag{53}\] \[=- \begin{bmatrix}j&\mathbf{0}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&j&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&j\text{\it cos}\left(\frac{\varepsilon}{2}\right)&\text{\it sin} \left(\frac{\theta}{2}\right)\\ \mathbf{0}&\mathbf{0}&\text{\it sin}\left(\frac{\theta}{2}\right)&j\text{\it cos} \left(\frac{\varepsilon}{2}\right)\end{bmatrix} \]  
from which:  
\[\left|\text{\it Tr}\left\{A_{\text{CNOT}}^{\dagger}A_{\text{CNOT}}\right\} \right|^{2}=\left|-2j\left[1+\text{\it cos}\left(\frac{\varepsilon}{2}\right) \right]\right|^{2}=4\left[1+\text{\it cos}\left(\frac{\varepsilon}{2}\right) \right]^{2} \tag{54}\]  
The substitution of Equation (54) into Equation (42) yields:  
\[\mathbf{F}=\frac{\mathbf{4}+\mathbf{4}\left[1+\text{\it cos}\left(\frac{\varepsilon}{2} \right)\right]^{2}}{\mathbf{4}(\mathbf{4}+\mathbf{1})}=\frac{\mathbf{1}+\left[1+\text{\it cos} \left(\frac{\varepsilon}{2}\right)\right]^{2}}{\mathbf{5}} \tag{55}\]where it has been emphasized that n = 4 for a two-qubit quantum gate.