-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Quantum computing, at present, is largely an engineering and physics endeavor rather than a programming or logic one. This paper seeks to explain the mathematics of quantum computation to a computer science audience. This paper is centered around the java library JQuantum, which has several advantages to other methods of learning quantum computation. It is accessible to all programamers, and allows for repeatable, dependable, and efficient calculations involving complex states. This library implements numerous popular quantum algorithms that can be used alongside classical java code. Through an explanation of quantum algorithms and their possibilities, this paper seeks to put the emerging field of quantum computation in the hands of programmers such that can be better prepared for the large-scale implications of quantum computing once quantum hardware is widely available.
##Introduction:
For all of the far-reaching possibilities that quantum computing promises, programmers tend to know very little about it, through no fault of their own. Quantum computation is incredibly inaccessible and reliant on engineering and physics knowledge to learn. The literature on quantum computation is not particularly helpful at aiding this problem, as it uses circuit notation or physics descriptions of quantum states to explain algorithms. It is near impossible for a programmer to interface with a large-scale quantum system in an abstract manner to test ideas.
This paper explains the entirety of the mathematics of quantum programming through the use of the java library JQuantum. This paper serves as documentation for the library’s syntax and also provides a detailed description of some of the most popular quantum algorithms and their uses. JQuantum was designed with encapsulation, clarity, and scalability in mind, making it exceptionally easy to program with.
With the ability to efficiently test embedded quantum systems, I expect quantum computing to become a much easier field to learn and produce meaningful results from. In simplest terms, this paper is a one-stop shop for quantum computing, designed for programmers.
##Why Quantum Computing is Important:
Quantum computers are exceptional at solving optimization problems that require brute force (or a similarly inefficient algorithm) on classical computers. Several NP problems have been shown to be solvable in polynomial time by a quantum computer, although it is very unlikely that such a feat would be possible with an NP-complete problem. Among the problems that quantum computers have the capacity to solve more efficiently are factoring large composite numbers, searching for a value of a function, and problems concerning the output space of a function.
Such an ability is possible because of the quantum properties that quantum computation exploits. Quantum computers are in a gigantic superposition of all possible combinations of its bits, with varying coefficients. Quantum computation acts probabilistically to its core, allowing for quantum mechanics to provide solutions to problems that would otherwise require brute force classically.
Quantum computing is making headway, but is still in the early stages of development. As of 2018, the largest quantum computer has 72 qubits, the quantum equivalent of classical bits, and is owned by Google. This is hardly enough to perform any meaningful computation, let alone to outperform the super computers Google already has at its disposal. At the time being, quantum computation is also very unpredictable. Quantum computation is done with a large margin of error and quantum states spontaneously decay if unmeasured.
Quantum computing makes no pretense to attempt to replace classical computing or find solutions in a more deterministic way to classical computing. Quantum computing rather, abides by a completely foreign logical structure, which is useful on a select set of problems in reducing the complexity of algorithms.
I expect quantum computing to increase in prevalence dramatically in the coming years. The limitations of classical computation has become quite obvious to computer scientists and quantum computing opens a door to solve some unanswered questions. Most famously, quantum computing has the capability to break all of encryption technology used online today. For these reasons, it is very important that future computer scientists learn how to use these tools that are so powerful.
##The mathematics of quantum computing:
Quantum computing is defined through matrix math. States are represented as matrices which are operated on through matrix multiplication.
###States:
In classical computing, the states of the computer are limited to the binary combinations of the bits in the system. In quantum computing, the states of the computer are made up of a linear combination of all of these states, called basis states, simultaneously. Each basis state has a complex coefficient denoting its magnitude and phase. Quantum states are represented with kets, a symbol with a bar on the left, the state name in the middle, and a rangle on the right. Basis states can be represented as the binary equivalent of the state within the ket.
Fig 1: An example of a two qubit quantum state shown as a ket, and then as a linear combination of all two bit basis states. a, b, c, and d are complex coefficients of each of the basis states.
Quantum states are represented as tall matrices containing a complex coefficient for each basis state, in binary counting order. When measured, a quantum state must collapse into one of the basis states. This basis state is chosen probabilistically, with each basis state having a probability of the absolute square of the coefficient. All of the absolute squares of the coefficients therefore must sum to one.
Fig 2: diagram of the probability of a two qubit state being measured as any of the two bit basis states, based on the complex coefficients a, b, c, and d. This probability statement shows that the absolute squares of the coefficients must sum to 1.
###Gates:
In quantum computation, gates operate on one or more qubits to change their state. This operation is represented by a square unitary matrix of complex numbers that is the same height as the state (which is 2n where n is the number of bits in the state). A matrix is defined as unitary when its inverse is its conjugate transpose. The conjugate transpose operation performs a transpose flip on the matrix followed by taking the complex conjugate of all of the complex numbers in the matrix. This fact about unitary matrices allows quantum gates to easily be inverted through this operation. The conjugate transpose operation is generally denoted through a dagger symbol
Fig 3: the single qubit SQRT-NOT gate matrix put through the conjugate transpose operation is equivalent to it being inverted. This allows for the simple inversion of quantum gates.
Multiply a quantum gate to a state in order to apply it. Should the gate be smaller than the state it is being applied to, this multiplication must be done separately for every basis combination of non-operand qubits.
Fig 4: the application of the two qubit swap gate on a two qubit quantum state in order to produce a new quantum state.
Fig 5: the application of the single qubit NOT operation on the most significant bit of a two qubit state. This requires two multiplications of the gate matrix. The matrices within matrices are to be interpreted as groupings, showing on which states the gate is applied.
It is worth mentioning that the bra symbol, which looks like the opposite of a ket, with a langle on the left and a bar on the right, is representative of the conjugate transpose operation on a quantum state, creating a long matrix of opposite phase.
Fig 6: mathematical definition of the bra symbol.
##JQuantum implementation:
The QuantumState class handles all of the math of combination and simplification of states and application of gates. This class is entirely hidden from the user, and performs all of the mathematics behind the scenes. It is always most efficient for a quantum state to be split up, should some of the qubits not be entangled with one another so after every gate the quantum state attempts to simplify itself to perhaps split into multiple states. If a gate is applied onto qubits of different states, the two states are combined and the gate is applied to the newly created state. The QuantumState class also handles all measurement mechanics, and is the only class with access to the complex coefficients of any particular state. Because the complex coefficients are stored on a classical computer, the measurement math could be invoked without causing a collapse to a basis state for testing purposes. This operation is called a sample, and is one of the advantages of this system. This class is intentionally impossible to access through normal means as a way to abstract the processes such that the programmer can interface with the qubits directly and the math is done underneath. Each Qubit has a QuantumState delegate, which will be the same for entangled Qubits.
The QuantumGate class serves to store quantum gates as two dimensional arrays of complex numbers. The class comes with statically defined gates representing commonly implemented gates on quantum hardware. The class comes with a handy invert method which simply applies the conjugate transpose operation on the unitary matrix. The quantum gates and their respective matrices are listed in the documentation.
##Advantages of JQuantum:
JQuantum is scalable. Because the qubits are abstractly referenced, adding and removing qubits takes little effort. Any function can be written to use a variable amount of qubits decided at runtime. Unlike real quantum hardware JQuantum is designed to make qubits universally entangle-able. Quantum functions can be of any complexity or size, as the quantum states do not decay over time. The implementations of hardware are not the concern of the JQuantum programmer, such as the allocation of qubits. Qubits can also be entangled with any other qubit, as there is no nearest neighbor rule. The only limitation to the scalability of the system is the 32 bit size of java integers, forcing the maximum number of entangled qubits to 32.
JQuantum is accessible. Java is one of the most popular programming languages. JQuantum requires little to know prior knowledge in order to start toying with. All algorithms are explained in the javadocs in plain English. The installation is incredibly simple, as it is only a small java library. JQuantum also allows for the embedding of quantum code alongside classical code. No setup is required to begin programming in quantum. This allows for the two methods of computation to work in tandem. All quantum algorithms are written in code, with explanatory documentation, as opposed to with circuit notation.
JQuantum is encapsulated. JQuantum focuses on the possibilities of quantum computing but not on their nitty gritty details. This allows a programmer to simply program while having the library take control of the mathematics. Qubits in separate objects can be entangled behind the scenes, but to the programmer they can be treated as separate entities. JQuantum presents qubits just as classical computers present classical bits.
All calculations performed through JQuantum are reproducable and exact to double precision. JQuantum programs, unlike real quantum hardware, can be run with the expectation of accurate results, even when applying algorithms of high depth. Quantum registers can be remeasured, or even analyzed for probabilities.