Fractal animations with quantum computing on a Raspberry Pi

Qiskit
Qiskit
Published in
4 min readNov 22, 2022

By Wiktor Mazin, Jan-Rainer Lahmann, Emil Reinert and Bengt Wegner

Creators are increasingly using Qiskit to make works of quantum art. And, combined with the Raspberry Pi, you have a unique platform to create portable installations beyond the realm of your laptop.

For this project, Wiktor Mazin, Jan-Rainer Lahmann, Emil Reinert and Bengt Wegner teamed up to demonstrate quantum fractals on the Raspberry Pi. We hope to show how to get creative with quantum computers thanks to the portability and ease-of-use of the RasQberry project, while providing a short guide on how you can create your own fractal animations using python code with Qiskit, both via a direct link and via an install on a Raspberry Pi.

We envision fractal animations on the Raspberry Pi to serve as a localized quantum computing fractal exploration space. We hope this platform will awaken you to the creative possibilities of quantum computing, and perhaps to provide a concrete means to produce demonstrations, art installations, and other artistic projects requiring portability.

Fractals, complex numbers and quantum computing

Fractals are visually stunning and have long been a field of interest and exploration among mathematicians, artists, psychologists, neuroscientists, and authors. They comprise amazing shapes like Romanesco broccoli, snowflakes, crystals, DNA, tree branches, and more. You can read about previous work creating fractal art with Qiskit here.

Fractals are images that display distinct structure at all scales, and the most striking ones often contain self-similarity, where images seem to repeat as you zoom in or out. Research into complex numbers has revealed that plotting certain formulas on the complex plane generates distinct fractal patterns. For instance, Julia sets are a simple kind of fractal which iteratively update the value of z in the formula z = z² + c, with z being a point on the complex plane and c being a chosen complex constant.

We first made the connection between fractals and quantum computing because both rely intimately on complex numbers, which are a necessity in order for quantum theory to accurately describe nature. Previous work demonstrates how we can use the complex amplitudes of state vectors as the complex constant to create Julia set fractals. More recently, with Julia set mating it’s possible to better leverage both amplitudes of a single qubit. As an example, you may paste Julia sets together via the rational function f(z) = (z² + c1)/( z² + c2), with c1 and c2 representing both of the statevector’s complex amplitudes. More info on fractals created with Julia set mating can be found in a previous blog.

Fractal animations with Qiskit

We began creating animations with these quantum computer-generated fractals in order to give viewers a new way to visualize the evolution of quantum information in a circuit as the incremental change of the fractal shape. The fractal demo animation you can create, with instructions below, portrays quantum superposition changing over the course of a 1-qubit quantum circuit. It begins with a Hadamard gate, and then you can see how 60 rotations around the Z axis (RZ gate) from the left relate to the Bloch sphere plus animations generated with one complex number and the visual expressions of fractals resulting from the variations of Julia set mating described in the previous blog.

Create your own fractal animations

1. Use a online interactive notebook in your browser — No installations required

You can follow this link to a MyBinder Quantum Fractal Guidebook, which allows one to run the code with the preset values, and experience the result of what is described in the section above. You can change the parameters at your will in the “parameter” code cells, and run the rest of the code to see which kind of fractals you can achieve.

2. Install on a Raspberry Pi

The fractals can also be generated on a Raspberry Pi by using the RasQberry project, which brings Qiskit to Raspberry Pi bundled with multiple quantum demos. All you need is a Raspberry Pi, preferably a model 4, running the latest version of Raspberry Pi OS. Find instructions on how to install RasQberry here.

After the initial install and running the One-Click-Install, you are ready to start the fractal demo. Find it under Quantum Demos. Make sure to have a display connected and have the terminal running on this display. After a short time the fractals will be opened in a browser window and you can watch them being generated. Find the generated GIF under RasQberry/demos/bin/fractal_files.

The RasQberry also supports an autostart option, which automatically starts the fractals demo on startup. Therefore, generating quantum fractals on a Raspberry Pi is as easy as plugging in a cable.

Feel free to contribute to the RasQberry project on GitHub or propose changes and additional features.

--

--

Qiskit
Qiskit

An open source quantum computing framework for writing quantum experiments and applications