La puerta de Hadamard


¿Qué es una puerta Hadamard?

La puerta de Hadamard es un operador de computación cuántica, muy simple a la vez que, probablemente, de los más usados. Su utilidad reside en su capacidad de convertir un qubit de un estado, tal que |0\rangle o |1\rangle, en una superposición de los mismos. Veamos los detalles.

La puerta de Hadamard se nombra con H y se define de forma matricial tal que H= \dfrac{1}{ \sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}

\huge { \text {Puerta de Hadamard }  H= \dfrac{1}{ \sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} }

Y efectivamente, si aplicamos una puerta Hadamard a |0\rangle queda tal que:

\dfrac{1}{ \sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} |0\rangle = \dfrac{1}{ \sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \dfrac{1}{ \sqrt{2}} \begin{pmatrix} 1 \\ 1 \end{pmatrix} = \dfrac{1}{ \sqrt{2}} (|0\rangle + |1\rangle)

…de igual manera si aplicamos Hadamard a un qubit |1\rangle tendremos:

\dfrac{1}{ \sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} |1\rangle = \dfrac{1}{ \sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \dfrac{1}{ \sqrt{2}} \begin{pmatrix} 1 \\ -1 \end{pmatrix} = \dfrac{1}{ \sqrt{2}} (|0\rangle - |1\rangle)

Apliquemos Hadamard sobre estados en otras bases:

H |+\rangle = \dfrac{1}{ \sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \dfrac{1}{ \sqrt{2}} (|0\rangle + |1\rangle) = \dfrac{1}{2} \begin{pmatrix} 2  \\ 0 \end{pmatrix} = \begin{pmatrix} 1 \\ 0 \end{pmatrix} = |0\rangle

como no podía ser de otra manera, ya que H es unitaria y reversible.

Es muy útil hacer una pequeña transformación y escribir H de manera genérica para un x \in \{0,1\} tal que H|x\rangle = \dfrac {1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} |x\rangle = \dfrac{1}{\sqrt{2}}(|0\rangle + (-1)^{x}|1\rangle) , efectivamente

H|x\rangle  = \dfrac{1}{\sqrt{2}}(|0\rangle + (-1)^{x}|1\rangle) = \left\{ \begin{aligned} & \text{si x=0 } H|0\rangle = \dfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle)  \\ & \text{si x=1 } H|1\rangle = \dfrac{1}{\sqrt{2}}(|0\rangle - |1\rangle) \end{aligned}  \right.

y podemos ir un paso más allá y escribir la expresión tal que :

H |x \rangle  = \dfrac{1}{\sqrt{2}}\left(|0\rangle + (-1)^{x}|1\rangle\right) = \dfrac{1}{\sqrt{2}} \left(\sum\limits_{y=0}^{1}(-1)^{xy}|y\rangle\right) \text{para } x\in \{0,1\}

Hadamard sobre multiples qubits..

Hadamard es una puerta que opera sobre un sólo qubit, pero en circuitos multiqubits no es infrecuente aplicar simultáneamente esta puerta sobre todos los qubits. En algunos textos se le denomina tensor Hadamard o H^{\otimes n} . Hagamos un caso práctico de aplicación de este tensor a un estado cuántico genérico | \psi \rangle = |x_{1} x_{2}x_{3}..x_{n}\rangle con x_{i} \in \{0,1\} \forall i \in \{1,2..,n\}

H^{\otimes n}| \psi \rangle = H^{\otimes n} |x_{1} x_{2}x_{3}..x_{n}\rangle = H |x_{1}\rangle \otimes H |x_{2} \rangle \otimes H |x_{3} \rangle \otimes ..H|x_{n}\rangle

..es importante ver que se está aplicando una puerta a cada uno de los estados simples y multiplicando tensorialmento esos n resultados. Utilizando la expresión genérica que usamos en el apartado anterior podemos continuar con:

H |x_{1} \rangle \otimes H |x_{2}\rangle  \otimes H |x_{3}\rangle \otimes \cdots H|x_{n}\rangle = \dfrac{1}{\sqrt{2}}(|0\rangle + (-1)^{x_{1}}|1\rangle) \otimes \dfrac{1}{\sqrt{2}}(|0\rangle + (-1)^{x_{2}}|1\rangle)\cdots\otimes \dfrac{1}{\sqrt{2}}(|0\rangle + (-1)^{x_{n}}|1\rangle) =  \dfrac{1}{\sqrt{2}}\left(\sum\limits_{y_{1}=0}^{1}(-1)^{x_{1}y_{1}}|y_{1}\rangle\right) \otimes \left(\sum\limits_{y_{2}=0}^{1}(-1)^{x_{1}y_{2}}|y_{2}\rangle\right) \cdots \otimes \left(\sum\limits_{y_{n}=0}^{1}(-1)^{x_{n}y_{n}}|y_{n}\rangle\right)

..que se puede simplificar con \dfrac{1}{\sqrt{2^{n}}} \sum\limits_{y\in\{0,1\}^{n}}(-1)^{x_{1}y_{1}+x_{2}y_{2}\cdots x_{n}y_{n}}|y\rangle = \dfrac{1}{\sqrt{2^{n}}} \left(\sum\limits_{y\in\{0,1\}^{n}}(-1)^{\sum\limits_{i=1}^{n}x_{i}y_{i}}|y\rangle  \right)

La manera intuitiva de llegar a esta última expresión es viendo como cada componente |0\rangle de cuaquier estado de múltiples qubits lleva siempre signo positivo, ya que todo producto x_iy_i con x_i=0 será cero, y el componte |1\rangle lleva un signo tal que (-1)^{x_{i}} , que se suman para el estado final de multiples qubits.

Veamos un caso particular con n=3..

H^{\otimes n}| \psi \rangle = H^{\otimes 3} |x_{1} x_{2}x_{3} \rangle= H |x_{1}\rangle \otimes H |x_{2} \rangle \otimes H |x_{3} \rangle = \dfrac{1}{ \sqrt{2^{3}}} \left ( \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} |x_{1} \rangle \otimes \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} |x_{2} \rangle \otimes \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} |x_{3} \rangle \right) = \dfrac{1}{ \sqrt{2^{3}}} \bigg ( \Big ((-1)^{x_{1}*0}|0\rangle + (-1)^{x_{1}*1}|1\rangle \Big ) \Big ((-1)^{x_{2}*0}|0\rangle + (-1)^{x_{2}*1}|1\rangle \Big ) \Big ((-1)^{x_{3}*0}|0\rangle + (-1)^{x_{3}*1}|1\rangle \Big ) \bigg ) = \dfrac{1}{ \sqrt{2^{3}}} \Big ( (-1)^{(x_{1}*0+x_{2}*0+x_{3}*0)} |000\rangle + (-1)^{(x_{1}*0+x_{2}*0+x_{3}*1)} |001\rangle + (-1)^{(x_{1}*0+x_{2}*1+x_{3}*0)} |010\rangle + (-1)^{(x_{1}*0+x_{2}*1+x_{3}*1)} |011\rangle + (-1)^{(x_{1}*1+x_{2}*0+x_{3}*0)} |100\rangle + (-1)^{(x_{1}*1+x_{2}*0+x_{3}*1)} |101\rangle + (-1)^{(x_{1}*1+x_{2}*1+x_{3}*0)} |110\rangle + (-1)^{(x_{1}*1+x_{2}*1+x_{3}*1)} |111\rangle \Big ) = \dfrac{1}{ \sqrt{2^{3}}} \Big (|000\rangle + (-1)^{(x_{3})} |001\rangle + (-1)^{(x_{2})} |010\rangle + (-1)^{(x_{2}+x_{3})} |011\rangle + (-1)^{(x_{1})} |100\rangle +(-1)^{(x_{1}+x_{3})} |101\rangle + (-1)^{(x_{1}+x_{2})} |110\rangle + (-1)^{(x_{1}+x_{2}+x_{3})} |111\rangle \Big )

Hemos visto la definición de la puerta de Hadamard, su utilidad para provocar una superposición desde un estado de una sola base, y hemos trabajado un poco de álgebra para generar una expresión genérica del tensor Hadamard sobre múltiples qubits, que será muy útil en la demostración del algoritmo de Deutsch-Jozsa que veremos más adelante.

Por cierto, esta puerta debe su nombre al matemático francés Jacques Hadamard.

Un comentario en “La puerta de Hadamard

Replica a Algoritmo de Deutsch – En el Vaticano hay dos Papas por kilómetro cuadrado Cancelar la respuesta

Este sitio utiliza Akismet para reducir el spam. Conoce cómo se procesan los datos de tus comentarios.