# Hadamard gate as a product of $R_x$, $R_z$ and a phase

I am having problems with this task.

Since the Hadamard gate rotates a state $$180°$$ about the $$\hat{n} = \frac{\hat{x} + \hat{z}}{\sqrt{2}}$$ axis, I imagine the solution can be found the following way:

First rotate $$\hat{n}$$ so it lies in the $$z$$-$$y$$ plane: $$R_z(\pi/2)$$ Then rotate $$\hat{n}$$ so it is parallell with the $$z$$-axis: $$R_x(\pi/4)$$ Now do the desired rotation about the $$z$$-axis: $$R_z(\pi)$$ Then rotate $$\hat{n}$$ back to its original position. The Hadamard gate can then be written: $$H = e^{i\lambda}R_z(-\pi/2)R_x(-\pi/4) R_z(\pi) R_x(\pi/4) R_z(\pi/2)$$ However, this doesn't seem to work. Can someone explain where my logic is flawed? Thank you very much

• Check exercise 4.4 of this PDF. It should explain your concern. – cnada Jan 24 '19 at 12:55
• I think you are right but maybe when doing your calculations, you are not dividing by 2 the angles in the rotation matrix definition. – cnada Jan 25 '19 at 10:44

Why do you say that it doesn't work? If I enter the following code into Mathematica, it works fine:

X = {{0, 1}, {1, 0}};
Z = {{1, 0}, {0, -1}};
FullSimplify[-I MatrixExp[-I Pi Z/4].MatrixExp[-I Pi X/8].MatrixExp[I Pi Z/2].MatrixExp[I Pi X/8].MatrixExp[I Pi Z/4]]


The only thing that I had to remember was to halve the angles compared to how you wrote them (because $$R_Z(\pi)$$ should give a $$Z$$ rotation, which is $$e^{i\pi Z/2}$$). That's the place that I always make the mistake with these calculations...

• Thank you very much! Not sure where my mistake was, but I wrote down the matrices in wolframalpha. With python it worked fine! – QCQCQC Jan 27 '19 at 22:02

As far as I can tell, it works fine. If I use the channel-state duality to view this sequence of operation's effect in Quirk's output display, it's the Hadamard gate's matrix:

Maybe you're multiplying or dividing by 2 somewhere you shouldn't be, when performing the operations?

• I am sure thats what i did wrong! Thank you very much – QCQCQC Jan 27 '19 at 22:03

Check exercise 4.4 of this PDF. It should explain your concern.

I think you are right but maybe when doing your calculations, you are not dividing by 2 the angles in the rotation matrix definition.

• Thank you for the answer. I have looked at that solution. Even though it solves the problem, it doesnt explain why my logic is flawed – QCQCQC Jan 24 '19 at 13:09