<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Malcolm Low</title>
    <description>The latest articles on DEV Community by Malcolm Low (@malcolmlow).</description>
    <link>https://dev.to/malcolmlow</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3894359%2F50ab9e6e-a918-40f1-b3b5-a7526195ffa6.jpg</url>
      <title>DEV Community: Malcolm Low</title>
      <link>https://dev.to/malcolmlow</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/malcolmlow"/>
    <language>en</language>
    <item>
      <title>Optimization Problems Explained: Traveling Salesman, Job Shop Scheduling, and the Knight's Tour</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Thu, 10 Sep 2026 11:56:38 +0000</pubDate>
      <link>https://dev.to/malcolmlow/optimization-problems-explained-traveling-salesman-job-shop-scheduling-and-the-knights-tour-5d4i</link>
      <guid>https://dev.to/malcolmlow/optimization-problems-explained-traveling-salesman-job-shop-scheduling-and-the-knights-tour-5d4i</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published on &lt;a href="https://malcolmlow.com/2026/08/04/optimization-problems-explained-traveling-salesman-job-shop-scheduling-and-the-knights-tour/" rel="noopener noreferrer"&gt;malcolmlow.com&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;a href="https://malcolmlow.com/2026/05/15/knights-tour-codex-cli/" rel="noopener noreferrer"&gt;Knight’s Tour walkthrough&lt;/a&gt; on this blog treats the problem as a coding exercise: implement Warnsdorff’s heuristic, watch a knight visit every square exactly once, move on. But the Knight’s Tour belongs to a much larger family — combinatorial optimization problems, where the challenge isn’t computing an answer, it’s searching an astronomically large space of candidate answers for a good one. The Traveling Salesman Problem and Job Shop Scheduling are the two most-cited members of that family, and putting all three side by side makes clear why certain techniques keep reappearing across logistics, manufacturing, and chessboard puzzles alike.&lt;/p&gt;




&lt;h2&gt;
  
  
  1 · What Makes a Problem “Combinatorial”
&lt;/h2&gt;

&lt;p&gt;A combinatorial optimization problem asks for the best arrangement, ordering, or assignment out of a finite but enormous set of possibilities. “Finite” is the misleading part — finite doesn’t mean small. The number of ways to order 20 cities is 20! (roughly 2.4 × 10&lt;sup&gt;18&lt;/sup&gt;), and it only grows from there. Checking every possibility, brute force, is correct but useless: even a supercomputer evaluating a trillion arrangements per second would need decades for a 25-city tour.&lt;/p&gt;

&lt;p&gt;This is the shared root of all three problems below. Each has a small, easily-stated rule for what counts as a valid solution, and a combinatorial explosion of candidates that satisfy the rule. The interesting work isn’t defining the problem — it’s finding a good answer without enumerating the haystack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A useful vocabulary distinction:&lt;/strong&gt; a problem is &lt;strong&gt;NP-complete&lt;/strong&gt; if it’s among the hardest problems whose solutions can at least be &lt;em&gt;verified&lt;/em&gt; quickly, and &lt;strong&gt;NP-hard&lt;/strong&gt; if it’s at least as hard as those, whether or not verification is fast. TSP’s decision version (“is there a tour under length L?”) is NP-complete; its optimization version (“find the shortest tour”) is NP-hard. Job Shop Scheduling is NP-hard. The Knight’s Tour is a special case that, unusually, isn’t — more on that in Section 4.&lt;/p&gt;

&lt;h2&gt;
  
  
  2 · The Traveling Salesman Problem
&lt;/h2&gt;

&lt;p&gt;Given a list of cities and the distances between each pair, find the shortest possible route that visits every city exactly once and returns to the start. First studied formally in the 1930s, TSP is the problem most people picture when they hear “NP-hard” — partly because it maps so cleanly onto real logistics: delivery routing, PCB drilling paths, DNA sequencing fragment assembly, even warehouse pick-path optimization all reduce to some variant of TSP.&lt;/p&gt;

&lt;p&gt;The number of distinct tours for &lt;em&gt;n&lt;/em&gt; cities is (&lt;em&gt;n&lt;/em&gt;−1)!⁄2 — for just 15 cities, that’s over 43 billion routes. Exact solvers exist (branch-and-bound, cutting planes, integer linear programming) and can handle surprisingly large instances — the Concorde TSP solver has certified optimal tours for problems with tens of thousands of cities — but they can take unbounded time in the worst case. In practice, most applications use heuristics instead:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Heuristic&lt;/th&gt;
&lt;th&gt;Idea&lt;/th&gt;
&lt;th&gt;Typical gap from optimal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Nearest neighbor&lt;/td&gt;
&lt;td&gt;Always jump to the closest unvisited city&lt;/td&gt;
&lt;td&gt;~25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2-opt local search&lt;/td&gt;
&lt;td&gt;Repeatedly uncross pairs of edges that improve total length&lt;/td&gt;
&lt;td&gt;~5%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For a full worked treatment of nearest neighbor, 2-opt, 3-opt and tabu search — including pseudocode, complexity, and how the four methods fit into a single practical pipeline — see &lt;a href="https://malcolmlow.com/2026/08/25/solving-the-traveling-salesman-problem-nearest-neighbor-2-opt-3-opt-and-tabu-search/" rel="noopener noreferrer"&gt;Solving the Traveling Salesman Problem: Nearest Neighbor, 2-Opt, 3-Opt and Tabu Search&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Beyond hand-designed heuristics, a large body of research applies metaheuristics — genetic algorithms, ant colony optimization, bee colony optimization — to push closer to optimal on large instances. One example: &lt;a href="https://www.inderscience.com/info/inarticle.php?artid=108591" rel="noopener noreferrer"&gt;Choong, Wong, Low &amp;amp; Chong, “A Bee Colony Optimization Algorithm with a Sequential-Pattern-Mining-based Pruning Strategy for the Traveling Salesman Problem,” &lt;em&gt;International Journal of Bio-Inspired Computation&lt;/em&gt;, 15(4), 239–253 (2020)&lt;/a&gt;, which uses sequential pattern mining to prune the search space a bee colony algorithm explores, improving both solution quality and runtime over earlier bee colony variants on standard TSP benchmarks. Section 7 below lists the full line of TSP research this paper builds on.&lt;/p&gt;

&lt;p&gt;Most of the field trades a provable worst-case guarantee away for speed, accepting “probably close to optimal, verified empirically on benchmark instances” instead — which is exactly the trade-off metaheuristic approaches like the one above are built around.&lt;/p&gt;

&lt;h2&gt;
  
  
  3 · Job Shop Scheduling
&lt;/h2&gt;

&lt;p&gt;A set of jobs, each made of an ordered sequence of operations, must run on a shared set of machines. Each machine can only process one operation at a time, and each job’s operations must run in their specified order. The goal is usually to minimize &lt;strong&gt;makespan&lt;/strong&gt; — the total time until every job finishes. This is the workhorse problem behind semiconductor fab scheduling, shipyard and manufacturing floor planning, and container terminal crane assignment — anywhere shared, expensive resources have to be sequenced across competing demands.&lt;/p&gt;

&lt;p&gt;Even the deceptively small “3 jobs × 3 machines” instance can take meaningful compute time to solve exactly, and general Job Shop Scheduling is NP-hard — confirmed by Garey, Johnson, and Sethi in 1976. The search space is every valid interleaving of operations across machines respecting precedence constraints, which grows combinatorially with both job count and machine count simultaneously, faster than TSP’s single-dimension city count.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common approaches:&lt;/strong&gt; dispatching rules (simple greedy priorities like “shortest processing time first” or “earliest due date first”), genetic algorithms (evolve a population of candidate schedules via mutation and crossover), simulated annealing (accept occasional worse moves to escape local optima), and constraint programming solvers for smaller, high-stakes instances where near-optimality genuinely matters. Neural network approaches are also an active research direction: &lt;a href="https://ieeexplore.ieee.org/document/9309776" rel="noopener noreferrer"&gt;Sim, Low, Chong &amp;amp; Shakeri, “Job Shop Scheduling Problem Neural Network Solver with Dispatching Rules,” &lt;em&gt;IEEM 2020&lt;/em&gt;, 14–17 December 2020, Singapore&lt;/a&gt;, trains a neural network to select which dispatching rule to apply at each decision point, rather than committing to a single fixed rule for the whole schedule. Section 7 lists the earlier bee-colony-based JSSP work this line of research follows from.&lt;/p&gt;

&lt;p&gt;Unlike TSP, there’s no single dominant heuristic with a well-known worst-case bound — the field leans heavily on metaheuristics, learned dispatching policies, and problem-specific rules tuned empirically to the shop floor in question.&lt;/p&gt;

&lt;h2&gt;
  
  
  4 · The Knight’s Tour — the Odd One Out
&lt;/h2&gt;

&lt;p&gt;A knight on a chessboard must visit every square exactly once using only legal knight moves. As covered in the &lt;a href="https://malcolmlow.com/2026/05/15/knights-tour-codex-cli/" rel="noopener noreferrer"&gt;Codex CLI walkthrough&lt;/a&gt;, this is a special case of the &lt;strong&gt;Hamiltonian path problem&lt;/strong&gt;: model each square as a graph node, connect two nodes if a knight can move between them in one hop, and a Knight’s Tour is exactly a Hamiltonian path through that graph.&lt;/p&gt;

&lt;p&gt;Finding a Hamiltonian path in an &lt;em&gt;arbitrary&lt;/em&gt; graph is NP-complete — it belongs in the same hardness class as TSP’s decision version. But the knight’s-move graph on a chessboard isn’t arbitrary; it has enough regular structure that a simple greedy rule, &lt;strong&gt;Warnsdorff’s rule&lt;/strong&gt; (always move to the unvisited square with the fewest onward moves), finds a complete tour almost every time on boards 5×5 and larger, in linear time, with no backtracking needed in the overwhelming majority of cases.&lt;/p&gt;

&lt;p&gt;The general Hamiltonian-circuit problem — not restricted to a knight’s-move graph — is itself a live research target for the same metaheuristic techniques used on TSP: &lt;a href="https://ieeexplore.ieee.org/document/6046872" rel="noopener noreferrer"&gt;Wong, Low &amp;amp; Chong, “Finding the Shortest Hamiltonian Circuit of Selected Places in Penang Using a Generic Bee Colony Optimization Framework,” &lt;em&gt;BIC-TA 2011&lt;/em&gt;, 51–57&lt;/a&gt; applies a bee colony framework to find the shortest Hamiltonian circuit connecting real-world locations — the same underlying graph-theory object the Knight’s Tour is a highly structured special case of.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; the Knight’s Tour is a working example of a problem that sits inside an NP-complete family in general, yet becomes tractable once you exploit the specific structure of the instance. It’s a reminder that “NP-hard in general” doesn’t mean “hard for every input” — structured sub-cases can be much friendlier than the worst case the complexity class describes.&lt;/p&gt;

&lt;h2&gt;
  
  
  5 · What the Three Have in Common
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;Complexity&lt;/th&gt;
&lt;th&gt;Dominant heuristic&lt;/th&gt;
&lt;th&gt;Real-world domain&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TSP&lt;/td&gt;
&lt;td&gt;NP-hard&lt;/td&gt;
&lt;td&gt;Nearest neighbor, 2-opt&lt;/td&gt;
&lt;td&gt;Logistics, routing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Job Shop Scheduling&lt;/td&gt;
&lt;td&gt;NP-hard&lt;/td&gt;
&lt;td&gt;Dispatching rules, genetic algorithms&lt;/td&gt;
&lt;td&gt;Manufacturing, semiconductor fabs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Knight’s Tour&lt;/td&gt;
&lt;td&gt;Tractable special case of Hamiltonian path (NP-complete in general)&lt;/td&gt;
&lt;td&gt;Warnsdorff’s rule&lt;/td&gt;
&lt;td&gt;Puzzle design, graph theory pedagogy&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The pattern across all three: a &lt;strong&gt;greedy, locally-informed rule&lt;/strong&gt; — go to the nearest city, dispatch the shortest job first, move to the most-constrained square — gets surprisingly close to optimal, surprisingly fast, with no guarantee it always will. Exact methods (branch-and-bound, ILP, constraint solvers) remain necessary when the application genuinely needs a certified optimum or a worst-case bound, but for most production systems, a well-tuned greedy heuristic plus local-search refinement is the pragmatic default.&lt;/p&gt;

&lt;h2&gt;
  
  
  6 · When to Reach for Which Tool
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Small instance, need the true optimum:&lt;/strong&gt; exact solvers — branch-and-bound, integer linear programming, or off-the-shelf constraint solvers (OR-Tools, Gurobi, CPLEX).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Large instance, “good enough” is genuinely good enough:&lt;/strong&gt; a simple greedy heuristic, ideally with a known worst-case bound if one exists for the problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Large instance, need better than greedy but exact is too slow:&lt;/strong&gt; metaheuristics — simulated annealing, genetic algorithms, tabu search — layered on top of a greedy starting solution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your instance has exploitable structure&lt;/strong&gt; (like the knight’s-move graph’s regularity): look for a problem-specific rule before reaching for general-purpose machinery. The cheapest algorithm is the one that exploits structure the general theory doesn’t assume.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7 · Related Publications from the Author
&lt;/h2&gt;

&lt;p&gt;The full line of the author’s own published research on TSP and Job Shop Scheduling, drawn from the &lt;a href="https://malcolmlow.com/research-2/" rel="noopener noreferrer"&gt;Publications page&lt;/a&gt;, spans nearly two decades of bee-colony and neural-network approaches to both problems:&lt;/p&gt;

