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
