# Can I initialize only one qubit in a 4-qubit circuit?

I wonder if there's a way we can initialize the quantum state only for part of the qubits in a quantum circuit. Say if I have a quantum circuit defined as qc = QuantumCircuit(4), can we only initialize the first qubit (qubit 0) to a particular quantum state, and leave other qubits unchanged (i.e. $$|0\rangle$$)?

I tried to follow a documentation on qiskit, but am still confused about how to do that. I tried to initialize all the qubits by generating a statevector from the tensor product of each qubit: qc.initialize(np.kron(...)), but it returns me LinAlgError: Last 2 dimensions of the array must be square. Is there an easier way I can do that by specifying which qubit I want to initialize? Thanks for the help!!

Adding to Frank's answer, you can also create an Instruction for the state vector initialization, using the Initialize class, which you can construct passing different arguments (vector, statevectors, etc.). You could then append this instruction to your circuit:

qc = QuantumCircuit(4)
init_gate = Initialize([0.8, 0.6])
qc.append(init_gate, [0])

     ┌─────────────────────┐
q_0: ┤ Initialize(0.8,0.6) ├
└─────────────────────┘
q_1: ───────────────────────
q_2: ───────────────────────
q_3: ───────────────────────


Simplest way is just to initialise one qubit using a 2D list:

from qiskit import QuantumCircuit

qubit_state = [0,1]
qc = QuantumCircuit(4)
# can use initialize only on the qubit 0
qc.initialize(qubit_state, 0)


Not sure what's causing your error, but this also works for me:

from qiskit import QuantumCircuit
import numpy as np

statevector = [0,1]
zero = [1,0]

# create entire 4-qubit state vector
for aux_qubit in range(3):
statevector = np.kron(statevector, zero)

qc = QuantumCircuit(4)
# apply to first 4 qubits
qc.initialize(statevector, [0,1,2,3])
qc.draw('text')

     ┌──────────────────────────────────────────────┐
q_0: ┤0                                             ├
│                                              │
q_1: ┤1                                             ├
│  Initialize(0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0) │
q_2: ┤2                                             ├
│                                              │
q_3: ┤3                                             ├
└──────────────────────────────────────────────┘


I recommend the first way as it scales better.