# Why is a Hadamard gate unitary?

The Hadamard gate is a unitary gate, but how does the matrix times its own conjugate transpose actually result in the $$I$$ matrix? I am currently looking at it as a scalar, 0.707..., multiplied by the matrix of ones and negative one.

$$\begin{equation} H=\frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \end{equation}$$

• Have you tried taking the conjugate transpose of the H matrix (which is equal to itself) and multiplying it by H to see what the result looks like? I'm not sure what exactly the question is... Jan 3, 2020 at 8:36
• sorry i am trying to learn. when i look at the matrix, i see a probability on the left (0.707), which can treated be a scalar and multiplied across each value in the matrix on the right. The first column would be .707, .707, and the second would be .707, -.707. So in my head i am picturing something other than the I matrix. I appreciate your help :) Jan 3, 2020 at 8:42
• @VP9 but what you're describing in your previous comment is just the matrix, not the matrix multiplied by itself. Jan 3, 2020 at 10:17

The Hadamard gate is described by this matrix $$\begin{equation} H=\frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \end{equation}$$ Conjugate transpose of $$H$$ is again $$H$$. Hence we have to check if $$HH$$ is $$I$$.

Multiplication goes as follows ($$h_{ij}$$ denotes elements of resulting matrix):

1. $$h_{11} = 1\cdot1 + 1\cdot1 = 2$$
2. $$h_{12} = 1\cdot 1 + 1\cdot (-1) = 0$$
3. $$h_{21} = 1 \cdot1 + (-1) \cdot 1= 0$$
4. $$h_{21} = 1 \cdot1 + (-1)\cdot (-1) = 2$$

So

$$\begin{equation} HH=\frac{1}{\sqrt{2}}\frac{1}{\sqrt{2}} \begin{pmatrix} 2 & 0 \\ 0 & 2 \end{pmatrix} = \frac{1}{2} \begin{pmatrix} 2 & 0 \\ 0 & 2 \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} =I. \end{equation}$$

• mind blown. poof. Jan 3, 2020 at 18:44
• Is the answer satisfactory for you? If so, would you mind to accept it? Jan 3, 2020 at 18:47

Just a side comment to this question.

In the real world nothing is so obvious.

Example: Try to define Hadamard gate in Ruby language. Even when trying to define gate by using rational numbers which helps us sometimes to keep good precision the answer is that Hadamard is not unitary.

m = (1 / Math.sqrt(2)).to_r * Matrix[[1,  1],
[1, -1]]


Then

m.unitary?


results false and result of m*m multiplication is as below:

Matrix[[2535301200456458353478625262249/2535301200456458802993406410752, 0/1],
[0/1, 2535301200456458353478625262249/2535301200456458802993406410752]]


That means if we really want to be sure that something is 'true' as it should be, we need to double check existing feature in language and maybe fix/write own code when needed.

• I'm not familiar with Ruby - does m.unitary? give true if you omit the .to_r? Of course $1/\sqrt{2}$ isn't rational, so it isn't clear to me whether the fractional form your code uses would be more precise. Apr 23, 2022 at 4:24