&lt;p&gt;Traveling Salesman Problem&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Wong, L.P., Low, M.Y.H., Chong, C.S. (2008). “A Bee Colony Optimization Algorithm for Traveling Salesman Problem.” &lt;em&gt;2nd Asia Modelling Symposium (AMS 2008)&lt;/em&gt;, 818–823, Kuala Lumpur, Malaysia.&lt;/li&gt;
&lt;li&gt;Wong, L.P., Low, M.Y.H., Chong, C.S. (2008). “Bee Colony Optimization with Local Search for Traveling Salesman Problem.” &lt;em&gt;6th IEEE International Conference on Industrial Informatics (INDIN08)&lt;/em&gt;, 1019–1025, Daejeon, Korea.&lt;/li&gt;
&lt;li&gt;Wong, L.P., Low, M.Y.H., Chong, C.S. (2009). “A Bee Colony Optimization Algorithm with the Fragmentation State Transition Rule for Traveling Salesman Problem.” &lt;em&gt;4th Virtual International Conference on Intelligent Production Machines and Systems (IPROMS)&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Wong, L.P., Low, M.Y.H., Chong, C.S. (2009). &lt;a href="https://ieeexplore.ieee.org/document/5195901" rel="noopener noreferrer"&gt;“An Efficient Bee Colony Optimization Algorithm for Traveling Salesman Problem using Frequency-based Pruning.”&lt;/a&gt; &lt;em&gt;7th IEEE International Conference on Industrial Informatics (INDIN09)&lt;/em&gt;, 775–782, Cardiff, UK.&lt;/li&gt;
&lt;li&gt;Wong, L.P., Low, M.Y.H., Chong, C.S. (2010). &lt;a href="https://www.worldscientific.com/doi/abs/10.1142/S0218213010000200" rel="noopener noreferrer"&gt;“Bee Colony Optimization with Local Search for Traveling Salesman Problem.”&lt;/a&gt; &lt;em&gt;International Journal on Artificial Intelligence Tools&lt;/em&gt;, 19(3), 305–334.&lt;/li&gt;
&lt;li&gt;Wong, L.P., Low, M.Y.H., Chong, C.S. (2011). &lt;a href="https://ieeexplore.ieee.org/document/6046872" rel="noopener noreferrer"&gt;“Finding the Shortest Hamiltonian Circuit of Selected Places in Penang Using a Generic Bee Colony Optimization Framework.”&lt;/a&gt; &lt;em&gt;International Conference on Bio-Inspired Computing: Theories and Applications (BIC-TA 2011)&lt;/em&gt;, 51–57, Penang, Malaysia.&lt;/li&gt;
&lt;li&gt;Choong, S.S., Wong, L.P., Low, M.Y.H., Chong, C.S. (2020). &lt;a href="https://www.inderscience.com/info/inarticle.php?artid=108591" rel="noopener noreferrer"&gt;“A Bee Colony Optimization Algorithm with a Sequential-Pattern-Mining-based Pruning Strategy for the Traveling Salesman Problem.”&lt;/a&gt; &lt;em&gt;International Journal of Bio-Inspired Computation&lt;/em&gt;, 15(4), 239–253.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Job Shop Scheduling&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chong, C.S., Low, M.Y.H., Sivakumar, A.I., Gay, K.L. (2006). “A Bee Colony Optimization Algorithm to Job Shop Scheduling.” &lt;em&gt;2006 Winter Simulation Conference&lt;/em&gt;, 1954–1961, Monterey, CA.&lt;/li&gt;
&lt;li&gt;Chong, C.S., Low, M.Y.H., Sivakumar, A.I., Gay, K.L. (2007). “Using a Bee Colony Algorithm for Neighbourhood Search in Job Shop Scheduling Problems.” &lt;em&gt;2007 European Conference on Modelling and Simulation&lt;/em&gt;, 459–465, Prague, Czech Republic.&lt;/li&gt;
&lt;li&gt;Wong, L.P., Puan, C.Y., Low, M.Y.H., Chong, C.S. (2008). “Bee Colony Optimization Algorithm with Big Valley Landscape Exploitation for Job Shop Scheduling Problems.” &lt;em&gt;2008 Winter Simulation Conference&lt;/em&gt;, 2050–2058, Miami, FL.&lt;/li&gt;
&lt;li&gt;Wong, L.P., Puan, C.Y., Low, M.Y.H., Chong, C.S., Wong, Y.W. (2010). &lt;a href="https://www.inderscience.com/info/inarticle.php?artid=32125" rel="noopener noreferrer"&gt;“Bee Colony Optimisation Algorithm with Big Valley Landscape Exploitation for Job Shop Scheduling Problems.”&lt;/a&gt; &lt;em&gt;International Journal of Bio-Inspired Computing&lt;/em&gt;, 2(2), 85–99.&lt;/li&gt;
&lt;li&gt;Sim, M.H., Low, M.Y.H., Chong, C.S., Shakeri, M. (2020). &lt;a href="https://ieeexplore.ieee.org/document/9309776" rel="noopener noreferrer"&gt;“Job Shop Scheduling Problem Neural Network Solver with Dispatching Rules.”&lt;/a&gt; &lt;em&gt;2020 International Conference on Industrial Engineering and Engineering Management (IEEM2020)&lt;/em&gt;, Singapore.&lt;/li&gt;
&lt;li&gt;Yang, Z., Liu, F., Zhang, W., Lou, X., Low, M.Y.H., Gan, B.P. (2026). &lt;a href="https://arxiv.org/abs/2512.06351" rel="noopener noreferrer"&gt;“LLM-Upgraded Graph Reinforcement Learning for Carbon-Aware Job Scheduling in Smart Manufacturing.”&lt;/a&gt; &lt;em&gt;41st ACM/SIGAPP Symposium On Applied Computing&lt;/em&gt;, 831–838, Thessaloniki, Greece.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Full author bibliography, including book chapters and the remaining 130+ conference and journal papers spanning simulation, crowd modeling, and manufacturing systems, is available on the &lt;a href="https://malcolmlow.com/research-2/" rel="noopener noreferrer"&gt;Publications page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;None of these three problems has been “solved” in the sense of a fast, exact, general algorithm — and for TSP and Job Shop Scheduling, complexity theory says no such algorithm exists unless P = NP. What they share instead is a body of heuristics, decades deep, that trade a small, usually-acceptable gap from optimal for a massive reduction in compute time. The Knight’s Tour is the outlier that got lucky: enough structure in its specific graph that a two-line greedy rule does the job outright.&lt;/p&gt;




&lt;p&gt;Combinatorial Optimization · 2026&lt;/p&gt;

&lt;p&gt;✦ This article was assembled with the assistance of &lt;a href="https://claude.ai" rel="noopener noreferrer"&gt;Claude by Anthropic&lt;/a&gt; ✦&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>programming</category>
      <category>computerscience</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Connect Codex to WordPress.com and Post from Termux on Android</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Thu, 10 Sep 2026 11:49:38 +0000</pubDate>
      <link>https://dev.to/malcolmlow/how-to-connect-codex-to-wordpresscom-and-post-from-termux-on-android-mld</link>
      <guid>https://dev.to/malcolmlow/how-to-connect-codex-to-wordpresscom-and-post-from-termux-on-android-mld</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published on &lt;a href="https://malcolmlow.com/2026/07/27/how-to-connect-codex-to-wordpress-com-and-post-from-termux-on-android/" rel="noopener noreferrer"&gt;malcolmlow.com&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can run Codex from an Android terminal and connect it to WordPress.com through the Model Context Protocol (MCP). This guide documents not only the successful setup, but also the connection failures encountered along the way: an incorrect endpoint that returned HTTP 404, an OAuth callback that depended on Termux remaining open, credentials that did not persist into a fresh process, and WordPress sites whose plans or connection states limited the available tools.&lt;/p&gt;

&lt;p&gt;The example device is a Samsung Galaxy S26 Ultra, although the workflow applies to other Android phones capable of running a maintained Termux build. The important parts are the Codex CLI, the exact MCP endpoint, a working OAuth credential store, and a deliberate draft-first publishing workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Claude instead?&lt;/strong&gt; See &lt;a href="https://malcolmlow.com/2026/05/26/publishing-to-wordpress-with-claude-and-the-wordpress-mcp-connector/" rel="noopener noreferrer"&gt;Publishing to WordPress with Claude and the WordPress MCP Connector&lt;/a&gt; for the corresponding browser-based Claude workflow, WordPress HTML constraints, and reusable-skill approach.&lt;/p&gt;




&lt;h2&gt;
  
  
  1 · What You Need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An Android phone with Termux installed from a trusted source such as F-Droid or the official Termux GitHub releases.&lt;/li&gt;
&lt;li&gt;Node.js, npm, and Git in Termux.&lt;/li&gt;
&lt;li&gt;An OpenAI account and the Codex CLI.&lt;/li&gt;
&lt;li&gt;A WordPress.com account with permission to edit the target site.&lt;/li&gt;
&lt;li&gt;A WordPress.com site whose plan and MCP settings permit the content tools you need.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Avoid an obsolete Termux package from an unofficial source. MCP availability is also site-specific: one account can contain a usable paid WordPress.com site, a site requiring a plan upgrade, and disconnected Jetpack sites at the same time.&lt;/p&gt;

&lt;h2&gt;
  
  
  2 · Install Codex in Termux
&lt;/h2&gt;

&lt;p&gt;Update Termux and install the prerequisites:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pkg update
pkg upgrade
pkg install nodejs git

node --version
npm --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install and verify Codex, then start it and complete the sign-in flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g @openai/codex
codex --version
codex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Android may open authorization in the default browser. Return to Termux when the browser step completes.&lt;/p&gt;

&lt;h2&gt;
  
  
  3 · Add the Exact WordPress.com MCP Endpoint
&lt;/h2&gt;

&lt;p&gt;Enable the WordPress.com MCP tools for your account, granting only the capabilities you need. Then register the remote Streamable HTTP server in Termux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;codex mcp add wpcom-mcp --url https://public-api.wordpress.com/wpcom/v2/mcp/v1
codex mcp get wpcom-mcp
codex mcp list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact path matters. The working endpoint used in this session was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://public-api.wordpress.com/wpcom/v2/mcp/v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The saved configuration should be enabled, use a Streamable HTTP transport, and contain the complete &lt;code&gt;/wpcom/v2/mcp/v1&lt;/code&gt; path. Codex stores MCP configuration in &lt;code&gt;~/.codex/config.toml&lt;/code&gt; by default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔐 Keep Termux running during OAuth, and never paste an access token into a prompt.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start authentication with &lt;code&gt;codex mcp login wpcom-mcp&lt;/code&gt;. The browser redirects to a temporary callback on &lt;code&gt;127.0.0.1&lt;/code&gt;, so the Codex process in Termux must remain alive to receive it.&lt;/p&gt;

&lt;p&gt;After approval, start a fresh Codex session and verify the server again. Treat &lt;code&gt;~/.codex&lt;/code&gt; as private configuration and never commit it to a public repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  4 · Problems Encountered and How to Debug Them
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;HTTP 404 during MCP initialization.&lt;/strong&gt; The first failure looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MCP startup failed
unexpected server response: HTTP 404
when send initialize request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The configured URL was an incomplete WordPress.com API path, not an MCP endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://public-api.wordpress.com/wpcom/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inspect the registration with &lt;code&gt;codex mcp get wpcom-mcp&lt;/code&gt;. If it is wrong, replace it cleanly and authenticate again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;codex mcp remove wpcom-mcp
codex mcp add wpcom-mcp --url https://public-api.wordpress.com/wpcom/v2/mcp/v1
codex mcp login wpcom-mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Browser approval succeeded, but the next session was unauthenticated.&lt;/strong&gt; Symptoms included &lt;code&gt;AuthRequired&lt;/code&gt; at startup, &lt;code&gt;Auth: Unsupported&lt;/code&gt; in the MCP list, or a success message followed by failure in a fresh Codex process. That is a credential-persistence problem, not an endpoint problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Android Termux could not reliably store the OAuth token.&lt;/strong&gt; In this session, the browser-based WordPress authorization completed successfully, but the Android Termux environment could not reliably save the OAuth token in a form that a later Codex process could retrieve. The clearest symptom was &lt;code&gt;try_lock() not supported&lt;/code&gt; when Codex attempted to use its file-backed credential store. As a result, a fresh session could return &lt;code&gt;AuthRequired&lt;/code&gt; even though the browser had just reported a successful login. This was a local credential-storage limitation, not a WordPress password problem and not an MCP endpoint problem.&lt;/p&gt;

&lt;p&gt;Update Codex and retry because this behavior may improve in newer builds. If it remains, do not work around it by copying OAuth tokens into prompts, shell history, or ordinary files. Use a supported desktop Codex environment for the authenticated WordPress action while continuing to research and draft in Termux.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The server is configured but no tools appear.&lt;/strong&gt; Start a fresh Codex process after configuration, run &lt;code&gt;codex mcp list&lt;/code&gt;, and use &lt;code&gt;/mcp&lt;/code&gt; inside the Codex terminal UI to inspect active servers. Run &lt;code&gt;codex mcp --help&lt;/code&gt; when the installed CLI syntax is uncertain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The account connects, but a particular site cannot be managed.&lt;/strong&gt; Enumerate the sites first. In this session, the same account returned a usable WordPress.com site with partial MCP support, another site requiring a paid plan, and several disconnected Jetpack sites. Authentication alone does not guarantee that every site exposes tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  5 · Ask Codex to Consult Official OpenAI Documentation
&lt;/h2&gt;

&lt;p&gt;When CLI behavior may have changed, prompt Codex to consult the current official documentation instead of relying only on model memory. Name the source, the error, the evidence you want inspected, and the boundary that no configuration should be changed without approval.&lt;/p&gt;

