Hot Posts

6/recent/ticker-posts

Introduction to Qiskit – Installation, Basic Terminology, and Your First Quantum Circuit -1



 


Introduction

Quantum computers are no longer just theoretical! Companies like IBM and Google have made real quantum devices accessible via the cloud, and you can connect to them using the Qiskit library. In this article, you’ll learn:

  1. How to install Qiskit,
  2. Basic quantum concepts (qubits, gates, circuits),
  3. How to build your first quantum circuit.


Step 1: Installing Qiskit

Python and Jupyter Notebook

Qiskit is a Python-based library. To get started:


Terminal Installation:

pip install qiskit                          # Core Qiskit package

pip install 'qiskit[visualization]'  # Visualization tools{codeBox}


Test the Installation:

import qiskit

print(qiskit.__version__)  # Output: 1.3.2 (latest version){codeBox}



 


Step 2: Basic Quantum Terms

Qubit (Quantum Bit)

  • Classical bits are 0 or 1. Qubits, however, can exist in superposition (a combination of 0 and 1).
  • Analogy: Like a spinning coin that represents both heads and tails simultaneously.

Quantum Gates

Operations applied to qubits. Examples:

  • Hadamard (H): Creates superposition (0 → 0+1).
  • CNOT: Entangles qubits (controls a target qubit based on another).

Quantum Circuit

  • A sequence of qubits and gates.


Step 3: Your First Quantum Circuit

Build a Simple Circuit:

from qiskit import QuantumCircuit

from qiskit.visualization import plot_histogram

# Create a 1-qubit circuit

circuit = QuantumCircuit(1, 1)  # 1 qubit, 1 classical bit

# Add a Hadamard gate

circuit.h(0)

# Measure qubit 0 → classical bit 0

circuit.measure(0, 0)

# Visualize the circuit

circuit.draw("mpl")  # Requires matplotlib{codeBox}

Output: A circuit diagram with a Hadamard gate applied to qubit 0.




Why This Works:

The Hadamard gate puts the qubit into a 50% probability state for 0 or 1. Measurement collapses it to a definite value.


Step 4: Run on a Simulator

from qiskit import Aer, transpile

simulator = Aer.get_backend('aer_simulator')

compiled_circuit = transpile(circuit, simulator)


# Run 10 shots

results = []

for _ in range(10):

    job = simulator.run(compiled_circuit, shots=1)

    counts = job.result().get_counts()

    results.append(counts)

    print(f"Result {_+1}: {counts}")


# Visualize aggregated results

aggregate_results = {}

for count in results:

    for key in count:

        aggregate_results[key] = aggregate_results.get(key, 0) + 1


plot_histogram(aggregate_results){codeBox}

Sample Output:


Sonuç 1: {'0': 1}
Sonuç 2: {'0': 1}
Sonuç 3: {'0': 1}
Sonuç 4: {'1': 1}
Sonuç 5: {'1': 1}
Sonuç 6: {'1': 1}
Sonuç 7: {'0': 1}
Sonuç 8: {'0': 1}
Sonuç 9: {'0': 1}
Sonuç 10: {'1': 1}




Analysis:

You’ll see roughly 50% 0s and 1s. Why? The Hadamard gate creates superposition, and measurement randomly collapses to 0 or 1.{alertInfo}


Resources:

  1. Qiskit Documentation
  2. IBM Quantum Lab (Free account).


What’s Next?

In the next article, "Quantum Gates and Basic Operations in Qiskit: From Hadamard to CNOT", we’ll cover:

  1. Pauli gates (X, Y, Z),
  2. Entanglement with CNOT,
  3. Multi-qubit circuits.


Ready to explore quantum computing? Start coding with Qiskit today!

Leave your questions in the comments below!{alertSuccess}

Post a Comment

1 Comments

Konuyla ilgili yorum giriniz.