I'm getting started in IBM quantum lab for quantum computing. My task is to put quantum state $|0\rangle$ on the 1st qubit and state $|1\rangle$ on second one. I tried using this method to initialize it as:
qc.initialize(0,0)
qc.initialize(1,1)
but when I run in the unitary simulator, I get the following error:
Simulation failed and returned the following error message:
ERROR: Failed to load qobj: Invalid qobj "initialize" instruction ("params" is incorrect length).
I also tried using reset method but it displayed error as well
qc.reset(0)
qc.reset(1)
qc.x(1)
If anyone knows how to set state to a specific qubit in Qiskit it would be great, thanks in advance
The full code:
#Creating a quantum circuit with two qubits
qc=QuantumCircuit(2)
#Set the state of the first qubit to|0⟩ and set the state of the second qubit to|1⟩.
qc.initialize(0,0)
qc.initialize(0,0)
#or
#qc.reset(0)
#qc.reset(1)
#qc.x(1)
#Applying Hadamard to both qubits
qc.h(0)
qc.h(1)
#Applying CNOT operator, where the controller qubit is the first qubit and the target qubit is the second qubit
qc.cx(0,1)
#Applying Hadamard to both qubits
qc.h(0)
qc.h(1)
display(qc.draw())
usim = Aer.get_backend('unitary_simulator')
qobj = assemble(qc)
unitary = usim.run(qobj).result().get_unitary()
array_to_latex(unitary, pretext="\\text{Circuit = }\n")