The Pauli X-gate
Overview¶
The Pauli X-gate is a simple negation operation. It corresponds to a classical NOT gate.
Here is how it works:
|0> --> |1>
|1> --> |0>
Imports¶
In [6]:
import qiskit
from qiskit import QuantumCircuit, Aer, execute
from qiskit.extensions import Initialize
Build¶
Let's try first with |0> --> |1> example. By default qubit is initialized to |0>
In [2]:
qc = QuantumCircuit(1) # quantum circuit with one qubit
qc.x(0) # applying X-gate
backend = Aer.get_backend('statevector_simulator')
result = execute(qc,backend).result()
out_state = result.get_statevector()
print(out_state)
Now, let's see what will happen if we apply X-gate on |1> qubit
In [3]:
initialize_qubit = Initialize([0,1])
qc.append(initialize_qubit, [0])
Out[3]:
In [4]:
qc.x(0)
backend = Aer.get_backend('statevector_simulator')
result = execute(qc,backend).result()
out_state = result.get_statevector()
print(out_state)
Execute¶
Analyze¶
Notes¶
In [7]:
qiskit.__version__
Out[7]: