惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
J
Java Code Geeks
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
U
Unit 42
B
Blog
宝玉的分享
宝玉的分享
腾讯CDC
Microsoft Azure Blog
Microsoft Azure Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
博客园 - Franky
博客园 - 三生石上(FineUI控件)
人人都是产品经理
人人都是产品经理
Martin Fowler
Martin Fowler
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
云风的 BLOG
云风的 BLOG
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
博客园 - 叶小钗

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Quantum computing basics in Python, without the hype
I Want To Learn Programming · 2026-06-17 · via DEV Community

I Want To Learn Programming

Quantum computing is buried under hype, but the basics are concrete: a qubit is a vector, a gate is a matrix, and you can simulate small quantum circuits in plain Python with NumPy. You do not need a quantum computer to understand how one works.

A qubit is a vector

A classical bit is 0 or 1. A qubit is a combination of both, written as a 2-element vector of amplitudes:

import numpy as np
zero = np.array([1, 0])   # |0>
one  = np.array([0, 1])   # |1>
# a superposition: equal parts |0> and |1>
plus = np.array([1, 1]) / np.sqrt(2)

The amplitudes are not probabilities directly; their squared magnitudes are. For plus, each squared amplitude is 1/2, so measuring gives 0 or 1 with equal chance. That is superposition: the qubit holds both possibilities until measured.

A gate is a matrix

Quantum gates are matrices that transform the qubit's vector. The Hadamard gate creates superposition; the X gate is a quantum NOT:

H = np.array([[1, 1], [1, -1]]) / np.sqrt(2)
X = np.array([[0, 1], [1, 0]])

H @ zero   # -> the plus state, superposition from |0>
X @ zero   # -> |1>, a bit flip

Applying a gate is just matrix-vector multiplication. A circuit is a sequence of these multiplications. That is the entire computational model, simulable with NumPy.

Measurement

Measurement collapses the superposition to a definite 0 or 1, with probability equal to the squared amplitude. Simulating it is sampling:

def measure(state):
    probs = np.abs(state) ** 2
    return np.random.choice(len(state), p=probs)

Run it many times on the plus state and you get roughly half 0s and half 1s. This is the part that feels strange: the outcome is genuinely probabilistic, and reading the qubit destroys the superposition.

Why it matters

With multiple qubits you get entanglement and a state space that grows exponentially (n qubits need 2^n amplitudes), which is the source of quantum computing's potential power for specific problems like search (Grover's algorithm) and factoring. Simulating small cases in Python is exactly how people build intuition before touching real hardware, and it shows you both the promise and the limits without the marketing.

Build it yourself

The physics with Python track covers quantum mechanics and simulation from scratch, building qubits, gates, measurement, and algorithms in NumPy, all graded in your browser. The first project is free.

Quantum computing is reachable. Simulate a few qubits and the ideas become concrete, hype removed.