2

It stated in Qiskit's documentation.

This question arose after I accidentally called the U3 gate with parameter $\theta$=$2\pi$ in the program and Qiskit executed the program without error:

tetha = 2 * np.pi
qc.u3(theta, phi, lam, reg)

I checked other values out of bounds and every time it worked (including looping at a distance of $4\pi$) according to the formula for U from the documentation (judging by the resulting unitary operator) but ignoring violation of declared boundaries for $\theta$, e.g:

print(Operator(U3Gate(1.5 * np.pi, 0, 0)))
print(Operator(U3Gate(5.5 * np.pi, 0, 0)))
print(Operator(U3Gate(-.5 * np.pi, 0, 0)))
print(Operator(U3Gate(3.5 * np.pi, 0, 0)))

Operator([[-0.70710678+0.j, -0.70710678+0.j], [ 0.70710678+0.j, -0.70710678+0.j]], input_dims=(2,), output_dims=(2,)) Operator([[-0.70710678+0.j, -0.70710678+0.j], [ 0.70710678+0.j, -0.70710678+0.j]], input_dims=(2,), output_dims=(2,)) Operator([[ 0.70710678+0.j, 0.70710678+0.j], [-0.70710678+0.j, 0.70710678+0.j]], input_dims=(2,), output_dims=(2,)) Operator([[ 0.70710678+0.j, 0.70710678+0.j], [-0.70710678+0.j, 0.70710678+0.j]], input_dims=(2,), output_dims=(2,))

But do $\theta$ values outside the declared range make any real sense in quantum computing?

Or is it just a little flaw in Qiskit?

Just in case, the formula for the U3 gate is $$ \mathrm{U3}= \begin{pmatrix} \cos(\theta/2) & -\mathrm{e}^{i\lambda}\sin(\theta/2) \\ \mathrm{e}^{i\phi}\sin(\theta/2) & \mathrm{e}^{i(\phi+\lambda)}\cos(\theta/2) \end{pmatrix}. $$

Martin Vesely
  • 15,244
  • 4
  • 32
  • 75
Psanfi
  • 306
  • 1
  • 9

1 Answers1

1

You use the mathematical representation of the gate to generate something you can apply to your qubit. Nothing breaks if you input $\theta$ higher that the range given. We can see this with some examples : With $\theta = 0$ and not thinking about the phase, $$ U3 = \begin{pmatrix} 1 & 0 \\ 0 & 1 \\ \end{pmatrix} $$ With $\theta = \frac{\pi}{2}$ and not thinking about the phase, $$ U3 = \begin{pmatrix} 0.7071 & 0.7071 \\ 0.7071 & 0.7071 \\ \end{pmatrix} $$ With $\theta = \pi$ and not thinking about the phase, $$ U3 = \begin{pmatrix} 0 & 1 \\ 1 & 0 \\ \end{pmatrix} $$ With $\theta = \frac{3\pi}{2}$ and not thinking about the phase, $$ U3 = \begin{pmatrix} -0.7071 & 0.7071 \\ 0.7071 & -0.7071 \\ \end{pmatrix} $$ With $\theta = 2\pi$ and not thinking about the phase, $$ U3 = \begin{pmatrix} -1 & 0 \\ 0 & -1 \\ \end{pmatrix} $$ The process then continues alternating a global phase of -1 and 1. As you can see the only thing changing are the pbases and not the complex amplitudes so there is no problem with the quantum computation.

BrockenDuck
  • 887
  • 6
  • 27