Skip to content

ItamarIliuk/quantum-hello-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚛ Quantum Hello World

The first step into the quantum universe — now in your terminal and browser

Python TypeScript Qiskit Node.js License: MIT


"The universe is not only stranger than we suppose,
but stranger than we can suppose."
— J.B.S. Haldane


Quantum Hello World Demo


🌌 What is this?

This project implements a fully functional quantum circuit simulator that runs a real Bell State — the quantum computing equivalent of "Hello, World!" — using IBM's Qiskit as the quantum backend and TypeScript as the orchestration layer.

Unlike classical computing where a bit is either 0 or 1, this program creates 2 entangled qubits that exist in superposition until measured. The result is always either |00⟩ or |11⟩ — never |01⟩ or |10⟩ — a direct demonstration of quantum entanglement.

This is not a toy simulation. This is the exact same mathematics that runs on IBM Quantum's real hardware.


✨ Features

Feature Description
🔬 Real Quantum Circuit Bell State Φ⁺ built with Hadamard + CNOT gates
📊 Statistical Analysis 1024-shot measurement with probability histogram
🖥️ Terminal Interface Full-color ASCII output with circuit diagram
🌐 Browser Preview Beautiful dark-mode web dashboard
♻️ Live Re-simulation Click a button to re-run the quantum circuit
🔗 TypeScript ↔ Python Clean inter-process bridge architecture
Zero Config Auto-installs Qiskit if not present

🧠 The Physics Behind It

     ┌───┐     ┌─┐
q_0: ┤ H ├──■──┤M├
     └───┘┌─┴─┐└╥┘
q_1: ─────┤ X ├─╫─
          └───┘ ║
c:  ════════════╩══

Step by step:

1. Initial state — Both qubits start at |0⟩:

|Ψ⟩ = |00⟩

2. Hadamard gate (H) — Qubit 0 enters superposition:

|Ψ⟩ = (1/√2)|0⟩ ⊗ |0⟩ + (1/√2)|1⟩ ⊗ |0⟩
    = (1/√2)(|00⟩ + |10⟩)

3. CNOT gate (CX) — Qubit 1 flips when qubit 0 is |1⟩:

|Ψ⟩ = (1/√2)|00⟩ + (1/√2)|11⟩  ← Bell State Φ⁺

4. Measurement — The wave function collapses:

  • |00⟩ with probability 50%
  • |11⟩ with probability 50%
  • |01⟩ and |10⟩impossible

This impossibility of opposite outcomes across 1024 trials is proof of entanglement.


🚀 Getting Started

Prerequisites

Installation

# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/quantum-hello-world.git
cd quantum-hello-world

# 2. Install Python dependencies (Qiskit)
pip install qiskit qiskit-aer

# 3. Install Node.js dependencies
npm install

# 4. Compile TypeScript
npx tsc

Running

🖥️ Terminal mode (colored ASCII output)

node dist/main.js

🌐 Browser mode (web dashboard)

node server.js
# Open http://localhost:3741

Tip: The TypeScript runtime auto-installs Qiskit if it's missing on your machine.


📁 Project Structure

quantum-hello-world/
│
├── quantum_circuit.py   # 🐍 Qiskit quantum circuit (Python backend)
├── main.ts              # 🔷 Terminal orchestrator (TypeScript)
├── server.js            # 🌐 Web dashboard server (Node.js)
├── tsconfig.json        # TypeScript compiler config
├── package.json         # Node.js dependencies
│
├── dist/                # Compiled TypeScript output
│   └── main.js
│
└── docs/
    └── assets/
        └── preview.png  # Preview screenshot

🔧 Architecture

┌────────────────────────────────────────────┐
│          TypeScript Orchestrator           │
│  (main.ts / server.js)                     │
│                                            │
│  • Checks Qiskit availability              │
│  • Spawns Python subprocess                │
│  • Parses JSON result                      │
│  • Renders terminal / HTML output          │
└─────────────────┬──────────────────────────┘
                  │ stdin/stdout (JSON)
                  ▼
┌────────────────────────────────────────────┐
│           Python / Qiskit Backend          │
│  (quantum_circuit.py)                      │
│                                            │
│  • Builds QuantumCircuit(2, 2)             │
│  • Applies H + CX gates                   │
│  • Simulates with AerSimulator             │
│  • Returns counts + circuit diagram        │
└────────────────────────────────────────────┘

📊 Sample Output

╔══════════════════════════════════════════════════════════╗
║        ⚛  SIMULADOR QUANTICO — HELLO WORLD  ⚛          ║
║            TypeScript  +  Qiskit (Python)                ║
╚══════════════════════════════════════════════════════════╝

┌─ CIRCUITO QUANTICO ──────────────────────────────────────┐
│      ┌───┐     ┌─┐
│ q_0: ┤ H ├──■──┤M├───
│      └───┘┌─┴─┐└╥┘┌─┐
│ q_1: ─────┤ X ├─╫─┤M├
│           └───┘ ║ └╥┘
│ c: 2/═══════════╩══╩═
└──────────────────────────────────────────────────────────┘

┌─ HISTOGRAMA DE MEDICOES ─────────────────────────────────┐
│ |00⟩  ████████████████████████████████  514 shots (50.2%)
│ |11⟩  ████████████████████████████████  510 shots (49.8%)
└──────────────────────────────────────────────────────────┘

🌍 Why Does This Matter?

Quantum computing is not just a faster computer — it's a fundamentally different way of processing information. While a classical computer with n bits can represent one of 2ⁿ states at a time, a quantum computer with n qubits can represent all 2ⁿ states simultaneously.

This Bell State program is the "Hello World" of this new computing paradigm because it demonstrates the two properties that make quantum computers powerful:

  • Superposition — A qubit can be 0 AND 1 at the same time
  • Entanglement — Two qubits can be correlated across any distance, instantly

Applications currently being developed with these principles:

  • 🔐 Quantum Cryptography — Unbreakable encryption
  • 💊 Drug Discovery — Simulating molecular interactions
  • 🏦 Financial Optimization — Portfolio optimization at scale
  • 🤖 Quantum ML — Next-generation AI algorithms

🤝 Contributing

Contributions are welcome! Here are some ideas to extend this project:

  • Add more quantum gates (Toffoli, S, T, Rx, Ry, Rz)
  • Implement Grover's search algorithm
  • Add Bloch sphere visualization
  • Support running on real IBM Quantum hardware via API
  • Add quantum teleportation circuit demo
  • WebSocket-based live simulation updates

📚 Learning Resources


📄 License

MIT License — see LICENSE for details.


Built with ⚛ by Itamar Iliuk

If this project sparked your curiosity about quantum computing, give it a ⭐!

About

ÔÜø Quantum Hello World: Bell State simulator with TypeScript + Qiskit. Demonstrates superposition and entanglement.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors