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 1\vert 1 \rangle amplitude by ii, a quarter turn of phase, and leaves 0\vert 0 \rangle 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 0\vert 0 \rangle name the basis states and rotations are described on the Bloch sphere; the qubits lesson introduces both.

Call

WhereCall
Pythonqc.s(qubit)
JScircuit.s(qubit)
Qiskit classSGate

Matrix

S=(100i)S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}

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

InputOutput
0\vert 0 \rangle0\vert 0 \rangle
1\vert 1 \ranglei1i\vert 1 \rangle
+\vert + \rangle12(0+i1)\tfrac{1}{\sqrt{2}}(\vert 0 \rangle + i\vert 1 \rangle)

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

Stay in the loop.

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