1
| What Is Quantum Computation?

Welcome to the first lesson of this course. We start by briefly revisiting classical computation through clear, hands-on examples, then shift to the quantum realm where you will explore a few foundational quantum circuits. Each example comes with accompanying code; if it does not all make sense right away, that's expected — as we progress, you will gradually build both your understanding of quantum concepts and your coding skills.

Key Concepts

◼
  • Quantum circuit
  • ◼
  • Qubit
  • ◼
  • Measurement
  • ◼
  • Superposition
  • ◼
  • Computational basis
  • Classical Computation

    In order to understand quantum computation, it helps to compare it to classical computation. To compute something, you have to be able to use rules to determine the output from a list of inputs. You can think of computing as starting with the inputs and following the rules to reach an output.
    Consider two binary numbers
    "01"
    and
    "10"
    , and let's see how we can add them. First, each bit-string is interpreted as a base-2 number rather than ordinary decimal, so
    "01"
    becomes one and
    "10"
    becomes two.
    Define the binary strings:
    In[]:=
    a="01";b="10";
    Construct the number from the base-2 digits of
    a
    :
    In[]:=
    FromDigits[a,2]
    Out[]=
    1
    Construct the number from the base-2 digits of
    b
    :
    In[]:=
    FromDigits[b,2]
    Out[]=
    2
    Add the numbers with ordinary addition:
    In[]:=
    FromDigits[a,2]+FromDigits[b,2]
    Out[]=
    3
    Convert the total back into a bit-string:
    In[]:=
    IntegerString[FromDigits[a,2]+FromDigits[b,2],2]
    Out[]=
    11
    Now let's add two binary strings
    "101"
    and
    "011"
    :
    In[]:=
    a="101";b="011";​​IntegerString[FromDigits[a,2]+FromDigits[b,2],2]
    Out[]=
    1000
    Pay attention to the string length of the initial numbers and the final total. The original bit-strings have length 3, but the answer is a four-bit string. Let's dive in a bit more.
    What are all the states of a sequence of three classical bits?
    In[]:=
    threeBits=Tuples[{0,1},3]
    Out[]=
    {{0,0,0},{0,0,1},{0,1,0},{0,1,1},{1,0,0},{1,0,1},{1,1,0},{1,1,1}}
    What are the corresponding numbers from those base-2 digits?
    In[]:=
    FromDigits[#,2]&/@threeBits
    Out[]=
    {0,1,2,3,4,5,6,7}
    With a 3-bit string you can represent
    0
    –
    7
    ; in general,
    n
    bits represent
    0
    to
    n
    2
    -1
    . Adding
    101
    and
    011
    gives 8, which exceeds the 3-bit range. This means in-place addition is modulo
    n
    2
    , so the sum wraps to
    000
    unless you provide an extra bit to capture the carry.
    If you stay within 3 bits, perform all operations modulo 8 (wrap-around arithmetic):
    In[]:=
    Mod[FromDigits[a,2]+FromDigits[b,2],2^3]
    Out[]=
    0
    Then the 3-bit string of that result is:
    In[]:=
    IntegerString[0,2,3]
    Out[]=
    000
    It is also possible to encode information in such sequences of classical bits to represent problems of interest. For example, each of those bit sequences could also encode a letter character:
    In[]:=
    FromLetterNumber[FromDigits[#,2]]&/@threeBits
    Out[]=
    { ,a,b,c,d,e,f,g}
    With yet another encoding scheme, those same bit sequences could represent colors with opacity:
    In[]:=
    Apply[RGBColor,#]&/@threeBits
    Out[]=
    
    ,
    ,
    ,
    ,
    ,
    ,
    ,
    
    Having seen how a 3-bit register cleanly enumerates eight distinct states and how different encodings map those states to numbers, letters, or colors, we now move to the quantum setting. There the same eight basis strings exist, but a 3-qubit register can also occupy complex superpositions of them, and even entangled combinations that have no classical analogue. The rules for storing and extracting information therefore change: measurement reveals a single basis outcome, while computation exploits interference among amplitudes.

    Quantum Circuits and Qubits

    Now we dive directly into quantum computation. We introduce common terms and concepts widely used in quantum information. Some details are only briefly mentioned; for each topic we highlight what to focus on for a first exposure, and later we return to expand on each concept in more depth.
    The diagram below represents an example of a quantum circuit:
    In[]:=
    qc=QuantumCircuitOperator[{​​"H","Z"->2,"Y"->3,"P"[Pi/4],​​"CNOT"->{1,3},"RY"[Pi/3]->2,"CH"->{2,3},Range[3]​​}];​​qc["Diagram"]
    Out[]=
    Notice how the circuit diagram has several wires, labeled
    c
    ,
    1
    ,
    2
    and
    3
    . Wires
    1
    ,
    2
    and
    3
    represent qubits (quantum bits) instead of classical bits. This is a 3-qubit system, meaning that the state can be described in the complex vector space
    8
    C
    . The previous eight classical bits can form a convenient basis (usually called the computational basis). Those 3-bits in quantum are represented by wrapping them around a notation
    Ket[{…}]
    which is called a ket. In general, a ket is a shorthand representation of a complex-valued vector. A general 3-qubit state is a complex linear combination of those eight basis states.
    A quantum circuit is read from left to right. The first operation — represented by the blue box labeled H — acts only on the first wire, while some operations act on more than one wire; they are multi-qubit gates. The boxes that look like gauges on the right represent measurement and point to the wire labeled
    c
    . The wire labeled
    c
    represents a classical system (such as part of a regular computer) where the results of the measurements on qubits are stored. All operations shown except measurements are unitary and reversible, a key feature we explore in more detail later. You can think of each box as performing a transformation on the quantum state of one or more wires. These transformations must obey fundamental principles dictated by quantum theory.
    What are the results of running this circuit? Since measurements are included at the end, executing the circuit returns a quantum measurement object in the Wolfram Quantum Framework. This object contains the probability distribution over possible bitstrings and can be sampled to generate measurement outcomes:
    In[]:=
    measurements=qc[]
    Out[]=
    QuantumMeasurement
    Target: {1,2,3}
    Measurement Outcomes: 8
    
    Note that by executing the code above we performed a quantum computation — but it was carried out on a classical computer (your PC). This is exactly what a quantum simulator does: it mimics quantum behavior and performs computations using the rules of quantum mechanics, all within classical hardware.
    What are the results of the measurement in this circuit?
    In[]:=
    measurements["ProbabilitiesPlot"]
    Out[]=
    Notice that the possible outcomes of a quantum measurement are simply classical bit sequences. In the earlier classical computation examples, the rules were deterministic: each input led to a definite output. In contrast, quantum computation typically yields a range of possible outcomes, each with a certain probability. This is because quantum theory provides a probabilistic description of measurement results, with the distribution determined by the state just before measurement (and the chosen measurement basis).
    For a quantum program to be useful, you arrange things so that the probability of measuring a result that encodes a desired solution to your problem is high.
    Additionally, you can track how the quantum state evolves as gates are applied. Although we have not yet discussed the state in full detail, for now focus on the linear combination of computational-basis bitstrings and examine the amplitude of each term. These amplitudes update linearly under gates, and their squared magnitudes determine the probabilities of the corresponding bitstrings upon measurement.
    In[]:=
    Grid[​​Prepend[​​Transpose[{​​{"Initial","H","Z","Y","P[π/4]","CNOT","RY[π/3]","CH","Measurements"},​​TraditionalForm/@FoldList[#2[#1]&,QuantumState["000"],qc["Operators"]]​​}],​​Style[#,Bold]&/@{"Step","State"}​​],​​Frame->All,Alignment->Left​​]
    Out[]=
    Step
    State
    Initial
    |000〉
    H
    1
    2
    |000〉+
    1
    2
    |100〉
    Z
    1
    2
    |000〉+
    1
    2
    |100〉
    Y
    
    2
    |001〉+
    
    2
    |101〉
    P[π/4]
    
    2
    |001〉+
    
    π
    4
    
    2
    |101〉
    CNOT
    
    2
    |001〉+
    
    π
    4
    
    2
    |100〉
    RY[π/3]
    1
    2
    
    3
    2
    |001〉+
    
    2
    2
    |011〉+
    1
    2
    
    3
    2
    π
    4
    
    |100〉+
    
    π
    4
    
    2
    2
    |110〉
    CH
    1
    2
    
    3
    2
    |001〉+
    
    4
    |010〉-
    
    4
    |011〉+
    1
    2
    
    3
    2
    π
    4
    
    |100〉+
    1
    4
    
    π
    4
    
    |110〉+
    1
    4
    
    π
    4
    
    |111〉
    Measurements
    0000,001
    3
    8
    ,010
    1
    16
    ,011
    1
    16
    ,100
    3
    8
    ,1010,110
    1
    16
    ,111
    1
    16
    
    Keep in mind that, in the end, the most important information we extract from a quantum system is its measurement results (and their statistics). We will discuss this in more detail in future chapters.
    Counting outcomes in a small circuit. Apply a Hadamard to a single qubit in the register state, then measure in the computational basis. What is the probability of each outcome?
    ​
    Vocabulary
    Exercises
    Solution
    Solution
    Solution
    The circuit produces an equal superposition and then measures, so the outcomes should be roughly 50/50.
    Q&A
    Why does the same quantum circuit not always return the same answer?
    Quantum measurement is intrinsically probabilistic. Unless the pre-measurement state happens to coincide with one of the measurement basis states, the outcome is drawn from a distribution determined by the state's amplitudes. Repeating the circuit (often called shots) lets you estimate that distribution.
    Is the simulator doing real quantum mechanics or just bookkeeping?
    Bookkeeping — but the bookkeeping follows the exact rules of quantum theory. The simulator carries the full state vector (or density matrix) and applies the gates as linear operators on a classical computer. A real quantum processor produces the same probability distribution physically; the simulator computes that distribution numerically.
    Tech Notes
    More to Explore
    Wolfram Quantum Framework documentation
    Wolfram U: Introduction to Linear Algebra
    Quantum Computation Framework GitHub
    Summary
    In this chapter you saw how classical bits are interpreted as base-2 digits, encoded as numbers, letters, or colors, and saw the bit-width constraint that forces in-place addition to be modular. We then introduced the quantum analogue:
    A quantum circuit is a sequence of unitary operations and (optionally) measurements applied to one or more qubits.
    A qubit's state is a complex linear combination of the computational basis states, and the squared amplitude of each basis term is the probability of obtaining that bitstring on measurement.
    Measurement in the computational basis returns a classical bitstring; the distribution of outcomes is what carries the result of a quantum computation.
    A quantum simulator computes the rules of quantum theory on classical hardware, so the output bitstrings have the same statistics as a real quantum processor would produce.
    References
    M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th Anniversary Edition, Cambridge University Press, 2010.
    S. Aaronson, Quantum Computing Since Democritus, Cambridge University Press, 2013.
    Wolfram Research, Wolfram Quantum Framework, paclet documentation, accessed 2026. <https://www.wolfr.am/DevWQCF>

    Initialization

    Install the Wolfram Quantum Framework: