From 0dd75ab4f5d9b15ebb45c0ceacb837600bd71371 Mon Sep 17 00:00:00 2001 From: ThunderBolt-OS Date: Fri, 15 Mar 2024 23:31:21 +0530 Subject: [PATCH] added hadamard and phase gate --- docs/quantum-gates-circuits/hadamard-gate.md | 113 +++++++++++++++++++ docs/quantum-gates-circuits/phase-gate.md | 111 ++++++++++++++++++ 2 files changed, 224 insertions(+) create mode 100644 docs/quantum-gates-circuits/hadamard-gate.md create mode 100644 docs/quantum-gates-circuits/phase-gate.md diff --git a/docs/quantum-gates-circuits/hadamard-gate.md b/docs/quantum-gates-circuits/hadamard-gate.md new file mode 100644 index 0000000..cd05b12 --- /dev/null +++ b/docs/quantum-gates-circuits/hadamard-gate.md @@ -0,0 +1,113 @@ +--- +sidebar_position: 3 +sidebar_label: 3. Hadamard Gate +--- + +# Hadamard Gate +## Definition + +The Hadamard gate is a single qubit gate that is used to create superposition. The Hadamard gate is named after the mathematician Jacques Hadamard. The Hadamard gate is used to change the state of the qubit in terms of the $X$ and $Z$ axes of the Bloch sphere. The Hadamard gate is used to perform the bit-flip and phase-flip operations. The Hadamard gate is the most commonly used gate in quantum computing after the Pauli gates. + +## Effect on qubit + +The Hadamard gate changes the state of the qubit from $|0\rangle$ to $\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$ and vice versa. The Hadamard gate changes the phase of the qubit from $+1$ to $-1$ and vice versa. + +PS: you must be thinking that the operations performed by the Hadamard gate are similar to the Pauli gates. Well, you are right! The Hadamard gate is a combination of the Pauli-X and Pauli-Z gates. The Hadamard gate is the most versatile gate in quantum computing, as it can be used to create superposition, entanglement, and perform phase-flip and bit-flip operations. + +## Types +The Hadamard gate has only one type. + +## Matrix representation + +The matrix representation of the Hadamard gate is: + * `Hadamard gate`: $\frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$ + +## Circuit representation + +The Hadamard gate is represented as ` ───H─── ` in the circuit. + +## Example + +Let's take an example to demonstrate the Hadamard gate. + +Certainly! Let's explore an example demonstrating the working of the Hadamard gate in excruciating detail. + +## Hadamard Gate (H) +Suppose we have a qubit initially in the state $ |0\rangle $, represented as: + +$$ +|q_0\rangle = |0\rangle +\tag{7} +$$ + +The Hadamard gate is represented by the following matrix: + +$$ +H = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} +\tag{8} +$$ + +To apply the Hadamard gate to the qubit $ |q_0\rangle = |0\rangle $, we perform a matrix multiplication of the Hadamard gate matrix with the state vector representing $ |0\rangle $. + +$$ +H|q_0\rangle = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} +\tag{9} +$$ + +Performing the matrix multiplication: + +$$ +H|q_0\rangle = \frac{1}{\sqrt{2}} \begin{bmatrix} 1*1 + 1*0 \\ 1*1 - 1*0 \end{bmatrix} +\tag{10} +$$ + +Simplifying: + +$$ +H|q_0\rangle = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 \\ 1 \end{bmatrix} +\tag{11} +$$ + +Therefore, after applying the Hadamard gate, the state of the qubit $ |q_0\rangle $ transforms to: + +$$ +|q_1\rangle = H|q_0\rangle = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 \\ 1 \end{bmatrix} +\tag{12} +$$ + +The ket representation of the final state is: + +$$ +|q_1\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) +\tag{13} +$$ + +The circuit representation of this operation is as follows: + +Initial state: |0⟩ + + ───H─── + +Final state: $\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle$ + +## Properties + +The properties of the Hadamard gate are: + * The Hadamard gate is Hermitian, i.e., the conjugate transpose of the gate is equal to the gate itself (i.e., $H^\dagger = H$). + * The Hadamard gate is involutory, i.e., applying the gate twice results in the identity gate. + * The Hadamard gate is a unitary gate, i.e., the inverse of the gate is equal to the conjugate transpose of the gate (i.e., $H^{-1} = H^\dagger$). + +## Conjugate transpose + +The conjugate transpose of the Hadamard gate is: + * `Hadamard gate`: $\frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$ + +## Inverse + +The inverse of the Hadamard gate is: + * `Hadamard gate`: $\frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$ + +## Dagger + +The dagger of the Hadamard gate is: + * `Hadamard gate`: $H^\dagger = H$ \ No newline at end of file diff --git a/docs/quantum-gates-circuits/phase-gate.md b/docs/quantum-gates-circuits/phase-gate.md new file mode 100644 index 0000000..b821246 --- /dev/null +++ b/docs/quantum-gates-circuits/phase-gate.md @@ -0,0 +1,111 @@ +--- +sidebar_position: 4 +sidebar_label: 4. Phase Gate +--- + +# Phase Gate + +## Definition +The phase gate is a single qubit gate that is used to change the phase of the qubit. The phase gate is also known as the $R_\phi$ gate. The phase gate is used to change the phase of the qubit in terms of the $Z$ axis of the Bloch sphere. The phase gate is used to perform the phase-flip operation. The phase gate is the most commonly used gate in quantum computing after the Pauli gates and the Hadamard gate. + +## Effect on qubit +The phase gate changes the phase of the qubit from $+1$ to $-1$ and vice versa. + +PS: wait wait wait! You are probably thinking that this particular operation is performed by Pauli-Z gate as well. I mean exact same operation right. Okay, this Phase gate is a generalization of the Pauli-Z gate. What do I mean by generalization, well both of these gates perform the same operation, but Pauli-Z gate introduces the phase change of $\pi$ ($180$ Degrees) to the $1\rangle$, while the Phase gate introduces a phase change of $\pi/2$ ($90$ Degrees) to the $1\rangle$. Thats the difference between the two gates. + +3. Types: The phase gate has only one type. + +4. Matrix representation: The matrix representation of the phase gate is: + * `Phase gate`: $\begin{bmatrix} 1 & 0 \\ 0 & e^{i\phi} \end{bmatrix}$ + +5. Circuit representation: The phase gate is represented as ` ───Rz─── ` in the circuit. + +6. Example: Let's take an example to demonstrate the phase gate. + +Certainly! Let's explore an example demonstrating the working of the phase gate in excruciating detail. + +* Phase Gate (Rz) +Suppose we have a qubit initially in the state $ |0\rangle $, represented as: + +$$ +|q_0\rangle = |0\rangle +\tag{14} +$$ + +The phase gate is represented by the following matrix: + +$$ +Rz = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\phi} \end{bmatrix} +\tag{15} +$$ + +To apply the phase gate to the qubit $ |q_0\rangle = |0\rangle $, we perform a matrix multiplication of the phase gate matrix with the state vector representing $ |0\rangle $. + +$$ +Rz|q_0\rangle = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\phi} \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} +\tag{16} +$$ + +Performing the matrix multiplication: + +$$ +Rz|q_0\rangle = \begin{bmatrix} 1*1 + 0*0 \\ 0*1 + e^{i\phi}*0 \end{bmatrix} +\tag{17} +$$ + +Simplifying: + +$$ +Rz|q_0\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} +\tag{18} +$$ + +Therefore, after applying the phase gate, the state of the qubit $ |q_0\rangle $ remains unchanged. Which means the phase gate does not change the state of the qubit, it only changes the phase of the qubit. + +Lets take the phase of the qubit to be $\phi = \pi/2$, then the matrix representation of the phase gate is: + +$$ +Rz = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\pi/2} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix} +\tag{19} +$$ + +So, after applying the phase gate, the state of the qubit $ |q_0\rangle $ transforms to: + +$$ +|q_1\rangle = Rz|q_0\rangle = \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 1*1 + 0*0 \\ 0*1 + i*0 \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \end{bmatrix} +\tag{20} +$$ + +The ket representation of the final state is: + +$$ +|q_1\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} = |0\rangle +\tag{21} +$$ + +The circuit representation of this operation is as follows: + +Initial state: |0⟩ + + ───Rz─── + +Final state: |0⟩ + +## Properties +The properties of the phase gate are: + * The phase gate is Hermitian, i.e., the conjugate transpose of the gate is equal to the gate itself (i.e., $Rz^\dagger = Rz$). + * The phase gate is involutory, i.e., applying the gate twice results in the identity gate. + * The phase gate is a unitary gate, i.e., the inverse of the gate is equal to the conjugate transpose of the gate (i.e., $Rz^{-1} = Rz^\dagger$). + +## Conjugate +ranspose: The conjugate transpose of the phase gate is: + * `Phase gate`: $\begin{bmatrix} 1 & 0 \\ 0 & e^{i\phi} \end{bmatrix}$ + +## Inverse +The inverse of the phase gate is: + * `Phase gate`: $\begin{bmatrix} 1 & 0 \\ 0 & e^{i\phi} \end{bmatrix}$ + +## Dagger + +The dagger of the phase gate is: + * `Phase gate`: $Rz^\dagger = Rz$ \ No newline at end of file