Skip to content

Commit

Permalink
Update introduction to Qiskit (Qiskit/qiskit-metapackage#1669)
Browse files Browse the repository at this point in the history
* Update introduction to Qiskit

* update docs

---------

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 2, 2023
1 parent 3e6a283 commit 078afd4
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions docs/intro_tutorial1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ subsequent sections:

.. jupyter-execute::

import numpy as np
from qiskit import QuantumCircuit, transpile
from qiskit.providers.aer import QasmSimulator
from qiskit_aer import AerSimulator
from qiskit.visualization import plot_histogram

# Use Aer's qasm_simulator
simulator = QasmSimulator()
# Use Aer's AerSimulator
simulator = AerSimulator()

# Create a Quantum Circuit acting on the q register
circuit = QuantumCircuit(2, 2)
Expand All @@ -37,21 +36,21 @@ subsequent sections:
circuit.cx(0, 1)

# Map the quantum measurement to the classical bits
circuit.measure([0,1], [0,1])
circuit.measure([0, 1], [0, 1])

# compile the circuit down to low-level QASM instructions
# supported by the backend (not needed for simple circuits)
# Compile the circuit for the support instruction set (basis_gates)
# and topology (coupling_map) of the backend
compiled_circuit = transpile(circuit, simulator)

# Execute the circuit on the qasm simulator
# Execute the circuit on the aer simulator
job = simulator.run(compiled_circuit, shots=1000)

# Grab results from the job
result = job.result()

# Returns counts
counts = result.get_counts(compiled_circuit)
print("\nTotal count for 00 and 11 are:",counts)
print("\nTotal count for 00 and 11 are:", counts)

# Draw the circuit
circuit.draw()
Expand Down Expand Up @@ -85,16 +84,15 @@ The basic elements needed for your program are imported as follows:

.. code-block:: python
import numpy as np
from qiskit import QuantumCircuit
from qiskit.providers.aer import QasmSimulator
from qiskit_aer import AerSimulator
from qiskit.visualization import plot_histogram
In more detail, the imports are

- ``QuantumCircuit``: can be thought as the instructions of the quantum system.
It holds all your quantum operations.
- ``QasmSimulator``: is the Aer high performance circuit simulator.
- ``AerSimulator``: is the Aer high performance circuit simulator.
- ``plot_histogram``: creates histograms.


Expand Down Expand Up @@ -130,7 +128,7 @@ Consider the following three lines of code:
circuit.h(0)
circuit.cx(0, 1)
circuit.measure([0,1], [0,1])
circuit.measure([0, 1], [0, 1])
The gates are added to the circuit one-by-one to form the Bell state

Expand Down Expand Up @@ -194,19 +192,18 @@ If you have issues installing Aer, you can alternatively use the Basic Aer
provider by replacing `Aer` with `BasicAer`. Basic Aer is included in Qiskit
Terra.

.. code-block:: text
.. code-block:: python
import numpy as np
from qiskit import QuantumCircuit, transpile
from qiskit.providers.basicaer import QasmSimulatorPy
...
To simulate this circuit, you will use the ``qasm_simulator``. Each run of this
To simulate this circuit, you will use the ``AerSimulator``. Each run of this
circuit will yield either the bit string 00 or 11.

.. jupyter-execute::

simulator = QasmSimulator()
simulator = AerSimulator()
compiled_circuit = transpile(circuit, simulator)
job = simulator.run(compiled_circuit, shots=1000)
result = job.result()
Expand Down

0 comments on commit 078afd4

Please sign in to comment.