&lt;p&gt;The official references for this workflow are the &lt;a href="https://developers.openai.com/codex/codex-manual.md" rel="noopener noreferrer"&gt;Codex manual&lt;/a&gt; and its &lt;a href="https://learn.chatgpt.com/docs/extend/mcp" rel="noopener noreferrer"&gt;MCP configuration documentation&lt;/a&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Goal&lt;/th&gt;
&lt;th&gt;Example Prompt&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Verify setup&lt;/td&gt;
&lt;td&gt;“Use current official OpenAI Codex documentation to verify how a Streamable HTTP MCP server and OAuth login should be configured. Cite the exact OpenAI pages you used. Then inspect my &lt;code&gt;wpcom-mcp&lt;/code&gt; registration without changing it.”&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debug 404&lt;/td&gt;
&lt;td&gt;“Debug this Codex MCP initialization error: HTTP 404. First inspect &lt;code&gt;codex mcp get wpcom-mcp&lt;/code&gt;; compare the transport and URL with current official OpenAI MCP documentation and the service’s official endpoint. Explain the cause before making changes.”&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debug OAuth&lt;/td&gt;
&lt;td&gt;“The browser says OAuth succeeded, but a fresh Codex session reports &lt;code&gt;AuthRequired&lt;/code&gt;. Use official OpenAI Codex documentation, check &lt;code&gt;codex mcp list&lt;/code&gt; and &lt;code&gt;/mcp&lt;/code&gt;, distinguish server reachability from credential persistence, and do not ask me to paste a token.”&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Collect evidence&lt;/td&gt;
&lt;td&gt;“Diagnose this connection layer by layer: saved configuration, endpoint, transport, OAuth callback, stored credential, fresh-session discovery, WordPress site access, and tool permissions. Show the evidence for each conclusion.”&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A useful troubleshooting prompt includes four things: the desired outcome, the observed error text, the authoritative sources to consult, and what Codex must not change without confirmation.&lt;/p&gt;

&lt;h2&gt;
  
  
  6 · Verify the Site Before Creating or Editing Content
&lt;/h2&gt;

&lt;p&gt;Once the connector is working, ask Codex to list the accessible WordPress.com sites before writing anything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Use the WordPress.com MCP tools to list the sites I can access.
Show each site ID, domain, connection status, and MCP availability.
Do not create or update content.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This session demonstrated why that step matters. The account had multiple sites, but only the intended Techucation site could perform the requested basic content operation. Use the numeric site ID or exact domain in later prompts, especially when similarly named or disconnected sites are present.&lt;/p&gt;

&lt;h2&gt;
  
  
  7 · Use a Draft-First Workflow
&lt;/h2&gt;

&lt;p&gt;Tell Codex the target site and status explicitly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a new post on malcolmlow.com as a draft.
Do not publish it.
Return the post ID, edit URL, and preview URL.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before updating an existing draft, have Codex list recent drafts with their IDs and modification times. “The draft article” can be ambiguous when a site contains many drafts. In this session, the newest modified draft was identified as post &lt;code&gt;3955&lt;/code&gt; before any write operation was attempted.&lt;/p&gt;

&lt;p&gt;Publishing and editing are separate actions. A request to improve formatting should preserve &lt;code&gt;status: draft&lt;/code&gt;. A request to publish should identify the site and post ID, and Codex should state that the change will make the article public before executing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  8 · Security and Review Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install Termux and Codex only from trusted sources.&lt;/li&gt;
&lt;li&gt;Never place WordPress passwords, OAuth tokens, or credential files in prompts.&lt;/li&gt;
&lt;li&gt;Keep &lt;code&gt;~/.codex&lt;/code&gt; private.&lt;/li&gt;
&lt;li&gt;Enable only the WordPress MCP tools you need.&lt;/li&gt;
&lt;li&gt;Confirm the exact domain and post ID before a write.&lt;/li&gt;
&lt;li&gt;Keep new and revised articles as drafts until reviewed.&lt;/li&gt;
&lt;li&gt;Check headings, code blocks, links, categories, tags, featured image, alt text, and mobile layout.&lt;/li&gt;
&lt;li&gt;Revoke WordPress.com access if the phone is lost or replaced.&lt;/li&gt;
&lt;li&gt;Use Android screen locking and device encryption.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  9 · Command Cheat Sheet
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Prepare Termux
pkg update
pkg upgrade
pkg install nodejs git

# Install Codex
npm install -g @openai/codex
codex --version

# Register WordPress.com MCP
codex mcp add wpcom-mcp --url https://public-api.wordpress.com/wpcom/v2/mcp/v1

# Authenticate and inspect
codex mcp login wpcom-mcp
codex mcp get wpcom-mcp
codex mcp list
codex mcp --help

# Start a fresh session
codex

# Inside the Codex TUI
/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Once the connection works, keep the workflow conservative: let Codex research and draft first, create or update the WordPress draft second, review it in the editor, and publish only after the exact site and post have been confirmed.&lt;/p&gt;

&lt;p&gt;AI Workflows · 2026&lt;/p&gt;

&lt;p&gt;✦ This article was assembled with the assistance of OpenAI Codex and checked against current official Codex documentation ✦&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Related AI workflow:&lt;/strong&gt; This Codex–Termux publishing setup turns a mobile device into an agentic workflow environment. &lt;a href="https://malcolmlow.com/2024/09/04/what-is-agentic-workflow-discover-how-ai-enhances-productivity/" rel="noopener noreferrer"&gt;See what agentic workflow means and how AI enhances productivity.&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;WordPress Guides&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://malcolmlow.com/2026/05/26/publishing-to-wordpress-with-claude-and-the-wordpress-mcp-connector/" rel="noopener noreferrer"&gt;Publish to WordPress with Claude and MCP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://malcolmlow.com/2026/06/11/move-your-wordpress-com-domain-to-cloudflare-and-halve-the-renewal/" rel="noopener noreferrer"&gt;Move a WordPress.com domain to Cloudflare&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://malcolmlow.com/2020/06/21/quick-guide-to-git/" rel="noopener noreferrer"&gt;Version publishing scripts with Git&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Want a complete Codex project?&lt;/strong&gt; Follow the &lt;a href="https://malcolmlow.com/2026/05/15/knights-tour-codex-cli/" rel="noopener noreferrer"&gt;hands-on Knight’s Tour project with Codex CLI&lt;/a&gt;, including scaffolding, tests and diff review.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>wordpress</category>
      <category>android</category>
      <category>mcp</category>
    </item>
    <item>
      <title>Homebrew Cask Explained: Install macOS Apps from Terminal</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Thu, 10 Sep 2026 11:49:35 +0000</pubDate>
      <link>https://dev.to/malcolmlow/homebrew-cask-explained-install-macos-apps-from-terminal-2h34</link>
      <guid>https://dev.to/malcolmlow/homebrew-cask-explained-install-macos-apps-from-terminal-2h34</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published on &lt;a href="https://malcolmlow.com/2025/11/12/streamlining-macos-application-management-with-homebrew-cask/" rel="noopener noreferrer"&gt;malcolmlow.com&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Homebrew Cask&lt;/strong&gt; is a command-line extension of Homebrew, the macOS package manager, that installs, updates, and removes full graphical (GUI) applications, things like Chrome, Slack, or VS Code, using a single terminal command instead of downloading a disk image and dragging an icon into Applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Homebrew Cask quick answer:&lt;/strong&gt; use &lt;code&gt;brew install --cask app-name&lt;/code&gt; to install a macOS GUI application from Terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew search --cask chrome
brew install --cask google-chrome
brew upgrade --cask
brew uninstall --cask google-chrome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;macOS users frequently face the challenge of efficiently managing application installations across multiple machines. The traditional approach involves manually downloading disk images, navigating installation wizards, and maintaining applications across systems. Homebrew Cask offers a command-line solution that significantly streamlines this process.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Homebrew Cask?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Homebrew&lt;/strong&gt; installs command-line tools and libraries, called &lt;em&gt;formulae&lt;/em&gt;, while &lt;strong&gt;Homebrew Cask&lt;/strong&gt; installs complete macOS applications with graphical interfaces. For example, &lt;code&gt;brew install wget&lt;/code&gt; installs a terminal utility, whereas &lt;code&gt;brew install --cask visual-studio-code&lt;/code&gt; installs the Visual Studio Code app in macOS. Cask functionality is built into modern Homebrew, so no separate tap or extension needs to be installed.&lt;/p&gt;

&lt;p&gt;The conventional installation workflow requires multiple steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Locating the official download source&lt;/li&gt;
&lt;li&gt;Downloading the disk image file&lt;/li&gt;
&lt;li&gt;Opening and mounting the disk image&lt;/li&gt;
&lt;li&gt;Transferring the application to the Applications folder&lt;/li&gt;
&lt;li&gt;Ejecting the disk image&lt;/li&gt;
&lt;li&gt;Managing the downloaded installer file&lt;/li&gt;
&lt;li&gt;Repeating this process for each required application&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Homebrew Cask reduces this to a single command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install --cask google-chrome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application is then installed automatically with no further user interaction required.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Advantages for Professional Workflows
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Accelerated System Provisioning
&lt;/h3&gt;

&lt;p&gt;Organizations and individual users can maintain installation scripts containing all required applications. A typical enterprise development environment setup might include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install --cask visual-studio-code
brew install --cask docker
brew install --cask slack
brew install --cask zoom
brew install --cask rectangle
brew install --cask iterm2
brew install --cask spotify
brew install --cask vlc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach reduces new machine setup time from several hours to approximately 15-20 minutes, depending on network bandwidth and the number of applications being installed.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Simplified Update Management
&lt;/h3&gt;

&lt;p&gt;Maintaining current software versions is essential for security compliance and feature availability. Run the following command to upgrade outdated Cask-managed applications:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew upgrade --cask
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This upgrades outdated managed casks. Casks marked &lt;code&gt;version :latest&lt;/code&gt; or &lt;code&gt;auto_updates true&lt;/code&gt; normally require the &lt;code&gt;--greedy&lt;/code&gt; option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew upgrade --cask --greedy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Complete Application Removal
&lt;/h3&gt;

&lt;p&gt;Plain &lt;code&gt;brew uninstall --cask&lt;/code&gt; removes the managed application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew uninstall --cask docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To also attempt removal of associated preferences and caches, use &lt;code&gt;--zap&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew uninstall --cask --zap docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;--zap&lt;/code&gt; carefully because it may remove files shared with other applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Automation and Standardization
&lt;/h3&gt;

&lt;p&gt;Homebrew Cask’s command-line interface enables scripting and automation. Development teams can create standardized setup scripts ensuring consistent development environments. IT departments can implement automated workstation provisioning workflows. System configurations can be version-controlled in dotfiles repositories, enabling rapid deployment and rollback capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recommended Applications by Category
&lt;/h2&gt;

&lt;p&gt;The following applications represent commonly deployed tools across professional environments:&lt;/p&gt;

&lt;h3&gt;
  
  
  Development Tools
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install --cask visual-studio-code
brew install --cask iterm2
brew install --cask docker
brew install --cask postman
brew install --cask dbeaver-community
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Productivity Applications
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install --cask rectangle        # Window management
brew install --cask alfred           # Enhanced search functionality
brew install --cask obsidian         # Knowledge management
brew install --cask notion           # Collaborative workspace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Communication Platforms
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install --cask slack
brew install --cask zoom
brew install --cask discord
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  System Utilities
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install --cask the-unarchiver
brew install --cask appcleaner
brew install --cask vlc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Implementation Guide
&lt;/h2&gt;

&lt;p&gt;Organizations and users without an existing Homebrew installation can deploy it with a single command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once Homebrew is installed, Cask functionality is built right in. Just start using &lt;code&gt;brew install --cask&lt;/code&gt; commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  Useful Commands to Know
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Search for an app
brew search --cask chrome

# Get information about an app
brew info --cask visual-studio-code

# List all installed cask apps
brew list --cask

# Update all apps
brew upgrade --cask

# Uninstall an app
brew uninstall --cask slack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to Install Homebrew Casks in ~/Applications
&lt;/h3&gt;

&lt;p&gt;By default, Homebrew Cask installs applications in &lt;code&gt;/Applications&lt;/code&gt;. Use &lt;code&gt;--appdir&lt;/code&gt; to target the per-user &lt;code&gt;~/Applications&lt;/code&gt; directory instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install --cask --appdir="$HOME/Applications" visual-studio-code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use that location by default, set &lt;code&gt;HOMEBREW_CASK_OPTS&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export HOMEBREW_CASK_OPTS="--appdir=${HOME}/Applications"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the export command to your shell profile to persist it across terminal sessions.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Few Gotchas
&lt;/h2&gt;

&lt;p&gt;Cask isn’t perfect. Here are some things to be aware of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Not every app is available&lt;/strong&gt; – Popular apps are well-covered, but niche or very new applications might not be in the repository yet&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App Store apps aren’t included&lt;/strong&gt; – Apps distributed exclusively through the Mac App Store can’t be installed via Cask&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Some apps require manual steps&lt;/strong&gt; – Occasionally, an app needs additional configuration or permissions that Cask can’t automate&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Updates might lag slightly&lt;/strong&gt; – Cask maintainers need to update formulas when new versions release, so there can be a brief delay&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are minor inconveniences compared to the time saved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a cask in Homebrew?
&lt;/h3&gt;

&lt;p&gt;A “cask” is Homebrew’s term for a pre-packaged macOS GUI application, as opposed to a “formula,” which is Homebrew’s term for a command-line tool or library. When you run &lt;code&gt;brew install --cask app-name&lt;/code&gt;, Homebrew downloads the official installer for that app and places it in &lt;code&gt;Applications&lt;/code&gt; automatically, skipping the manual disk-image and drag-and-drop steps entirely.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between Homebrew and Homebrew Cask?
&lt;/h3&gt;

