Quantum Computing on Your Favorite Retro Computer

A quantum simulator for the Commodore 64, written in 200 lines of BASIC, performs quantum gate operations on a simulated two qubit system.

Nick Bild
10 months agoRetro Tech
A quantum simulator for the Commodore 64 (📷: Davide Gessa)

Quantum computers are a type of computing technology that leverage the principles of quantum mechanics to perform calculations. Unlike classical computers that use bits to represent information as either a 0 or 1, quantum computers utilize quantum bits, or qubits, which can exist in multiple states simultaneously thanks to a phenomenon known as superposition. This unique property of qubits allows quantum computers to perform computations on a vastly larger scale and solve complex problems more efficiently than classical computers.

The physical system that represents a qubit can be any entity that exhibits quantum properties, such as the spin of an electron or the polarization of a photon. The state of a qubit can be in a superposition of both 0 and 1, meaning it can simultaneously represent multiple states. For instance, a qubit can exist in a state that is 60% 0 and 40% 1, or any other combination of probabilities.

Quantum computers perform computations by manipulating the quantum states of qubits. Quantum gates, similar to classical logic gates, are used to manipulate the state of the qubits. These gates can change the probabilities of different states or entangle qubits together, creating complex relationships between them. Entanglement is a crucial property in quantum computing that allows qubits to become highly correlated, enabling quantum computers to process vast amounts of information in parallel.

Today’s quantum computer systems are highly experimental, expensive, and wholly impractical for nearly all real-world use cases, so very few people have had a chance to get their hands on one yet. That may be the case for many years to come, but in the meantime, why not fake it? Given the mystique surrounding these new systems, it is easy to forget that any problem that can be solved by a quantum computer can also be solved by a classical computer (and vice versa), as long as you give it enough time.

A software engineer by the name of Davide Gessa took this principle to an extreme in building a quantum simulator for the Commodore 64 computer from the 1980s. In 200 lines of BASIC, no less. This 8-bit computer running simulations in BASIC will not be setting any records for speed (in a positive way, at least), but this project is very instructive and takes some of the mystery out of quantum computing.

The program simulates the effects of a number of quantum gate operations on a two-qubit system. Supported operations include Pauli-X, Pauli-Y, Pauli-Z, Hadamard, CNOT, and SWAP. After the simulator starts up with a predefined initial state, the user is prompted to enter shorthand commands specifying which gate operations to apply to the qubits. The simulator will then run those operations for a defined number of iterations, during which the quantum state of the system evolves. When the computations are finished, the program provides the user with the distribution of the quantum states of the system.

No, you will not be solving any cryptographic or optimization problems with the Commodore 64 quantum simulator, but you might gain some insights into the probabilistic nature of quantum mechanics and learn a thing or two about quantum computers on a much simpler hardware platform. And of course, running quantum simulations on a Commodore also makes for some great conversations around the water cooler. The BASIC source code is available on GitHub if you want to give it a try on your own machine (or emulator).

Nick Bild
R&D, creativity, and building the next big thing you never knew you wanted are my specialties.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles