S gate
The S gate, a quarter-turn phase: matrix, effect on the basis states, the s() call in Python and JS, and why it costs nothing on IonQ hardware.
The S gate multiplies the amplitude by , a quarter turn of phase, and leaves alone. It acts on one qubit and takes no parameters. The Circuit panel draws it as S. On its own it changes nothing a measurement can see; 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.s(qubit) |
| JS | circuit.s(qubit) |
| Qiskit class | SGate |
Matrix
On the Bloch sphere this is a quarter-turn about the Z axis. S is the square root of Z: two S gates make one Z. It is the special case p(π/2) of the P gate, and two T gates make one S.
Effect on basis states
| Input | Output |
|---|---|
A measurement straight after S shows no change on or . The phase shows once the qubit is in superposition.
Inverse
The inverse of S is Sdg, sdg(qubit). S is not its own inverse: two S gates make a Z, not an identity.
Usage
from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.s(0)
qc.s(0)
qc.h(0)
qc.measure(0, 0)
import { QuantumCircuit } from 'qiskit';
const circuit = QuantumCircuit(1, 1);
circuit.h(0);
circuit.s(0);
circuit.s(0);
circuit.h(0);
circuit.measure(0, 0);
Every shot reads 1: the two S gates make a Z, and H Z H is an X.
On IonQ hardware
S is a virtual Z. The compiler folds the quarter-turn into the phase of the next pulse, so S costs no gate and no time on the machine. 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