&lt;p&gt;Homebrew installs command-line tools and libraries (things like &lt;code&gt;git&lt;/code&gt; or &lt;code&gt;wget&lt;/code&gt;). Homebrew Cask is the same package manager extended to install full graphical applications (things like Chrome or Slack). Since 2018 they’ve shipped as a single unified &lt;code&gt;brew&lt;/code&gt; command — you don’t need to install Cask separately, just add the &lt;code&gt;--cask&lt;/code&gt; flag.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Homebrew Cask free?
&lt;/h3&gt;

&lt;p&gt;Yes. Homebrew and Homebrew Cask are both free, open-source projects. There’s no cost to install or use them — you’re simply automating the download of each app’s own installer, which may itself be free or paid depending on the app.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I install an app with Homebrew Cask?
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;brew install --cask app-name&lt;/code&gt; in Terminal, replacing &lt;code&gt;app-name&lt;/code&gt; with the app’s Cask identifier (for example, &lt;code&gt;brew install --cask visual-studio-code&lt;/code&gt;). Use &lt;code&gt;brew search --cask keyword&lt;/code&gt; first if you’re not sure of the exact name.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bottom Line
&lt;/h2&gt;

&lt;p&gt;Homebrew Cask has fundamentally changed how I interact with my Mac. What started as a way to avoid repetitive downloads has become an essential part of my workflow. The ability to script, automate, and version-control my application setup means I’m never more than a few commands away from a productive environment.&lt;/p&gt;

&lt;p&gt;If you spend any significant time on macOS, especially as a developer or power user, Homebrew Cask is worth learning. Your future self—the one setting up that next new machine—will thank you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;Pick three applications you use regularly and install them via Cask. I bet you’ll be hooked by the simplicity. Start with something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install --cask visual-studio-code
brew install --cask google-chrome  
brew install --cask rectangle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Welcome to a more efficient way of managing your Mac applications.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;What’s your favorite Homebrew Cask application? Have you automated your Mac setup? Share your experiences in the comments below!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try a Cask-managed Mac utility:&lt;/strong&gt; &lt;a href="https://malcolmlow.com/2026/03/11/say-goodbye-to-finder-meet-marta/" rel="noopener noreferrer"&gt;Marta is a free dual-pane file manager for macOS&lt;/a&gt;, and it installs with &lt;code&gt;brew install --cask marta&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>macos</category>
      <category>homebrew</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Quantum Computing: A Complete Learning Path</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Wed, 19 Aug 2026 16:05:49 +0000</pubDate>
      <link>https://dev.to/malcolmlow/quantum-computing-a-complete-learning-path-3c67</link>
      <guid>https://dev.to/malcolmlow/quantum-computing-a-complete-learning-path-3c67</guid>
      <description>&lt;p&gt;&lt;strong&gt;QUANTUM SERIES 2026&lt;/strong&gt; — The complete learning path, from a single qubit to Grover's algorithm.&lt;/p&gt;

&lt;p&gt;This is the index to the Techucation Quantum Series: a sequence of hands-on posts that build quantum computing from the ground up. Each one stands on its own, but together they form a single arc, from what a qubit actually is, through the rules that make quantum mechanics strange, to the algorithms that turn those rules into a real speedup. The order below is a learning path from first principles to algorithms, not the order the posts were written.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;New to the topic? Read top to bottom. Already comfortable with qubits and gates? Skip ahead to the algorithms in Section 4.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  0 · Foundational Pre-reading: The Math Behind the Phase
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2025/11/26/eulers-formula-shorthand-for-a-circle/" rel="noopener noreferrer"&gt;Euler's Formula: Why e^(iφ) Is Just Shorthand for a Circle&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
Optional warm-up before the qubit posts: the complex plane, i as a 90° rotation, and why the phase factor e^(iφ) traces a circle.&lt;/p&gt;

&lt;h2&gt;
  
  
  1 · Start Here: Qubits and Superposition
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2025/11/27/introduction-to-quantum-computing-qubits-hadamard-gates-and-superposition/" rel="noopener noreferrer"&gt;Quantum Computing From First Principles: Qubits, Hadamard Gates &amp;amp; Why H^2 = I&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
First principles: what a qubit is, how the Hadamard gate builds superposition, and why tensor products scale the state space.&lt;/p&gt;

&lt;h2&gt;
  
  
  2 · The Hadamard Toolkit
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2024/04/21/quantum-fourier-transform-of-1-qubit/" rel="noopener noreferrer"&gt;The Quantum Fourier Transform of a Single Qubit is the Hadamard Transform&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
The one-qubit QFT turns out to be exactly the Hadamard gate, a small result that anchors the bigger picture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2026/04/03/quantum-computing-the-walsh-hadamard-matrix-backbone-of-grovers-diffusion-operator/" rel="noopener noreferrer"&gt;The Walsh-Hadamard Matrix: Backbone of Grover's Diffusion Operator&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
How the Hadamard sign table generalises to n qubits and powers Grover's diffusion step.&lt;/p&gt;

&lt;h2&gt;
  
  
  3 · The Rules of the Quantum World
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2025/12/24/reversible-computation-in-quantum-computing/" rel="noopener noreferrer"&gt;Reversible Computation in Quantum Computing&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
Why every quantum gate must be reversible, and how ancilla bits turn irreversible logic into unitary logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2025/12/27/the-cost-of-garbage-why-we-must-clean-junk-bits/" rel="noopener noreferrer"&gt;The Cost of Garbage in Quantum Computing&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
Leftover junk qubits destroy interference; uncomputation cleans them up to protect the speedup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2026/06/07/the-no-cloning-theorem-in-quantum-computing-why-you-cant-copy-a-qubit/" rel="noopener noreferrer"&gt;The No-Cloning Theorem: Why You Cannot Copy a Qubit&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
A short proof that an unknown quantum state cannot be duplicated, and what that impossibility makes possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2026/06/24/quantum-teleportation-and-why-it-isnt-cloning/" rel="noopener noreferrer"&gt;Quantum Teleportation, and Why It Is Not Cloning&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
Moving an unknown qubit from one place to another without ever copying it, using entanglement and two classical bits.&lt;/p&gt;

&lt;h2&gt;
  
  
  4 · Algorithms
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2025/12/09/understanding-phase-kickback-in-quantum-computing/" rel="noopener noreferrer"&gt;Understanding Phase Kickback&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
The mechanism where the target qubit flips the control's phase, the trick underneath Deutsch's, Grover's, and Shor's.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2025/12/09/deutschs-algorithm-in-quantum-computing-the-4-cases/" rel="noopener noreferrer"&gt;Deutsch's Algorithm: The Four Cases&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
The four one-bit Boolean functions, the reversible oracle, and the single query that beats the classical two.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2025/12/20/deutsch-algorithm-revisited-quantum-vs-classical-implementation-in-qiskit/" rel="noopener noreferrer"&gt;Deutsch Revisited: Quantum vs Classical in Qiskit&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
The same algorithm in running Qiskit code: two classical queries against one quantum query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2026/03/28/quantum-computing-inversion-about-the-mean/" rel="noopener noreferrer"&gt;Grover's Algorithm: Inversion About the Mean&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
A full three-qubit walkthrough of the oracle and the amplitude amplification that surfaces the marked item.&lt;/p&gt;

&lt;h2&gt;
  
  
  5 · Entanglement and Bell's Inequality
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://malcolmlow.com/2025/10/20/exploring-quantum-entanglement-chsh-game-simulator/" rel="noopener noreferrer"&gt;The CHSH Game Simulator and Bell's Inequality&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
An interactive game where quantum entanglement beats the classical 75 percent ceiling and violates Bell's inequality.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Quantum Series 2026 · Built with Qiskit 1.x&lt;/em&gt;&lt;/p&gt;

</description>
      <category>quantumcomputing</category>
      <category>qiskit</category>
      <category>tutorial</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Mac Mini M4 vs Mac Studio for Local LLMs: AI Benchmarks</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Thu, 06 Aug 2026 02:48:52 +0000</pubDate>
      <link>https://dev.to/malcolmlow/mac-mini-m4-vs-mac-studio-for-local-llms-ai-benchmarks-1imo</link>
      <guid>https://dev.to/malcolmlow/mac-mini-m4-vs-mac-studio-for-local-llms-ai-benchmarks-1imo</guid>
      <description>&lt;h1&gt;
  
  
  Mac Mini M4 vs Mac Studio for Local LLMs
&lt;/h1&gt;

&lt;p&gt;Which Mac is the better local-LLM workstation? The answer depends on model size, memory and whether sustained throughput matters more than price. My hands-on comparison covers the Mac Mini M4 and Mac Studio across 1B, 8B and 14B models.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick answer
&lt;/h2&gt;

&lt;p&gt;The Mac Mini M4 is the value choice for smaller models and occasional experiments. Mac Studio pulls ahead for larger models, longer contexts and repeated generation, where its higher memory bandwidth and sustained cooling help.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I measured
&lt;/h2&gt;

&lt;p&gt;I compared generation speed, time to first token and prompt processing on representative 1B, 8B and 14B local models. Treat the results as workload-specific: quantisation, context length and backend settings can change the ranking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing between them
&lt;/h2&gt;

&lt;p&gt;Choose the Mini when low cost, low power and a compact desk setup are priorities. Choose the Studio when local inference is a daily workload, larger models must stay in memory, or you need steadier performance over long sessions.&lt;/p&gt;

&lt;p&gt;Read the full benchmark methodology and results on the &lt;a href="https://malcolmlow.com/2025/11/13/mac-studio-vs-mac-mini-m4-local-ai-performance-benchmarks/" rel="noopener noreferrer"&gt;canonical Mac Mini M4 vs Mac Studio article&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>mac</category>
      <category>llm</category>
      <category>benchmark</category>
    </item>
    <item>
      <title>How to Connect Claude to the dev.to API and Build a Reusable Skill</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Sun, 26 Jul 2026 08:49:17 +0000</pubDate>
      <link>https://dev.to/malcolmlow/how-to-connect-claude-to-the-devto-api-and-build-a-reusable-skill-1jn8</link>
      <guid>https://dev.to/malcolmlow/how-to-connect-claude-to-the-devto-api-and-build-a-reusable-skill-1jn8</guid>
      <description>&lt;p&gt;MCP (Model Context Protocol) connectors extend Claude's reach into external services, but connector coverage is uneven across platforms. dev.to is one such gap: no MCP connector currently supports writing to it. This post documents the workaround — calling dev.to's REST API directly, converting that workflow into a reusable Claude skill, and the reasoning behind keeping the API key out of that skill entirely.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The Gap: No MCP Connector for dev.to Writes
&lt;/h2&gt;

&lt;p&gt;Claude connects to external services through MCP (Model Context Protocol) connectors — Gmail, Google Drive, Shopify, and so on. A community-built &lt;a href="https://github.com/nickytonline/dev-to-mcp" rel="noopener noreferrer"&gt;dev-to-mcp server&lt;/a&gt; exists, but it only wraps dev.to's &lt;em&gt;public&lt;/em&gt; API: &lt;code&gt;get_articles&lt;/code&gt;, &lt;code&gt;get_article&lt;/code&gt;, &lt;code&gt;get_user&lt;/code&gt;, &lt;code&gt;get_tags&lt;/code&gt;, &lt;code&gt;get_comments&lt;/code&gt;, &lt;code&gt;search_articles&lt;/code&gt;. Read-only, by design — the author explicitly left out the authenticated write endpoints to keep the initial release simple.&lt;/p&gt;

&lt;p&gt;The existence of an MCP server for a service doesn't mean everything that service's API can do is exposed through it. That distinction matters when planning any AI-agent integration against a third-party platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The Workaround: dev.to's Real REST API
&lt;/h2&gt;

&lt;p&gt;dev.to has had a full authenticated REST API for years — create, read, update, delete articles, plus follower and notification endpoints. It's a plain API, not an MCP tool, which means using it requires a general-purpose way to make HTTP calls: a sandboxed environment with network access and a shell. The complete reference — every endpoint, required headers, and response schema — is published at &lt;a href="https://developers.forem.com/api/v1" rel="noopener noreferrer"&gt;developers.forem.com/api/v1&lt;/a&gt;. This is the page an AI agent (or a person) should read directly before writing any integration code against it, rather than relying on prior training knowledge of the API shape.&lt;/p&gt;

&lt;p&gt;The workflow reduces to three plain HTTP calls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. GET  /api/articles/:username/:slug   → find the numeric article ID
2. GET  /api/articles/:username/:slug   → pull body_markdown to edit locally
3. PUT  /api/articles/:id  (with api-key header)  → push the new title, tags, body
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The raw markdown is fetched, edited with standard text-replacement, and pushed back with a signed request. The published URL and slug remain unchanged after a title edit, so existing links continue to resolve correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Turning It Into a Reusable Skill
&lt;/h2&gt;

&lt;p&gt;Claude supports "skills" — markdown files that document a workflow so it doesn't need to rediscover the same steps in a future session. The dev.to workflow above was written up as a &lt;code&gt;SKILL.md&lt;/code&gt; covering the exact curl patterns, a link to the official API reference, the tag-format constraints (max four tags, alphanumeric only), and the note that a PUT only changes the fields explicitly sent.&lt;/p&gt;

&lt;p&gt;That file sits alongside similar skills built for a Shopify cross-listing workflow and a WordPress publishing workflow — each one converting a one-off problem-solving session into something reusable, rather than re-explaining the same constraints each time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🔐 &lt;strong&gt;The rule that mattered more than any of the code: the API key never went into the skill file.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Skill files persist. They are read back into context automatically in every future conversation, on any device, indefinitely. A live credential sitting in one is a standing liability — no expiry, no encryption, no audit trail, and no way to verify later who or what might have accessed it. The skill therefore documents where to obtain the key and includes a reminder to request it fresh each session, but the value itself is never written down. It is used for the curl calls in a single conversation, then discarded.&lt;/p&gt;

