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

推荐订阅源

A
About on SuperTechFans
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
I
InfoQ
C
Check Point Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
Last Week in AI
Last Week in AI
GbyAI
GbyAI
P
Proofpoint News Feed
量子位
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
B
Blog
T
The Blog of Author Tim Ferriss
H
Help Net Security
云风的 BLOG
云风的 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: The Walsh-Hadamard Matrix — Backbone o...
Malcolm Low · 2026-05-16 · via DEV Community

Malcolm Low

Originally published on malcolmlow.net

In the Grover's Algorithm — Inversion About the Mean walkthrough, the diffusion operator applies H⊗³ twice per iteration. Every single step is governed by a sign table called the Hadamard Reference. That table is not a lookup shortcut — it is the 8×8 Walsh-Hadamard Transform matrix written out in full. This post derives it from scratch: one qubit, then two, then all three, arriving at the complete matrix and the rule behind every sign in it.


1 · The Circuit: Three Qubits, Three Hadamard Gates

We initialise all three qubits in the ground state |0⟩ and route each through its own independent Hadamard gate. There are no two-qubit (entangling) gates — the circuit is entirely parallel.

Qubit Input Gate Output
q₀ |0⟩ H (1/√2)(|0⟩ + |1⟩)
q₁ |0⟩ H (1/√2)(|0⟩ + |1⟩)
q₂ |0⟩ H (1/√2)(|0⟩ + |1⟩)

All three outputs are identical because all three inputs are identical. The structure emerges when we take their tensor product.


2 · Single-Qubit Hadamard Action

Input H|input⟩ Short notation
|0⟩ (1/√2)(|0⟩ + |1⟩) |+⟩
|1⟩ (1/√2)(|0⟩ − |1⟩) |−⟩

In matrix form:

H = (1/√2) [ +1  +1 ]
            [ +1  -1 ]

Enter fullscreen mode Exit fullscreen mode

Key property: H is its own inverse — H² = I. Every element has magnitude 1/√2, so tensoring three copies multiplies the magnitudes to 1/√8 while the signs follow a precise bitwise pattern.


3 · Two-Qubit Tensor Product: q₀ ⊗ q₁

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

Enter fullscreen mode Exit fullscreen mode

All four two-qubit basis states appear with equal amplitude 1/2. Measurement probability per state: (1/2)² = 25%.


4 · Three-Qubit Tensor Product: q₀ ⊗ q₁ ⊗ q₂

|+⟩ ⊗ |+⟩ ⊗ |+⟩
= (1/√8)( |000⟩ + |001⟩ + |010⟩ + |011⟩
        + |100⟩ + |101⟩ + |110⟩ + |111⟩ )

Enter fullscreen mode Exit fullscreen mode

This is |ψinit⟩ — the uniform superposition over all 8 basis states that opens Grover's algorithm. Each state carries amplitude +1/√8 ≈ 0.3535 and measurement probability 1/8 = 12.5%.


5 · The 8×8 Walsh-Hadamard Sign Matrix

When H⊗³ is applied to an arbitrary basis state |j⟩:

H⊗³ |j⟩ = (1/√8) Σᵢ (−1)^popcount(i AND j) |i⟩

Enter fullscreen mode Exit fullscreen mode

The entry at row i, column j carries sign (−1)^popcount(i AND j) divided by √8.
+ = amplitude +1/√8 ≈ +0.3535 / = amplitude −1/√8 ≈ −0.3535

          |000⟩ |001⟩ |010⟩ |011⟩ |100⟩ |101⟩ |110⟩ |111⟩
          ─────────────────────────────────────────────────
H|000⟩ →    +     +     +     +     +     +     +     +
H|001⟩ →    +     −     +     −     +     −     +     −
H|010⟩ →    +     +     −     −     +     +     −     −
H|011⟩ →    +     −     −     +     +     −     −     +
H|100⟩ →    +     +     +     +     −     −     −     −
H|101⟩ →    +     −     +     −     −     +     −     +
H|110⟩ →    +     +     −     −     −     −     +     +
H|111⟩ →    +     −     −     +     −     +     +     −

Enter fullscreen mode Exit fullscreen mode

Each row shows how an input basis state |j⟩ distributes its amplitude across all 8 output states after H⊗³ is applied.


6 · Why the Sign is (−1)^popcount(i AND j)

Because H acts independently on each qubit, H⊗³ is the tensor product of three 2×2 matrices. The entry at row i, column j is the product of the three corresponding single-qubit entries:

H⊗³[i, j] = H[i₀, j₀] × H[i₁, j₁] × H[i₂, j₂]

Enter fullscreen mode Exit fullscreen mode

Each single-qubit factor equals +1 unless both the k-th bit of i and the k-th bit of j are 1, in which case it equals −1. Multiplying all three:

sign(i, j) = (−1)^(i₀j₀ + i₁j₁ + i₂j₂) = (−1)^popcount(i AND j)

Enter fullscreen mode Exit fullscreen mode

The rule in plain terms: bitwise AND the row index and the column index, count the 1-bits, check parity. Even count → positive. Odd count → negative.

Quick verification: row H|101⟩, column |011⟩

i (row) j (col) i AND j popcount Sign
101 (=5) 011 (=3) 001 1 (odd) − ✓

Matches the matrix in Section 5: row H|101⟩, column |011⟩ is indeed −.


7 · Connection to Grover's Diffusion Operator

This matrix is the Hadamard Reference used throughout the Grover's Algorithm walkthrough. The diffusion operator D = H⊗³ (2|0⟩⟨0| − I) H⊗³ works in three sub-steps, each directly using this matrix:

Sub-step Operation Effect
First H⊗³ Maps computational basis → Hadamard basis Each amplitude spreads across all 8 columns via the sign table
Phase flip 2|0⟩⟨0|−I Keeps |000⟩ unchanged, negates all other states
Second H⊗³ Maps back to computational basis Routes constructive interference into the target state

Without the sign structure of the Walsh-Hadamard matrix, neither the uniform superposition nor the diffusion step would work. The matrix is the silent engine behind Grover's quadratic speedup.


Quantum Series 2026 · Built with Qiskit 1.x