I am new to qiskit and currently trying to implement Shor's 9-Qubit_Code. I am trying to orient my code on the example given in the official qiskit-tutorial and so far I have the following:
import matplotlib.pyplot as plt
import numpy as np
import math
from qiskit import *
circuit = QuantumCircuit(9)
circuit.cnot(0, 3)
circuit.cnot(0, 6)
circuit.h(0)
circuit.h(3)
circuit.h(6)
circuit.cnot(0, 1)
circuit.cnot(3, 4)
circuit.cnot(6, 7)
circuit.cnot(0, 2)
circuit.cnot(3, 5)
circuit.cnot(6, 8)
# Insert some error here
circuit.barrier()
circuit.x(0)
circuit.id(1)
circuit.id(2)
circuit.id(3)
circuit.id(4)
circuit.id(5)
circuit.id(6)
circuit.id(7)
circuit.id(8)
circuit.barrier()
circuit.cnot(0, 1)
circuit.cnot(3, 4)
circuit.cnot(6, 7)
circuit.cnot(0, 2)
circuit.cnot(3, 5)
circuit.cnot(6, 8)
circuit.ccx(2, 1, 0)
circuit.ccx(5, 4, 3)
circuit.ccx(8, 7, 6)
circuit.h(0)
circuit.h(3)
circuit.h(6)
circuit.cnot(0, 3)
circuit.cnot(0, 6)
circuit.ccx(8, 3, 0)
circuit.draw(output='mpl')
plt.show()
# Run the quantum circuit on a statevector simulator backend
backend = Aer.get_backend('statevector_simulator')
# Create a Quantum Program for execution
job = backend.run(circuit)
result = job.result()
outputstate = result.get_statevector(circuit, decimals=3)
print(outputstate)
However, I still need to be able to set the first qubit in an arbitrary state, but I do not know how to do this and I can not find something like that on the tutorials page. Could you please help me?
Remark: This is not supposed to be a "serious" program, it is just for me to get a feel of what is going on.
qiskit.circuit.Parameter
class to define a parametrised state preparation. $\endgroup$