liveBook · Manning

Default quantum state

As explained in Building Quantum Software with Python

A default quantum state is the all-zero computational-basis state used as the initial state before quantum operations are applied.

A default quantum state initializes every qubit to 0 with certainty. For one qubit, the amplitude vector is [1, 0]: outcome 0 has probability 100%, while outcome 1 has probability 0. section 3.1.4

For n qubits, represent the state as a list of 2^n amplitudes. Set the first entry to 1 and every remaining entry to 0, producing [1, 0, 0, 0] for two qubits. section 4.2.3

A simulator can create the state with a small reusable initializer:

  • Allocate 2^n zero-valued entries. section 4.2.3
  • Assign amplitude 1 to index 0, corresponding to the all-zero computational-basis outcome. section 3.1.4 section 4.2.3
  • Apply gates or operators afterward to change the amplitudes and prepare other states. section 3.1.4

Python initialization

def init_state(n): state = [0 for _ in range(2 ** n)] state[0] = 1 return state state = init_state(2) print(state) # [1, 0, 0, 0] The same starting state supports later transformations. In magnitude amplification, the inversion operator preserves amplitude 0 and negates every other amplitude after transforming back to the default-state basis. section 4.2.3 section 6.1.5

Listing 4.2 Function to create a default quantum state
def init_state(n):
    state = [0 for _ in range(2 ** n)]   #1
    state[0] = 1    #2
    return state

Use the listing to inspect the complete n-qubit initializer; the related two-qubit output makes the vector layout concrete. section 4.2.3

How Building Quantum Software with Python covers it

How deep it goes
Defines one- and n-qubit list representations and uses them in an inversion procedure, while deferring physical state preparation.
Examples
Uses Python outputs [1, 0] and [1, 0, 0, 0], plus a three-qubit inversion example with a random operator.
What it assumes
Assumes basic Python lists and qubit notation while teaching the all-zero state and amplitude-vector layout directly.
What you can do after
Build it from scratch by initializing valid state vectors for single- and multi-qubit Python simulations.
How it connects
Connects computational-basis states, qubits, quantum gates, state preparation, oracles, and amplitude amplification.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Quantum Software with Python. The section links point to the parts of the book it draws on.