&lt;p&gt;The key is generated at &lt;a href="https://dev.to/settings/extensions"&gt;dev.to → Settings → Extensions&lt;/a&gt;, under the "DEV API Keys" section near the bottom of that page.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  4. Applying This Pattern Elsewhere
&lt;/h2&gt;

&lt;p&gt;This pattern is not dev.to-specific. It applies to any service where an MCP connector doesn't yet exist, or only covers part of the API:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check whether the service has a plain REST API, even without an MCP wrapper — most established platforms do.&lt;/li&gt;
&lt;li&gt;Have Claude write the skill file &lt;em&gt;after&lt;/em&gt; the problem has been solved once, so it captures the real constraints (rate limits, required headers, field-naming quirks) rather than a guess.&lt;/li&gt;
&lt;li&gt;Keep secrets out of anything durable. If a workflow needs a credential, the skill should describe how to obtain one and where to provide it — never store the value itself.&lt;/li&gt;
&lt;li&gt;State the no-storage requirement explicitly when asking for a skill to be created, since the entire purpose of a skill is to outlive the conversation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Example Prompts for Each Step
&lt;/h2&gt;

&lt;p&gt;The steps above map directly onto plain-language requests. These are the actual prompts that drive each stage of the workflow:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Example Prompt&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Check what's possible&lt;/td&gt;
&lt;td&gt;"Check your connectors and skills — can you update a post on dev.to?"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set up (first time)&lt;/td&gt;
&lt;td&gt;"Look up the API docs at developers.forem.com/api/v1, figure out how to update a dev.to article, then store what you learn into a skill — don't save the API key in it."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Connect (each session)&lt;/td&gt;
&lt;td&gt;"Use the dev.to skill to update this post: [url]" — Claude should then ask for the API key and remind you it's generated at dev.to → Settings → Extensions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Look up an article&lt;/td&gt;
&lt;td&gt;"Look up this dev.to article and tell me its current title, tags, and ID: [url]"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create a new post&lt;/td&gt;
&lt;td&gt;"Publish a new dev.to post titled '[title]' with this content: [markdown], tagged [tag1, tag2, tag3]."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Update an existing post&lt;/td&gt;
&lt;td&gt;"Update my dev.to post at [url] — change the title to '[new title]' and add the tag [tag]."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sync with a source article&lt;/td&gt;
&lt;td&gt;"This dev.to post is a cross-post of [source URL]. Update it to match the current version."&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each prompt is a plain description of the desired outcome, not a set of technical instructions — the skill file supplies the mechanics (endpoints, headers, field constraints) so the request itself can stay short.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>claude</category>
      <category>mcp</category>
    </item>
    <item>
      <title>Quantum Teleportation, and Why It Isn't Cloning</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Wed, 24 Jun 2026 11:04:09 +0000</pubDate>
      <link>https://dev.to/malcolmlow/quantum-teleportation-and-why-it-isnt-cloning-1fdl</link>
      <guid>https://dev.to/malcolmlow/quantum-teleportation-and-why-it-isnt-cloning-1fdl</guid>
      <description>&lt;p&gt;&lt;em&gt;Part of the Techucation Quantum Series.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Teleportation is the most over-sold word in quantum computing. It conjures Star Trek transporters and faster-than-light messaging, and almost every popular account quietly implies you end up with a &lt;em&gt;copy&lt;/em&gt; of the original. You do not. Quantum teleportation moves an unknown quantum state from one qubit to another while &lt;strong&gt;destroying&lt;/strong&gt; the original, and that destruction is not an incidental detail. It is the mechanism that keeps the protocol on the right side of the no-cloning theorem.&lt;/p&gt;

&lt;h2&gt;
  
  
  A quick word on no-cloning
&lt;/h2&gt;

&lt;p&gt;This whole protocol is haunted by the &lt;strong&gt;no-cloning theorem&lt;/strong&gt;: there is no operation that copies an arbitrary &lt;em&gt;unknown&lt;/em&gt; quantum state. I worked through the proof and its consequences in a recent post, &lt;a href="https://malcolmlow.com/2026/06/07/the-no-cloning-theorem-in-quantum-computing-why-you-cant-copy-a-qubit/" rel="noopener noreferrer"&gt;The No-Cloning Theorem in Quantum Computing: Why You Can't Copy a Qubit&lt;/a&gt;, so I won't re-derive it here.&lt;/p&gt;

&lt;p&gt;The single fact we need: &lt;strong&gt;you cannot deterministically duplicate an unknown qubit.&lt;/strong&gt; The qualifiers matter, because teleportation lives in the gaps between them. The theorem forbids copying &lt;em&gt;unknown&lt;/em&gt; states (a known state you can re-prepare at will), it forbids &lt;em&gt;deterministic, perfect&lt;/em&gt; copies, and it is a statement about &lt;em&gt;unitary&lt;/em&gt; operations — and measurement, which teleportation leans on at the decisive moment, is not unitary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why teleportation isn't cloning
&lt;/h2&gt;

&lt;p&gt;The distinction in one sentence: &lt;strong&gt;cloning would leave &lt;code&gt;|ψ⟩&lt;/code&gt; in two places; teleportation leaves it in exactly one.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Partway through the protocol, Alice's message qubit is &lt;em&gt;measured&lt;/em&gt;. Measurement collapses it into a classical basis state — a plain &lt;code&gt;|0⟩&lt;/code&gt; or &lt;code&gt;|1⟩&lt;/code&gt; carrying none of the original amplitudes. By the time Bob's qubit holds &lt;code&gt;|ψ⟩&lt;/code&gt;, Alice's qubit demonstrably does not. The state was relocated, and the accounting is exact: one copy in, one copy out. No moment ever exists where two qubits both carry &lt;code&gt;|ψ⟩&lt;/code&gt;, so there is nothing for the no-cloning theorem to object to.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This also kills the faster-than-light fantasy. The protocol forces Alice to send Bob two ordinary classical bits. Until they arrive, Bob's qubit is information-free — we will see that fall out of the algebra below.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The complete circuit
&lt;/h2&gt;

&lt;p&gt;Read it left to right; the protocol splits into three stages. The message qubit &lt;code&gt;q0&lt;/code&gt; starts in the unknown state &lt;code&gt;|ψ⟩&lt;/code&gt;, while &lt;code&gt;q1&lt;/code&gt; and &lt;code&gt;q2&lt;/code&gt; both start in &lt;code&gt;|0⟩&lt;/code&gt;. In the diagram, &lt;code&gt;*&lt;/code&gt; marks a control and &lt;code&gt;(+)&lt;/code&gt; a CNOT target.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3rdgpnptd6glg1pftaz9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3rdgpnptd6glg1pftaz9.jpg" alt=" " width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 1 — Bell pair.&lt;/strong&gt; Alice and Bob share an entangled pair: an &lt;code&gt;H&lt;/code&gt; on &lt;code&gt;q1&lt;/code&gt; followed by a CNOT from &lt;code&gt;q1&lt;/code&gt; onto &lt;code&gt;q2&lt;/code&gt; prepares &lt;code&gt;(|00⟩ + |11⟩)/√2&lt;/code&gt; across the two halves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 2 — Alice measures.&lt;/strong&gt; Alice folds her message into the pair (a CNOT from &lt;code&gt;q0&lt;/code&gt; onto &lt;code&gt;q1&lt;/code&gt;, then an &lt;code&gt;H&lt;/code&gt; on &lt;code&gt;q0&lt;/code&gt;) and measures both of her qubits, collapsing them to two classical bits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 3 — Bob corrects.&lt;/strong&gt; Depending on those two bits, Bob applies an &lt;code&gt;X&lt;/code&gt; and/or a &lt;code&gt;Z&lt;/code&gt; to &lt;code&gt;q2&lt;/code&gt; — the &lt;code&gt;X&lt;/code&gt; controlled by Alice's &lt;code&gt;q1&lt;/code&gt; bit, the &lt;code&gt;Z&lt;/code&gt; by her &lt;code&gt;q0&lt;/code&gt; bit — and &lt;code&gt;q2&lt;/code&gt; emerges as &lt;code&gt;|ψ⟩&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The protocol in bra-ket and tensor form
&lt;/h2&gt;

&lt;p&gt;Three qubits: &lt;code&gt;q0&lt;/code&gt; carries &lt;code&gt;|ψ⟩ = α|0⟩ + β|1⟩&lt;/code&gt;, &lt;code&gt;q1&lt;/code&gt; is Alice's half of the Bell pair, and &lt;code&gt;q2&lt;/code&gt; is Bob's half. They pre-share &lt;code&gt;|Φ+⟩ = (|00⟩ + |11⟩)/√2&lt;/code&gt; on &lt;code&gt;q1 q2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — the starting state.&lt;/strong&gt; Tensor the message against the Bell pair:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|ψ⟩ = α|0⟩ + β|1⟩            (the unknown message on q0)

