P gate
The P gate, a phase of any angle: matrix, effect on the basis states, the p() call in Python and JS, and why it costs nothing on IonQ hardware.
The P gate multiplies the amplitude by and leaves alone. It acts on one qubit and takes one parameter, the angle in radians. The Circuit panel draws it as P(λ) with the angle shown as a multiple of π. On its own it changes nothing a measurement can see, whatever the angle; the phase shows once the qubit is in superposition.
Kets such as name the basis states and rotations are described on the Bloch sphere; the qubits lesson introduces both.
Call
| Where | Call |
|---|---|
| Python | qc.p(λ, qubit) |
| JS | circuit.p(λ, qubit) |
| Qiskit class | PhaseGate |
| Controlled form | cp(λ, control, target) |
Matrix
On the Bloch sphere this is a rotation about the Z axis by . It is the same operation as rz(λ) up to a global phase. The fixed-angle gates are special cases: p(π) is Z, p(π/2) is S, p(π/4) is T.
Effect on basis states
| Input | Output |
|---|---|
A measurement straight after P shows no change on or , whatever the angle. The phase shows once the qubit is in superposition.
Inverse
The inverse of p(λ) is p(-λ).
Usage
from math import pi
from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.p(pi, 0)
qc.h(0)
qc.measure(0, 0)
import { QuantumCircuit } from 'qiskit';
const circuit = QuantumCircuit(1, 1);
circuit.h(0);
circuit.p(Math.PI, 0);
circuit.h(0);
circuit.measure(0, 0);
Every shot reads 1: p(π) is a Z, and H Z H is an X. A smaller angle gives a smaller share of 1s.
On IonQ hardware
P is a virtual Z. The compiler folds the angle into the phase of the next pulse, so it costs no gate and no time on the machine, whatever the angle. See How your circuit is compiled.
Related
Stay in the loop.
Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.
Gates