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 1\vert 1 \rangle amplitude by eiλe^{i\lambda} and leaves 0\vert 0 \rangle alone. It acts on one qubit and takes one parameter, the angle λ\lambda 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 0\vert 0 \rangle name the basis states and rotations are described on the Bloch sphere; the qubits lesson introduces both.

Call

WhereCall
Pythonqc.p(λ, qubit)
JScircuit.p(λ, qubit)
Qiskit classPhaseGate
Controlled formcp(λ, control, target)

Matrix

P(λ)=(100eiλ)P(\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\lambda} \end{pmatrix}

On the Bloch sphere this is a rotation about the Z axis by λ\lambda. 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

InputOutput
0\vert 0 \rangle0\vert 0 \rangle
1\vert 1 \rangleeiλ1e^{i\lambda}\vert 1 \rangle
+\vert + \rangle12(0+eiλ1)\tfrac{1}{\sqrt{2}}(\vert 0 \rangle + e^{i\lambda}\vert 1 \rangle)

A measurement straight after P shows no change on 0\vert 0 \rangle or 1\vert 1 \rangle, 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.

Stay in the loop.

Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.