|ψ⟩ ⊗ |Φ+⟩ = (α|0⟩ + β|1⟩) ⊗ (|00⟩ + |11⟩)/√2
           = (1/√2) [ α|000⟩ + α|011⟩ + β|100⟩ + β|111⟩ ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2 — Alice's CNOT&lt;/strong&gt; (control q0, target q1):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CNOT (control q0, target q1)  flips q1 wherever q0 = 1:

= (1/√2) [ α|000⟩ + α|011⟩ + β|110⟩ + β|101⟩ ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3 — Alice's Hadamard on q0.&lt;/strong&gt; Substitute &lt;code&gt;|0⟩ → (|0⟩+|1⟩)/√2&lt;/code&gt; and &lt;code&gt;|1⟩ → (|0⟩−|1⟩)/√2&lt;/code&gt;, then collect by the value of &lt;code&gt;(q0 q1)&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;H on q0, then collect by the pair Alice will measure (q0 q1):

= (1/2) [ |00⟩ (α|0⟩ + β|1⟩)    ← case A
        + |01⟩ (α|1⟩ + β|0⟩)    ← case B
        + |10⟩ (α|0⟩ − β|1⟩)    ← case C
        + |11⟩ (α|1⟩ − β|0⟩) ]  ← case D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each bracketed &lt;code&gt;q2&lt;/code&gt; state is the original &lt;code&gt;|ψ⟩&lt;/code&gt; acted on by a known Pauli. Alice measures, gets one of four outcomes (each with probability 1/4), sends the two bits to Bob, and Bob undoes the Pauli. The &lt;strong&gt;Case&lt;/strong&gt; column ties each row back to the matching line in Step 3:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt; Case | Alice measures (q0 q1) | Bob holds on q2 | Relation to |ψ⟩ | Bob applies 
------+------------------------+-----------------+-----------------+-------------
 A    | 00                     | α|0⟩ + β|1⟩     | I |ψ⟩           | nothing     
 B    | 01                     | α|1⟩ + β|0⟩     | X |ψ⟩           | X           
 C    | 10                     | α|0⟩ − β|1⟩     | Z |ψ⟩           | Z           
 D    | 11                     | α|1⟩ − β|0⟩     | ZX |ψ⟩          | X then Z    
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bob applies &lt;code&gt;Z^m0 X^m1&lt;/code&gt; — an &lt;code&gt;X&lt;/code&gt; if &lt;code&gt;m1 = 1&lt;/code&gt;, then a &lt;code&gt;Z&lt;/code&gt; if &lt;code&gt;m0 = 1&lt;/code&gt; — and every branch lands back on &lt;code&gt;α|0⟩ + β|1⟩ = |ψ⟩&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Qiskit — classical feed-forward
&lt;/h2&gt;

&lt;p&gt;This version measures mid-circuit and uses real classical conditioning via &lt;code&gt;if_test&lt;/code&gt;. The verification trick: rather than read out Bob's state, apply the &lt;em&gt;inverse&lt;/em&gt; of the preparation to &lt;code&gt;q2&lt;/code&gt;. If teleportation worked, that must collapse &lt;code&gt;q2&lt;/code&gt; to &lt;code&gt;|0⟩&lt;/code&gt; on every shot.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;qiskit&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;QuantumCircuit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;QuantumRegister&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ClassicalRegister&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transpile&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;qiskit.circuit.library&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StatePreparation&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;qiskit.quantum_info&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random_statevector&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;qiskit_aer&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;AerSimulator&lt;/span&gt;

&lt;span class="c1"&gt;# Unknown state to teleport (StatePreparation is unitary -&amp;gt; invertible)
&lt;/span&gt;&lt;span class="n"&gt;psi&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;random_statevector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;StatePreparation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;psi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;q&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;q&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# q0 message, q1 Alice, q2 Bob
&lt;/span&gt;&lt;span class="n"&gt;mz&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ClassicalRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mz&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# q0 result -&amp;gt; drives Z
&lt;/span&gt;&lt;span class="n"&gt;mx&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ClassicalRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mx&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# q1 result -&amp;gt; drives X
&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ClassicalRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;out&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# verification bit
&lt;/span&gt;&lt;span class="n"&gt;qc&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumCircuit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mz&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prep&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;        &lt;span class="c1"&gt;# 1. load |ψ⟩ onto q0
&lt;/span&gt;&lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;        &lt;span class="c1"&gt;# 2. Bell pair on (q1,q2)
&lt;/span&gt;&lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                      &lt;span class="c1"&gt;# 3. Alice's basis change
&lt;/span&gt;&lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mz&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mx&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;if_test&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;mx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;                 &lt;span class="c1"&gt;# 4. Bob's corrections
&lt;/span&gt;    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;if_test&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;mz&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;z&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prep&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inverse&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;            &lt;span class="c1"&gt;# 5. un-prepare on Bob: must read 0
&lt;/span&gt;&lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AerSimulator&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;transpile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;AerSimulator&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="n"&gt;shots&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;result&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;get_counts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;clean&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# leftmost bit = out
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counts&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Teleportation verified:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;clean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;out&lt;/code&gt; bit comes back &lt;code&gt;0&lt;/code&gt; on 100% of shots regardless of the random &lt;code&gt;(mx, mz)&lt;/code&gt; branch — exactly the claim that Bob reconstructs &lt;code&gt;|ψ⟩&lt;/code&gt; in every case.&lt;/p&gt;

&lt;h2&gt;
  
  
  No faster-than-light, and the takeaway
&lt;/h2&gt;

&lt;p&gt;Before Bob learns &lt;code&gt;(m0, m1)&lt;/code&gt;, his qubit is an equal mixture of the four branch states. Averaging the four projectors gives the Pauli twirl:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ρ_Bob = (1/4)( |ψ⟩⟨ψ| + X|ψ⟩⟨ψ|X
              + Z|ψ⟩⟨ψ|Z + XZ|ψ⟩⟨ψ|ZX )  =  I/2   for every |ψ⟩
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for &lt;em&gt;any&lt;/em&gt; &lt;code&gt;|ψ⟩&lt;/code&gt;. Bob's local state is identical no matter what Alice sent, so no information has reached him yet. The classical bits are not a formality — they are the only thing that carries the state across, and they travel no faster than light.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Takeaway.&lt;/strong&gt; No-cloning forbids duplicating an unknown qubit (&lt;a href="https://malcolmlow.com/2026/06/07/the-no-cloning-theorem-in-quantum-computing-why-you-cant-copy-a-qubit/" rel="noopener noreferrer"&gt;proof here&lt;/a&gt;). Teleportation never attempts a copy: it entangles the message with a shared Bell pair, measures the original out of existence, and ships two classical bits naming which of four Pauli corrections rebuilds the state on the other end. Exactly one copy before, exactly one after. No-cloning is not a bug the protocol works around — it is the reason the protocol has to look the way it does.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://malcolmlow.com/2026/06/24/quantum-teleportation-and-why-it-isnt-cloning/" rel="noopener noreferrer"&gt;malcolmlow.com&lt;/a&gt;. Built with Qiskit. This article was written with the assistance of Claude by Anthropic.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>quantumcomputing</category>
      <category>qiskit</category>
      <category>python</category>
      <category>physics</category>
    </item>
    <item>
      <title>Move Your WordPress.com Domain to Cloudflare and Halve the Renewal</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Thu, 11 Jun 2026 04:33:59 +0000</pubDate>
      <link>https://dev.to/malcolmlow/move-your-wordpresscom-domain-to-cloudflare-and-halve-the-renewal-4a9n</link>
      <guid>https://dev.to/malcolmlow/move-your-wordpresscom-domain-to-cloudflare-and-halve-the-renewal-4a9n</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;This post was originally published on &lt;a href="https://malcolmlow.com/2026/06/11/move-your-wordpress-com-domain-to-cloudflare-and-halve-the-renewal/" rel="noopener noreferrer"&gt;Techucation&lt;/a&gt;, my blog at malcolmlow.com. Cross-posted here for the dev.to community.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My WordPress.com domain renewal notice came in at &lt;strong&gt;£16/year&lt;/strong&gt;, with auto-renew switched off and the expiry only a couple of days away. That is a fine price for convenience, but the same name sits on Cloudflare Registrar at wholesale cost with no markup. This post walks through the move end to end, including the one step that quietly breaks things if you rush it, and lays out the real cost difference.&lt;/p&gt;

&lt;p&gt;The short version: you do not "renew at Cloudflare". You &lt;strong&gt;transfer&lt;/strong&gt; the domain to Cloudflare, which extends the registration by a year in the process. The saving is real, but the order of operations matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The cost case
&lt;/h2&gt;

&lt;p&gt;Cloudflare Registrar charges exactly what the registry charges them, with zero markup, and bundles WHOIS privacy for free. Retail registrars add a margin on top. For a &lt;code&gt;.net&lt;/code&gt; the difference looks like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;WordPress.com&lt;/th&gt;
&lt;th&gt;Cloudflare Registrar&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;.net renewal (1 yr)&lt;/td&gt;
&lt;td&gt;£16 (approx US$20)&lt;/td&gt;
&lt;td&gt;approx US$10.44 (at cost)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Markup&lt;/td&gt;
&lt;td&gt;Retail margin&lt;/td&gt;
&lt;td&gt;None (wholesale pass-through)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WHOIS privacy&lt;/td&gt;
&lt;td&gt;Included&lt;/td&gt;
&lt;td&gt;Included, free&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Approx 5-year cost&lt;/td&gt;
&lt;td&gt;approx US$100&lt;/td&gt;
&lt;td&gt;approx US$52&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Figures are indicative for mid-2026.&lt;/strong&gt; Because Cloudflare is at cost, your renewal tracks the registry wholesale rate, so it moves up if the registry (Verisign for &lt;code&gt;.net&lt;/code&gt;) raises prices. The trade-off: Cloudflare requires the domain to run on Cloudflare DNS.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. The gotcha: transfer, not renew, and DNS moves first
&lt;/h2&gt;

&lt;p&gt;Two things trip people up:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You cannot renew a domain at a registrar where it is not registered.&lt;/strong&gt; To get Cloudflare pricing you transfer the domain in. A gTLD transfer (.com, .net, .org) automatically adds one year, so it replaces the renewal rather than stacking on top of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloudflare will not let you transfer the registration until the domain is already running on Cloudflare DNS.&lt;/strong&gt; So the real sequence is DNS first, registrar second, with any redirect rebuilt in the middle so the site never goes dark.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Mind the expiry window.&lt;/strong&gt; Do not start this within a few days of expiry and then walk away. A transfer left to auto-complete can take up to 5 days. If you are close to the date, expedite it (see step 6) rather than waiting out the clock.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  3. Step by step
&lt;/h2&gt;

&lt;p&gt;The full order of operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1  Unlock the domain at WordPress.com, get the EPP / auth code
2  Add the domain as a Free zone in Cloudflare
3  Stage the redirect in Cloudflare (before flipping nameservers)
4  Change nameservers at WordPress.com to Cloudflare's pair
5  Wait for the Cloudflare zone to go Active
6  Initiate the transfer in Cloudflare, paste the EPP code, pay
7  Approve / expedite the transfer on the WordPress.com side
8  Verify: registrar, new expiry, redirect, DNSSEC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; In WordPress.com under Upgrades &amp;gt; Domains, open the domain, turn off Transfer lock, then start the transfer-out flow far enough to reveal the EPP / auth code. Copy it. Do not let WordPress walk you all the way through its own wizard, you only want the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt; In the Cloudflare dashboard, Add a domain, choose the Free plan. Cloudflare scans existing DNS and assigns you two nameservers like &lt;code&gt;name.ns.cloudflare.com&lt;/code&gt;. Note them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt; If the domain is a redirect (common when it just points at another site of yours), rebuild that redirect in Cloudflare now while it sits idle. See section 4.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt; Back at WordPress.com, switch the nameservers from WordPress to the two Cloudflare nameservers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5.&lt;/strong&gt; Cloudflare flips the zone to Active once it sees the nameserver change, usually under an hour. The transfer option stays greyed out until then.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6.&lt;/strong&gt; Once Active, go to Domain Registration &amp;gt; Transfer Domains, select the domain, paste the EPP code, and pay the at-cost fee. This payment includes the added year.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7.&lt;/strong&gt; Watch for the confirmation from the losing registrar. WordPress.com surfaces a Transfer Management page with an &lt;strong&gt;Accept Transfer&lt;/strong&gt; button. Clicking it skips the 5-day wait and completes the transfer in minutes.&lt;/p&gt;

&lt;p&gt;Done: the registry should now show the registrar as Cloudflare, status Active, and the expiry rolled forward by a year.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. The redirect-only trap
&lt;/h2&gt;

&lt;p&gt;If your domain only exists to redirect to another site, the imported records (the host's A records and a couple of CNAMEs) become redundant once you build a Cloudflare Redirect Rule. Tempting to delete them all for a tidy zone. Here is the trap:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A Cloudflare Redirect Rule only fires on traffic that reaches Cloudflare's edge. Traffic only reaches the edge if the hostname resolves to a &lt;strong&gt;proxied&lt;/strong&gt; record (orange cloud). Delete every record and the name resolves to nothing, so the redirect goes dark.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The fix is to keep one proxied placeholder for the rule to attach to:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;Proxy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;@&lt;/td&gt;
&lt;td&gt;192.0.2.1&lt;/td&gt;
&lt;td&gt;Proxied&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CNAME&lt;/td&gt;
&lt;td&gt;www&lt;/td&gt;
&lt;td&gt;@&lt;/td&gt;
&lt;td&gt;Proxied (only if you want www)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TXT&lt;/td&gt;
&lt;td&gt;@&lt;/td&gt;
&lt;td&gt;"google-site-verification=..."&lt;/td&gt;
&lt;td&gt;DNS only&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;192.0.2.1&lt;/code&gt; is a reserved TEST-NET address that never routes anywhere, which is exactly what you want: the proxy intercepts the request before that IP is ever used. Then a single Redirect Rule (Rules &amp;gt; Redirect Rules) handles the rest:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;When (match)&lt;/td&gt;
&lt;td&gt;hostname ends with example.net&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Then (action)&lt;/td&gt;
&lt;td&gt;301 to &lt;a href="https://example.com" rel="noopener noreferrer"&gt;https://example.com&lt;/a&gt; + path&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Preserve query string&lt;/td&gt;
&lt;td&gt;On&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Keep the TXT verification record as DNS only. It does not need to resolve to anything, it just needs to exist.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. After the transfer
&lt;/h2&gt;

&lt;p&gt;Three things to settle once the registrar shows Cloudflare:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Auto-renew.&lt;/strong&gt; Optional, but turning it on (Domain Registration &amp;gt; your domain) means you never repeat the two-days-from-expiry scramble. If you leave it off, set yourself a reminder a few weeks before the date.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNSSEC.&lt;/strong&gt; Worth enabling for the added integrity protection. Because Cloudflare is now both your DNS and your registrar, the DS record is published to the registry automatically, so it activates without you touching the registrar by hand. Give it from a few minutes up to a couple of hours to show as signed at the registry.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Registrar lock.&lt;/strong&gt; On by default at Cloudflare, so that one is already handled.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;One caution with DNSSEC:&lt;/strong&gt; once the DS record is published, do not move nameservers away from Cloudflare or disable DNSSEC out of order. Breaking the signature chain is the classic way to make a domain go dark, because validating resolvers will reject it. As long as DNS stays on Cloudflare, you are fine.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Net result
&lt;/h2&gt;

&lt;p&gt;Same domain, half the renewal cost, a year added, and the registrar consolidated with your DNS. The only part that needs care is the DNS-first ordering and not over-deleting the redirect records. Everything else is a few clicks and a short wait.&lt;/p&gt;

</description>
      <category>cloudflare</category>
      <category>dns</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Deutsch Algorithm Revisited: Quantum vs Classical Implementation in Qiskit</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Sun, 07 Jun 2026 10:12:11 +0000</pubDate>
      <link>https://dev.to/malcolmlow/deutsch-algorithm-revisited-quantum-vs-classical-implementation-in-qiskit-4ii2</link>
      <guid>https://dev.to/malcolmlow/deutsch-algorithm-revisited-quantum-vs-classical-implementation-in-qiskit-4ii2</guid>
      <description>&lt;p&gt;In the &lt;a href="https://malcolmlow.com/2025/12/09/deutschs-algorithm-in-quantum-computing-the-4-cases/" rel="noopener noreferrer"&gt;previous post on the Deutsch algorithm&lt;/a&gt;, we covered the theory. Here we implement both the classical and quantum approaches in Qiskit so the quantum advantage is visible in working code: the same problem solved with fewer oracle queries than any classical method can manage.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Challenge
&lt;/h2&gt;

&lt;p&gt;Given a black-box function &lt;code&gt;f: {0,1} → {0,1}&lt;/code&gt;, determine whether it is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Constant&lt;/strong&gt;: f(0) = f(1) (always returns 0, or always returns 1)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Balanced&lt;/strong&gt;: f(0) ≠ f(1) (returns 0 for one input, 1 for the other)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The whole question is how many times you must query the function:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Queries required&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Classical&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quantum&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Complete Qiskit Implementation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Oracle functions
&lt;/h3&gt;

&lt;p&gt;First, build the oracle functions representing all possible single-bit Boolean functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;qiskit&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;QuantumCircuit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;QuantumRegister&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ClassicalRegister&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;qiskit_aer&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;AerSimulator&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_constant_oracle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;constant_value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Creates a constant oracle (returns 0 or 1 for all inputs)&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;oracle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumCircuit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Constant_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;constant_value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;constant_value&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Flip the output qubit
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;oracle&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_balanced_oracle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;balance_type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Creates a balanced oracle&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;oracle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumCircuit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Balanced_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;balance_type&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;balance_type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;identity&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# f(x) = x
&lt;/span&gt;        &lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;balance_type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;negation&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# f(x) = NOT x
&lt;/span&gt;        &lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;oracle&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Classical approach: two queries required
&lt;/h3&gt;

&lt;p&gt;The classical algorithm must query the oracle twice, once for f(0) and once for f(1):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;classical_deutsch_query1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;First query: Evaluate f(0)&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;qr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;q&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ClassicalRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;c&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumCircuit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Input: x = 0 (already initialized to |0&amp;gt;)
&lt;/span&gt;    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Measure output to get f(0)
&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;classical_deutsch_query2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Second query: Evaluate f(1)&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;qr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;q&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ClassicalRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;c&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumCircuit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Input: x = 1
&lt;/span&gt;    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Measure output to get f(1)
&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Quantum approach: one query suffices
&lt;/h3&gt;

&lt;p&gt;The quantum Deutsch algorithm uses superposition and interference to answer with a single oracle query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;deutsch_algorithm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Implements the Deutsch algorithm - requires only ONE query&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;qr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;q&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ClassicalRegister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;c&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QuantumCircuit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 1: Initialize q[1] to |1&amp;gt;
&lt;/span&gt;    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 2: Apply Hadamard gates (create superposition)
&lt;/span&gt;    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 3: Apply the oracle (SINGLE QUERY!)
&lt;/span&gt;    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 4: Apply Hadamard to input qubit
&lt;/span&gt;    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;barrier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 5: Measure
&lt;/span&gt;    &lt;span class="n"&gt;qc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;qc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Running the comparison
&lt;/h3&gt;

&lt;p&gt;Now test all four possible oracles with both approaches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;oracles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Constant 0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;create_constant_oracle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Constant 1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;create_constant_oracle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Balanced (Identity)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;create_balanced_oracle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;identity&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Balanced (Negation)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;create_balanced_oracle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;negation&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;simulator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AerSimulator&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;oracle&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;oracles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Classical: 2 queries
&lt;/span&gt;    &lt;span class="n"&gt;qc1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;classical_deutsch_query1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;result1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;simulator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qc1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shots&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;result&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;f_0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_counts&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;())[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="n"&gt;qc2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;classical_deutsch_query2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;result2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;simulator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qc2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shots&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;result&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;f_1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_counts&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;())[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="n"&gt;classical_result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CONSTANT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;f_0&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;f_1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;BALANCED&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="c1"&gt;# Quantum: 1 query
&lt;/span&gt;    &lt;span class="n"&gt;qc_quantum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deutsch_algorithm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oracle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;result_quantum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;simulator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qc_quantum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shots&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;result&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result_quantum&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_counts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;quantum_result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CONSTANT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;BALANCED&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: Classical=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;classical_result&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, Quantum=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;quantum_result&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Circuit Diagrams
&lt;/h2&gt;

&lt;p&gt;The full figures are rendered in the &lt;a href="https://malcolmlow.com/2025/12/20/deutsch-algorithm-revisited-quantum-vs-classical-implementation-in-qiskit/" rel="noopener noreferrer"&gt;original post&lt;/a&gt;; the structure of each is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Classical Query 1, f(0):&lt;/strong&gt; q[0] stays in |0⟩, the oracle processes the input, and q[1] is measured to read f(0).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Classical Query 2, f(1):&lt;/strong&gt; an X gate flips q[0] to |1⟩, the oracle processes it, and q[1] is measured to read f(1).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quantum Deutsch (single query):&lt;/strong&gt; initialise |01⟩, Hadamards on both wires create superposition, a single oracle query, a final Hadamard on q[0], then measure q[0].&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key structural difference: the classical circuits measure the &lt;strong&gt;output&lt;/strong&gt; qubit q[1] to read function values, while the quantum circuit measures the &lt;strong&gt;input&lt;/strong&gt; qubit q[0] after interference. That is what lets a single query reveal a global property of the function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sample Output
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;======================================================================
Testing: Constant 0 Oracle
======================================================================

[CLASSICAL APPROACH - Requires 2 queries]
  Query 1: f(0) = 0
  Query 2: f(1) = 0
  Result: Function is CONSTANT
  Total queries needed: 2

[QUANTUM APPROACH - Requires only 1 query]
  Measurement results: {'0': 1000}
  Result: Function is CONSTANT
  Total queries needed: 1

  Both methods agree: True

======================================================================
Testing: Balanced (Identity) Oracle
======================================================================

[CLASSICAL APPROACH - Requires 2 queries]
  Query 1: f(0) = 0
  Query 2: f(1) = 1
  Result: Function is BALANCED
  Total queries needed: 2

[QUANTUM APPROACH - Requires only 1 query]
  Measurement results: {'1': 1000}
  Result: Function is BALANCED
  Total queries needed: 1

  Both methods agree: True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Understanding the Quantum Advantage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Classical approach:&lt;/strong&gt; evaluate f(0), evaluate f(1), compare the two results. Two queries required; you must check both inputs individually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quantum approach:&lt;/strong&gt; query with a superposition of both inputs, use interference to extract the global property, then measure. One query required; it exploits quantum parallelism.&lt;/p&gt;

&lt;p&gt;The quantum algorithm queries the oracle with a superposition of both inputs simultaneously (|0⟩ + |1⟩), then uses interference to extract a global property of the function without evaluating it on individual inputs. The single measurement directly tells you whether the function is constant or balanced.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measurement Interpretation
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Function type&lt;/th&gt;
&lt;th&gt;Explanation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;|0⟩&lt;/td&gt;
&lt;td&gt;Constant&lt;/td&gt;
&lt;td&gt;Constructive interference, f(0) ⊕ f(1) = 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|1⟩&lt;/td&gt;
&lt;td&gt;Balanced&lt;/td&gt;
&lt;td&gt;Destructive interference, f(0) ⊕ f(1) = 1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Running the Code
&lt;/h2&gt;

&lt;p&gt;Install Qiskit and Aer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;qiskit qiskit-aer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run the comparison script; it outputs the result for all four oracle types.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This implementation shows the Deutsch advantage concretely: a 2x reduction in oracle queries (from 2 to 1), the first algorithm to demonstrate quantum advantage over classical, and a foundational technique introducing superposition, interference, and phase kickback. The speedup is modest for this toy problem, but the same idea (query with superposition, extract a global property through interference) scales up to Deutsch-Jozsa, Simon's algorithm, and Shor's factoring.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part of the Quantum Series 2026. Originally published on &lt;a href="https://malcolmlow.com/2025/12/20/deutsch-algorithm-revisited-quantum-vs-classical-implementation-in-qiskit/" rel="noopener noreferrer"&gt;Techucation&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>quantum</category>
      <category>qiskit</category>
      <category>python</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Deutsch's Algorithm in Quantum Computing: The 4 Cases</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Sun, 07 Jun 2026 10:11:35 +0000</pubDate>
      <link>https://dev.to/malcolmlow/deutschs-algorithm-in-quantum-computing-the-4-cases-5dae</link>
      <guid>https://dev.to/malcolmlow/deutschs-algorithm-in-quantum-computing-the-4-cases-5dae</guid>
      <description>&lt;p&gt;Deutsch's Algorithm determines whether a function &lt;em&gt;f(x)&lt;/em&gt; is &lt;strong&gt;constant&lt;/strong&gt; or &lt;strong&gt;balanced&lt;/strong&gt; using only a single query. Before getting to the quantum circuit, it helps to see how the four possible single-bit functions are physically built.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 4 Possible Functions
&lt;/h2&gt;

&lt;p&gt;With one input bit, there are exactly four Boolean functions. Two are constant (the output ignores the input) and two are balanced (the output depends on the input). In each oracle the bottom input is set to 0 so the output wire carries exactly f(x).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Constant Zero&lt;/td&gt;
&lt;td&gt;f(x) = 0&lt;/td&gt;
&lt;td&gt;Constant (identity, no gates)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Constant One&lt;/td&gt;
&lt;td&gt;f(x) = 1&lt;/td&gt;
&lt;td&gt;Constant (X on the output wire)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Balanced ID&lt;/td&gt;
&lt;td&gt;f(x) = x&lt;/td&gt;
&lt;td&gt;Balanced (CNOT)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Balanced NOT&lt;/td&gt;
&lt;td&gt;f(x) = ¬x&lt;/td&gt;
&lt;td&gt;Balanced (X, CNOT, X)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The General Oracle (U_f)
&lt;/h2&gt;

&lt;p&gt;Every oracle is wrapped in the standard reversible form. It leaves the input register alone and XORs f(x) into the output register:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;U_f |x⟩|y⟩  =  |x⟩ |y ⊕ f(x)⟩
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Complete Circuit
&lt;/h2&gt;

&lt;p&gt;To detect the function type in one shot, initialise the bottom wire to |1⟩ and use Hadamard gates to build superposition on both wires before and after the oracle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|0⟩ ──[H]──╤═════╤──[H]──[M]
           │ U_f │
|1⟩ ──[H]──╧═════╧───────────
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The top wire is the control, the bottom wire is the target prepared in |−⟩. The oracle's (−1)^f(x) phase is kicked back onto the top wire, and the final Hadamard converts that phase difference into a measurable 0 or 1.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mathematical Proof
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Initialisation:   |ψ₀⟩ = |0⟩|1⟩

2. Superposition:    |ψ₁⟩ = |+⟩|−⟩ = ½(|0⟩ + |1⟩)(|0⟩ − |1⟩)

3. The kickback:     U_f |x⟩|−⟩ = (−1)^f(x) |x⟩|−⟩
                     the function output is pushed into the phase of the top qubit.

4. Global state:     |ψ₂⟩ = (1/√2) [ (−1)^f(0)|0⟩ + (−1)^f(1)|1⟩ ] ⊗ |−⟩
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final Measurement
&lt;/h2&gt;

&lt;p&gt;After the last Hadamard on the top qubit, the relative phase between the two terms decides the outcome:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If &lt;strong&gt;f(0) = f(1)&lt;/strong&gt; (constant) the top qubit collapses to ±|+⟩, so the final H gives &lt;strong&gt;measure 0&lt;/strong&gt;.&lt;br&gt;
If &lt;strong&gt;f(0) ≠ f(1)&lt;/strong&gt; (balanced) it collapses to ±|−⟩, so the final H gives &lt;strong&gt;measure 1&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A single oracle query distinguishes constant from balanced, where any classical approach needs two. That one-query advantage is the seed of Deutsch-Jozsa, Simon's, and ultimately Shor's algorithm.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Part of the Quantum Series 2026. Originally published on &lt;a href="https://malcolmlow.com/2025/12/09/deutschs-algorithm-in-quantum-computing-the-4-cases/" rel="noopener noreferrer"&gt;Techucation&lt;/a&gt;, where the circuit diagrams are rendered in full.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>quantum</category>
      <category>qiskit</category>
      <category>algorithms</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Understanding Phase Kickback in Quantum Computing</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Sun, 07 Jun 2026 10:08:40 +0000</pubDate>
      <link>https://dev.to/malcolmlow/understanding-phase-kickback-in-quantum-computing-44en</link>
      <guid>https://dev.to/malcolmlow/understanding-phase-kickback-in-quantum-computing-44en</guid>
      <description>&lt;p&gt;In standard classical logic, a control bit dictates what happens to a target. In quantum mechanics the relationship is symmetric. When the target qubit is in an eigenstate of the gate operator, the eigenvalue phase is &lt;strong&gt;kicked back&lt;/strong&gt; onto the control qubit, leaving the target unchanged while flipping the relative phase of the control. This post derives that result from first principles using the CNOT gate on |+⟩ ⊗ |−⟩.&lt;/p&gt;




&lt;h2&gt;
  
  
  1 · The CNOT Circuit and the Kickback Setup
&lt;/h2&gt;

&lt;p&gt;The circuit places the control qubit in superposition |+⟩ and the target qubit in |−⟩. Since |−⟩ is an eigenstate of X with eigenvalue −1, the kickback occurs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;control:
|+⟩
|−⟩
target:
|−⟩
+
|−⟩
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key observation:&lt;/strong&gt; The target qubit is unchanged after the CNOT. The control qubit flips from |+⟩ to |−⟩. The phase was kicked back to the control, not forward to the target.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2 · Full Derivation: |+⟩ ⊗ |−⟩ through CNOT
&lt;/h2&gt;

&lt;p&gt;Step 1 — Define the initial state&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|ψ₀⟩ = |+⟩ ⊗ |−⟩
= (1/√2)(|0⟩ + |1⟩) ⊗ (1/√2)(|0⟩ − |1⟩)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2 — Expand the tensor product&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|ψ₀⟩ = (1/2)[ |00⟩ − |01⟩ + |10⟩ − |11⟩ ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3 — Apply the CNOT gate&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|ψ₁⟩ = (1/2)[ |00⟩ − |01⟩ + |11⟩ − |10⟩ ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4 — Factor and identify the result&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|ψ₁⟩ = (1/2)[ |0⟩(|0⟩ − |1⟩) − |1⟩(|0⟩ − |1⟩) ]
= (1/√2)(|0⟩ − |1⟩) ⊗ (1/√2)(|0⟩ − |1⟩)
= |−⟩ ⊗ |−⟩
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The target qubit is still |−⟩ — unchanged by the CNOT. The control qubit changed from |+⟩ to |−⟩. The −1 eigenvalue of the target has been kicked back as a relative phase onto the control.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  3 · Why Phase Kickback Matters
&lt;/h2&gt;

&lt;p&gt;The math shows that while we applied a gate to the target, the &lt;strong&gt;relative phase&lt;/strong&gt; of the control qubit changed from positive to negative. This is a structural property of controlled unitaries acting on their eigenstates, and it appears at the core of every major quantum algorithm.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Algorithm&lt;/th&gt;
&lt;th&gt;How phase kickback is used&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://malcolmlow.com/2025/12/09/deutschs-algorithm-in-quantum-computing-the-4-cases/" rel="noopener noreferrer"&gt;Deutsch’s Algorithm&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;The oracle kicks a −1 phase onto the control qubit to encode whether f is constant or balanced, extractable with a single H gate measurement.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://malcolmlow.com/2026/03/28/quantum-computing-inversion-about-the-mean/" rel="noopener noreferrer"&gt;Grover’s Algorithm&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;The oracle flips the sign of the target state’s amplitude by kicking a −1 phase back to the control register, enabling amplitude amplification.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shor’s Algorithm&lt;/td&gt;
&lt;td&gt;Quantum Phase Estimation relies entirely on phase kickback to transfer eigenvalue information from the target register to the control register.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The general rule:&lt;/strong&gt; for any unitary U with eigenstate |u⟩ (so U|u⟩ = eⁱᵖ|u⟩), a controlled-U gate with the control in superposition kicks the phase eⁱᵖ back to the control qubit. The target is unchanged.&lt;/p&gt;
&lt;/blockquote&gt;







&lt;p&gt;&lt;em&gt;Part of the Quantum Series 2026. Originally published on &lt;a href="https://malcolmlow.com/2025/12/09/understanding-phase-kickback-in-quantum-computing/" rel="noopener noreferrer"&gt;Techucation&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>quantum</category>
      <category>qiskit</category>
      <category>physics</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Quantum Computing From First Principles: Qubits, Hadamard Gates &amp; Why H^2 = I</title>
      <dc:creator>Malcolm Low</dc:creator>
      <pubDate>Sun, 07 Jun 2026 10:07:46 +0000</pubDate>
      <link>https://dev.to/malcolmlow/introduction-to-quantum-computing-qubits-hadamard-gates-and-superposition-139d</link>
      <guid>https://dev.to/malcolmlow/introduction-to-quantum-computing-qubits-hadamard-gates-and-superposition-139d</guid>
      <description>&lt;p&gt;&lt;em&gt;Part of the &lt;a href="https://malcolmlow.com/2026/06/26/quantum-computing-a-complete-learning-path/" rel="noopener noreferrer"&gt;Quantum Computing: A Complete Learning Path&lt;/a&gt; series.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;QUANTUM SERIES 2026&lt;/strong&gt; — Qubits, the Hadamard gate, superposition, tensor products, and quantum interference from first principles.&lt;/p&gt;

&lt;p&gt;Classical computers store information in bits that are always exactly 0 or 1. Quantum computers exploit the principles of quantum mechanics to do something fundamentally different: they operate on &lt;strong&gt;qubits&lt;/strong&gt;, which can exist in a superposition of both states simultaneously. The &lt;strong&gt;Hadamard gate&lt;/strong&gt; is the simplest gate that creates this superposition, and understanding it from first principles is the entry point to every quantum algorithm that follows.&lt;/p&gt;




&lt;h2&gt;
  
  
  1 . The Qubit
&lt;/h2&gt;

&lt;p&gt;A qubit is the fundamental unit of quantum information. Unlike a classical bit, a qubit can exist in a &lt;strong&gt;superposition&lt;/strong&gt; of |0&amp;gt; and |1&amp;gt; simultaneously. We write its general state using Dirac (bra-ket) notation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|ψ&amp;gt; = α|0&amp;gt; + β|1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here α and β are complex numbers called &lt;strong&gt;probability amplitudes&lt;/strong&gt;. They must satisfy the normalisation condition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|α|² + |β|² = 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two computational basis states are represented as column vectors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|0&amp;gt; = [1, 0]ᵀ      |1&amp;gt; = [0, 1]ᵀ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we measure the qubit in state |ψ&amp;gt; = α|0&amp;gt; + β|1&amp;gt;, we get |0&amp;gt; with probability |α|² and |1&amp;gt; with probability |β|². The act of measurement destroys the superposition and collapses the qubit to a definite classical state.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key distinction:&lt;/strong&gt; The superposition is not just ignorance about a hidden value. The qubit genuinely occupies both states until measured, and this physical reality is what quantum algorithms exploit.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2 . The Hadamard Gate
&lt;/h2&gt;

&lt;p&gt;The Hadamard gate H is a 2x2 unitary matrix that maps each computational basis state to an equal superposition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;H = (1/√2) [ +1  +1 ]
           [ +1  -1 ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Applying H to each basis state:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;H |input&amp;gt;&lt;/th&gt;
&lt;th&gt;Short name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;|0&amp;gt;&lt;/td&gt;
&lt;td&gt;(1/√2)( |0&amp;gt; + |1&amp;gt; )&lt;/td&gt;
&lt;td&gt;|+&amp;gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|1&amp;gt;&lt;/td&gt;
&lt;td&gt;(1/√2)( |0&amp;gt; - |1&amp;gt; )&lt;/td&gt;
&lt;td&gt;|-&amp;gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Both outputs have equal amplitudes of 1/√2, giving a 50% measurement probability for each outcome. The sign difference between |+&amp;gt; and |-&amp;gt; is what drives interference later.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Unitarity check:&lt;/strong&gt; H&lt;sup&gt;†&lt;/sup&gt; H = I. Since H is real and symmetric, H&lt;sup&gt;†&lt;/sup&gt; = H, so H² = I. The Hadamard gate is its own inverse.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  3 . H² = I: Quantum Interference
&lt;/h2&gt;

&lt;p&gt;Applying H twice to |0&amp;gt; returns the qubit to |0&amp;gt;. The algebra shows exactly why the |1&amp;gt; amplitudes cancel through destructive interference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;H(H|0&amp;gt;)
  = H( (1/√2)(|0&amp;gt; + |1&amp;gt;) )
  = (1/√2)( H|0&amp;gt; + H|1&amp;gt; )
  = (1/√2)( (1/√2)(|0&amp;gt;+|1&amp;gt;) + (1/√2)(|0&amp;gt;-|1&amp;gt;) )
  = (1/2)( |0&amp;gt; + |1&amp;gt; + |0&amp;gt; - |1&amp;gt; )
  = (1/2)( 2|0&amp;gt; )
  = |0&amp;gt;  [correct]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The +|1&amp;gt; and -|1&amp;gt; terms cancel completely (destructive interference) while the |0&amp;gt; terms add (constructive interference). This is the fundamental mechanism behind quantum algorithms: arranging amplitudes so wrong answers cancel and the correct answer survives.&lt;/p&gt;

&lt;h2&gt;
  
  
  4 . Single-Qubit Circuit: H-H-Measure
&lt;/h2&gt;

&lt;p&gt;A single qubit routed through two Hadamard gates and then measured always returns 0 with 100% probability:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;q_0: --[H]--[H]--[M]--
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;State&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Initialise&lt;/td&gt;
&lt;td&gt;|ψ_0&amp;gt; = |0&amp;gt;&lt;/td&gt;
&lt;td&gt;Ground state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. First H&lt;/td&gt;
&lt;td&gt;|ψ_1&amp;gt; = (1/√2)(|0&amp;gt;+|1&amp;gt;)&lt;/td&gt;
&lt;td&gt;Superposition: 50/50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Second H&lt;/td&gt;
&lt;td&gt;|ψ_2&amp;gt; = |0&amp;gt;&lt;/td&gt;
&lt;td&gt;Interference collapses back&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Measure&lt;/td&gt;
&lt;td&gt;Result = 0&lt;/td&gt;
&lt;td&gt;100% probability&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is a concrete demonstration that superposition is not just probabilistic noise. The deterministic outcome of 0 is only possible because the two Hadamard gates interact through interference, a purely quantum effect with no classical analogue.&lt;/p&gt;

&lt;h2&gt;
  
  
  5 . Tensor Products and Multi-Qubit States
&lt;/h2&gt;

&lt;p&gt;Multi-qubit systems are described using the tensor product (x). For two qubits, the four computational basis states are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Ket&lt;/th&gt;
&lt;th&gt;Tensor form&lt;/th&gt;
&lt;th&gt;Column vector&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;|00&amp;gt;&lt;/td&gt;
&lt;td&gt;|0&amp;gt; x |0&amp;gt;&lt;/td&gt;
&lt;td&gt;[1, 0, 0, 0]ᵀ&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|01&amp;gt;&lt;/td&gt;
&lt;td&gt;|0&amp;gt; x |1&amp;gt;&lt;/td&gt;
&lt;td&gt;[0, 1, 0, 0]ᵀ&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|10&amp;gt;&lt;/td&gt;
&lt;td&gt;|1&amp;gt; x |0&amp;gt;&lt;/td&gt;
&lt;td&gt;[0, 0, 1, 0]ᵀ&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|11&amp;gt;&lt;/td&gt;
&lt;td&gt;|1&amp;gt; x |1&amp;gt;&lt;/td&gt;
&lt;td&gt;[0, 0, 0, 1]ᵀ&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The tensor product of two vectors is computed by multiplying each element of the first vector by the entire second vector and stacking the results. For |0&amp;gt; x |1&amp;gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|0&amp;gt; x |1&amp;gt; = [1,0]ᵀ x [0,1]ᵀ = [0, 1, 0, 0]ᵀ = |01&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Dimension growth:&lt;/strong&gt; n qubits span a 2ⁿ-dimensional Hilbert space. A 3-qubit system already has 8 basis states; a 50-qubit system has 2⁵⁰ ~ 10^15, impossible to store classically.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  6 . Two-Qubit Superposition: HxH on |00&amp;gt;
&lt;/h2&gt;

&lt;p&gt;Applying independent Hadamard gates to both qubits starting from |00&amp;gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;q_0: --[H]--
q_1: --[H]--
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(HxH)|00&amp;gt;
  = (H|0&amp;gt;) x (H|0&amp;gt;)
  = (1/√2)(|0&amp;gt;+|1&amp;gt;) x (1/√2)(|0&amp;gt;+|1&amp;gt;)
  = (1/2)( |00&amp;gt; + |01&amp;gt; + |10&amp;gt; + |11&amp;gt; )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All four two-qubit basis states appear with equal amplitude &lt;strong&gt;1/2&lt;/strong&gt;. Each has measurement probability (1/2)² = &lt;strong&gt;25%&lt;/strong&gt;. This is the two-qubit analogue of the uniform superposition that opens algorithms like Grover's.&lt;/p&gt;

&lt;h2&gt;
  
  
  7 . Interference in a Two-Qubit H-H Circuit
&lt;/h2&gt;

&lt;p&gt;Applying HxH twice to |00&amp;gt; returns it to |00&amp;gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input to 2nd HxH&lt;/th&gt;
&lt;th&gt;After (HxH)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;|00&amp;gt;&lt;/td&gt;
&lt;td&gt;(1/2)( |00&amp;gt; + |01&amp;gt; + |10&amp;gt; + |11&amp;gt; )&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|01&amp;gt;&lt;/td&gt;
&lt;td&gt;(1/2)( |00&amp;gt; - |01&amp;gt; + |10&amp;gt; - |11&amp;gt; )&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|10&amp;gt;&lt;/td&gt;
&lt;td&gt;(1/2)( |00&amp;gt; + |01&amp;gt; - |10&amp;gt; - |11&amp;gt; )&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|11&amp;gt;&lt;/td&gt;
&lt;td&gt;(1/2)( |00&amp;gt; - |01&amp;gt; - |10&amp;gt; + |11&amp;gt; )&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Output state&lt;/th&gt;
&lt;th&gt;Amplitude sum (x 1/4)&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;|00&amp;gt;&lt;/td&gt;
&lt;td&gt;+1 +1 +1 +1&lt;/td&gt;
&lt;td&gt;4/4 = 1, constructive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|01&amp;gt;&lt;/td&gt;
&lt;td&gt;+1 -1 +1 -1&lt;/td&gt;
&lt;td&gt;0, destructive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|10&amp;gt;&lt;/td&gt;
&lt;td&gt;+1 +1 -1 -1&lt;/td&gt;
&lt;td&gt;0, destructive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;|11&amp;gt;&lt;/td&gt;
&lt;td&gt;+1 -1 -1 +1&lt;/td&gt;
&lt;td&gt;0, destructive&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Only |00&amp;gt; survives. This is the same interference structure that the &lt;a href="https://malcolmlow.com/2026/03/28/quantum-computing-inversion-about-the-mean/" rel="noopener noreferrer"&gt;Grover diffusion operator&lt;/a&gt; exploits at scale: constructive interference on the target state, destructive on all others.&lt;/p&gt;

&lt;h2&gt;
  
  
  8 . The HxH Matrix and Why It Matters
&lt;/h2&gt;

&lt;p&gt;The combined HxH operator is a 4x4 Walsh-Hadamard matrix (scaled by 1/2), the two-qubit case of the popcount rule derived in the &lt;a href="https://malcolmlow.com/2026/04/03/quantum-computing-the-walsh-hadamard-matrix-backbone-of-grovers-diffusion-operator/" rel="noopener noreferrer"&gt;Walsh-Hadamard post&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HxH = (1/2) [ +1  +1  +1  +1 ]
            [ +1  -1  +1  -1 ]
            [ +1  +1  -1  -1 ]
            [ +1  -1  -1  +1 ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every quantum algorithm that achieves a speedup over classical computation does so through the same three-phase structure:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Phase&lt;/th&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Open&lt;/td&gt;
&lt;td&gt;Hadamard on all qubits&lt;/td&gt;
&lt;td&gt;Create uniform superposition over all 2ⁿ states&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Operate&lt;/td&gt;
&lt;td&gt;Oracle / phase manipulation&lt;/td&gt;
&lt;td&gt;Mark or bias the amplitude of the target answer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Close&lt;/td&gt;
&lt;td&gt;Hadamard again (+ measurement)&lt;/td&gt;
&lt;td&gt;Interference concentrates probability on the answer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The bottom line:&lt;/strong&gt; the qubit and the Hadamard gate are the entry point to everything. Grover's O(√N) search, Shor's O((log N)³) factoring, and every other quantum speedup ultimately trace back to this interference mechanism operating at scale.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://malcolmlow.com" rel="noopener noreferrer"&gt;malcolmlow.com&lt;/a&gt;. Part of the Quantum Series 2026, built with Qiskit 1.x.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>quantumcomputing</category>
      <category>qiskit</category>
      <category>tutorial</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
