Skip to content

Commit

Permalink
Added U1, U2 and U3 deprecation warnings into Circuit Library (#8391)
Browse files Browse the repository at this point in the history
* Added U1, U2 and U3 deprecation warnings in Circuit Library

* corrected parentheses and removed cdots

* Remove cdots

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* moved formulas to examples

* Add linebreak

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Fix sphinx identifier

* corrected global phases

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
4 people committed Jul 27, 2022
1 parent 28802cf commit f8f638a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
16 changes: 16 additions & 0 deletions qiskit/circuit/library/standard_gates/u1.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ class U1Gate(Gate):
This is a diagonal gate. It can be implemented virtually in hardware
via framechanges (i.e. at zero error and duration).
.. warning::
This gate is deprecated. Instead, the following replacements should be used
.. math::
U1(\lambda) = P(\lambda)= U(0,0,\lambda)
.. code-block:: python
circuit = QuantumCircuit(1)
circuit.p(lambda, 0) # or circuit.u(0, 0, lambda)
**Circuit symbol:**
.. parsed-literal::
Expand Down
30 changes: 28 additions & 2 deletions qiskit/circuit/library/standard_gates/u2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,20 @@ class U2Gate(Gate):
Implemented using one X90 pulse on IBM Quantum systems:
.. math::
U2(\phi, \lambda) = RZ(\phi).RY(\frac{\pi}{2}).RZ(\lambda)
.. warning::
This gate is deprecated. Instead, the following replacements should be used
.. math::
U2(\phi, \lambda) = U\left(\frac{\pi}{2}, \phi, \lambda\right)
.. code-block:: python
circuit = QuantumCircuit(1)
circuit.u(pi/2, phi, lambda)
**Circuit symbol:**
Expand All @@ -49,11 +61,25 @@ class U2Gate(Gate):
**Examples:**
.. math::
U2(\phi,\lambda) = e^{i \frac{\phi + \lambda}{2}}RZ(\phi)
RY\left(\frac{\pi}{2}\right) RZ(\lambda)
= e^{- i\frac{\pi}{4}} P\left(\frac{\pi}{2} + \phi\right)
\sqrt{X} P\left(\lambda- \frac{\pi}{2}\right)
.. math::
U2(0, \pi) = H
.. math::
U2(0, 0) = RY(\pi/2)
.. math::
U2(-\pi/2, \pi/2) = RX(\pi/2)
.. seealso::
:class:`~qiskit.circuit.library.standard_gates.U3Gate`:
Expand Down
18 changes: 18 additions & 0 deletions qiskit/circuit/library/standard_gates/u3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@
class U3Gate(Gate):
r"""Generic single-qubit rotation gate with 3 Euler angles.
.. warning::
This gate is deprecated. Instead, the following replacements should be used
.. math::
U3(\theta, \phi, \lambda) = U(\theta, \phi, \lambda)
.. code-block:: python
circuit = QuantumCircuit(1)
circuit.u(theta, phi, lambda)
**Circuit symbol:**
.. parsed-literal::
Expand Down Expand Up @@ -52,6 +65,11 @@ class U3Gate(Gate):
**Examples:**
.. math::
U3(\theta, \phi, \lambda) = e^{-i \frac{\pi + \theta}{2}} P(\phi + \pi) \sqrt{X}
P(\theta + \pi) \sqrt{X} P(\lambda)
.. math::
U3\left(\theta, -\frac{\pi}{2}, \frac{\pi}{2}\right) = RX(\theta)
Expand Down

0 comments on commit f8f638a

Please sign in to comment.