We guide a competent programmer through the programming of a quantum circuit simulator, supporting quantum logic gates with arbitrary control qubits on 20+ qubits, assuming no previous knowledge of quantum computing. We explain qubit-wise multiplication for updating the state vector; how to compute partial traces on arbitrary subsets of qubits to find reduced density matrices; and computing qubit phase and purity. A sample implementation in JavaScript is provided, which also demonstrates how to compute von Neumann entropy, concurrence (to quantify entanglement), and magic, with source code much smaller and easier to study than other popular software packages.
We guide a competent programmer through the programming of a quantum circuit simulator, supporting quantum logic gates with arbitrary control qubits on 20+ qubits, assuming no previous knowledge of quantum computing. We explain qubit-wise multiplication for updating the state vector; how to compute partial traces on arbitrary subsets of qubits to find reduced density matrices; and computing qubit phase and purity. A sample implementation in JavaScript is provided, which also demonstrates how to compute von Neumann entropy, concurrence (to quantify entanglement), and magic, with source code much smaller and easier to study than other popular software packages.
Abstract This practical guide provides a detailed introduction to quantum logic gates and unitary operators as implemented on the IBM Q platform. It focuses on the fundamental gate structures used in quantum programming, particularly within the Composer interface, and provides screenshots and detailed descriptions of each operator’s functionality. The guide emphasizes the operational role of gates in controlling qubit states and constructing quantum circuits. To enhance understanding, the behavior of gates is visualized on the Bloch sphere, demonstrating how single-qubit operations rotate qubit states around the XXX, YYY, and ZZZ axes, as well as how phase shifts and amplitude adjustments modify the qubit. These operations are essential for measurement, state preparation, and precise manipulation of quantum systems. The relevance of this study is underscored by the rapid development of quantum technologies and the increasing accessibility of quantum computing platforms like IBM Q. A thorough understanding of quantum gates and their implementations is critical for advancing quantum algorithm design and for training specialists capable of deploying quantum computational solutions in fields ranging from cryptography to complex physical system simulations. This guide provides both theoretical insights and practical exercises, bridging the gap between abstract quantum mechanics and applied quantum programming, thereby equipping readers with foundational skills for effective circuit construction and quantum computation.
This chapter introduces the fundamental concepts and rules of quantum computing. In parallel, it develops an initial, easy-to-understand codebase in Python for building and simulating small-scale quantum circuits and algorithms. The chapter details single qubits, superposition, quantum states with many qubits, operators, including a sizable set of important single-qubit gates and controlled gates. The Bloch sphere and the quantum circuit notation are introduced. Entanglement follows, that fascinating “spooky action at a distance,” as Einstein called it. With this background, the chapter discusses maximally entangled Bell states, the no-cloning theorem, the noneffect of global phases, the partial trace and reduced density matrix, and uncomputation. The quantum postulates are discussed in a nonphilosophical way, leading to measurement and how to simulate it.
We start this chapter by reviewing how quantum states and spaces are described with Dirac notation. We then examine qubits, the quantum memory bits, and the states formed with multiple qubits. We next discuss quantum gates and their low-level processing of qubits. And, at last, we get on to quantum programming and QC applications. We explore the use of several software packages that simulate QC, or provide the programs to run on quantum computers. We explore an example of the latter using the IBM Quantum Platform. The assortment of examples and problems that follow includes simple circuits, Monte Carlo techniques, Schrödinger's cat, and quantum Fourier transforms.
Existing graphical user interfaces for circuit simulators often show small visual summaries of the reduced state of each qubit, showing the probability, phase, purity, and/or Bloch sphere coordinates associated with each qubit. These necessarily provide an incomplete picture of the quantum state of the qubits, and can sometimes be confusing for students or newcomers to quantum computing. We contribute two novel visual approaches to provide more complete information about small circuits. First, to complement information about each qubit, we show the complete state vector, and illustrate the way that amplitudes change from layer-to-layer under the effect of different gates, by using a small set of colors, arrows, and symbols. We call this “state vector difference highlighting”, and show how it elucidates the effect of Hadamard, X, Y, Z, S, T, Phase, and SWAP gates, where each gate may have an arbitrary combination of control and anticontrol qubits. Second, we display pairwise information about qubits (such as concurrence and correlation) in a triangular “half-matrix” visualization. Our open source software implementation, called MuqcsCraft, is available as a live online demonstration that runs in a web browser without installing any additional software, allowing a user to define a circuit through drag-and-drop actions, and then simulate and visualize it.
Applying controlled unitary gates to generate entanglement between qubits is a routine task in both quantum communication and computation. The existing tools for predicting how much entanglement a given gate can generate require either simulation of the entangling circuit or averaging over a distribution of inputs for a given controlled unitary gate. Here, we introduce a computable quantity ζ that not only determines whether a controlled unitary gate generates entanglement, but also quantifies the entanglement for any specific input without requiring the construction of the output state. For two-qubit controlled unitary gates, we establish the physical conditions corresponding to the extremum values of the proposed quantity. Extending the dimension of control and target registers to arbitrary size through a generalized controlled unitary architecture, we derive a universal upper bound on ζ and identify the conditions for its saturation. Later we establish functional relation between the quantity and other known quantities, such as purity, normalized linear entropy, and von Neumann entropy. Finally, we compare our results with previous research work and show that the quantity proposed in this work achieves the previously known optimal values of entangling power of controlled unitary gates for some specific dimensions of target and control registers.