1
$\begingroup$

$ \def \ket#1{|#1\rangle} \def \bra#1{\langle#1|} $Is there a way to set qubits to be a specific value outside of resetting them like so? I understand that all qubits are initialized to the $\ket 0$ state, but is there a way to draw this explicitly outside of using the reset method? Also, can qubits be initialized to other states without using gate logic? It would be preferred if it read something like $t_0=\ket 0$ before the wire.

x = QuantumRegister(4, 't')
y = QuantumRegister(2, 'q')
c = QuantumCircuit(x, y)
init_circ.reset(x)
init_circ.h(x)

Initialize to |0>

$\endgroup$

2 Answers 2

1
$\begingroup$

Whether or not this is a stated goal, the capabilities of Qiskit parallel those of the IBM quantum computers. Since on the computers there is no way to initialize qubits to anything other than $|0\rangle$, Qiskit doesn't provide that ability either. Any program you can create in Qiskit should, theoretically run [mostly] unmodified on the real computer.

Other simulators can offer this capability since they don't mimic real-world devices.

$\endgroup$
2
$\begingroup$

Use the initial_state parameter in the QuantumCircuit.draw method:

x = QuantumRegister(4, 't')
y = QuantumRegister(2, 'q')
c = QuantumCircuit(x, y)
c.h(x)
c.draw(output="mpl", initial_state=True)

In order to initiate qubits to a state other than $|0\rangle$, gates must be applied, one way or another. I.e you can use the QuantumCircuit.initialize method to instantiate a qubit to an arbitrary state $|\psi\rangle$, for example. However, this method will apply the unitary evolution $U$ needed to eveolve $|0\rangle$ to $|\psi\rangle$.

$\endgroup$
3
  • $\begingroup$ Is it possible to show the initial states of x but not y? $\endgroup$ Nov 16, 2022 at 23:21
  • $\begingroup$ initial_state is a boolean argument. $\endgroup$ Nov 17, 2022 at 4:10
  • $\begingroup$ As to your first question, I have a slight preference for prepare_state() over initialize(). The only difference is that prepareState() doesn't first force the qubits to 0. Hence your code is always reversible, and you can use things like Statevector on it. $\endgroup$ Nov 17, 2022 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.