3

I would like to implement $S^{\dagger}$ gate in Q# and I would like the best way to do it, is it correct to say that $S^{\dagger}$ is equivalent to R1( -Pi()/2 , q) ? Is it also correct to say that $S^{\dagger}$ is equivalent to Rz( -Pi()/2 , q) but with a global phase ?

Thank you.

luciano
  • 5,763
  • 1
  • 12
  • 34
user12910
  • 451
  • 4
  • 8

2 Answers2

4

Since the S operation supports the Adjoint functor, the Q# call Adjoint S(target) is the easiest way to call the $S^{\dagger}$ gate.

To verify that this is the same as the suggestion made above by Tharrmashastha V, you can use the AssertOperationsEqualReferenced operation:

AssertOperationsEqualReferenced(1,
    ApplyToEachCA(Adjoint S, _),
    ApplyToEachCA(Rz(-PI() / 2.0, _), _)
);
Chris Granade
  • 1,068
  • 7
  • 10
1

It is correct. Since you have $R_1(\theta) = \begin{bmatrix}1 & 0\\ 0 & e^{i\theta}\end{bmatrix}$ and $R_z(\theta) = \begin{bmatrix}e^{-i\theta/2} & 0\\ 0 & e^{i\theta/2}\end{bmatrix}$ just using the value of $\theta = -\pi/2$ gives you $R_1(-\pi/2) = \begin{bmatrix}1 & 0\\ 0 & -i\end{bmatrix} = S^{\dagger}$ and $R_z(-\pi/2) = e^{i\pi/4}\begin{bmatrix}1 & 0\\ 0 & -i\end{bmatrix}$ which works exactly the same as $S^{\dagger}$ but with a global phase of $e^{i\pi/4}$.

Tharrmashastha V
  • 394
  • 1
  • 13