Deutsch's Algorithm on a Quantum Computer

In 1985, David Deutsch [1] proposed a highly contrived but simple algorithm to explore the potentially greater computational power of a quantum computer as compared to a classical computer. Consider four possible functions of a single-bit (or basis qubit) or , which produce a single-bit result or , as follows: , , , . The first two functions are classified as "constant" (with ), while the latter two are described as "balanced" (with ). Suppose now that a classical computer, idealized as a "black box", can perform the computation .
To determine whether is constant or balanced on a classical computer, it is necessary to run the program twice, with inputs and , respectively. For example, with the input , suppose we find . Then can be either or . We need a second run with to determine which alternative is correct. By contrast, a 2-qubit quantum computer can find the result in a single operation—one shot instead of two.
As shown in the graphic, a black box performing one of the four functions is built into the quantum computer circuit. Our objective is to determine whether this function is constant or balanced. The two qubits and (which can be abbreviated as the quantum state are input, and the program is executed. The first exit qubit is measured, which collapses it to a classical bit 0 or 1. Very directly, 0 indicates that is constant while 1 indicates that it is balanced. The second exit qubit can be discarded.
You can select one of the four possible functions and run the quantum-computer program. The quantum state of the two-qubit system at each stage of the computation is exhibited, colored in red.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


The Hadamard gate transforms the basis qubits into superpositions as follows: ,
)/. The Deutsch gate carries out the following action, showing the incoming and outgoing qubits:
Here represents the exclusive or (XOR) Boolean operation on the bits and . The above would be a CNOT gate if .
In a generalization to qubits, known as the Deutsch–Jozsa algorithm, a single query on a quantum computer can find a result that would require up to the of order queries on a classical computer. Similar fragmentary results show promise of possible exponential gains in computational power using a quantum machine.
[1] D. Deutsch, "Quantum Theory, the Church–Turing Principle and the Universal Quantum Computer," Proceedings of the Royal Society of London A, 400, 1985 pp. 97–117.
[2] G. Fano and S. M. Blinder, Twenty-First Century Quantum Mechanics: Hilbert Space to Quantum Computers, Berlin: Springer, 2017, Sect. 6.5.
[3] "Deutsch's Algorithm." (Apr 28, 2017) www.cs.xu.edu/~kinne/quantum/deutche.html.
[4] M. A. Nielson and I. L. Chuang, Quantum Computation and Quantum Information, Cambridge: Cambridge University Press, 2010. doi:10.1017/CBO9780511976667.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2018 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+