Poly-Z Gate

Qiskit Representation

This is the process of a one quibit circuit being built, having an Z-Gate and measurement applied, then ploting the results goes in code

In [12]:
import numpy as np
import qiskit as q
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, transpile, Aer, IBMQ
from qiskit.tools.jupyter import *
from qiskit.visualization import *
from ibm_quantum_widgets import *

# Loading your IBM Quantum account(s)
provider = IBMQ.load_account()
ibmqfactory.load_account:WARNING:2021-05-27 15:56:13,805: Credentials are already in use. The existing account in the session will be replaced.

Constructing the circuit

Makes the quantum circuit "foundation". The first parameter is the number of qubits (quantum bits) the second parameter is the number of cbits (classical bits), this lets us store the information to be read by the simulator

In [13]:
zGateExample = QuantumCircuit(1,1)

Adds an Poly-Z gate to the first qubit (represented by the number zero)

In [14]:
zGateExample.z(0)
Out[14]:
<qiskit.circuit.instructionset.InstructionSet at 0x7f2f1492cc40>

Adds an measurement operator to the first qubit and results stored in the first cbit

In [15]:
zGateExample.measure(0,0)
Out[15]:
<qiskit.circuit.instructionset.InstructionSet at 0x7f2f12839460>

Draws the circuit out for a visual representation

In [16]:
zGateExample.draw()
Out[16]:

Choosing the backend and gathering results

Choosing a backend from the avaible computers with my account. The QASM Simulator is a regular computer doing this as a simulation to give an idea of what probabilities of the outcomes are for the circuit

In [17]:
backend = Aer.get_backend("qasm_simulator")

Executes the circuit made (argument one [xGateExample]) on the backend (argument two [backend])

In [18]:
job = q.execute(zGateExample, backend)

Gathers the results from the execution done in the previous statement

In [19]:
results = job.result()

Gathers the counts of how many times 1 or 0 was the result

In [20]:
counts = results.get_counts()

Results

Plots the counts on a histogram shown below

In [21]:
plot_histogram(counts)
Out[21]:

The above shows that the first qubits value after measurement is 1 with 100% probability