Computing With Ellipses
22 May 2018


This project is about using analog electronics and the mathematics of elliptical states and operators to perform computation. The goal of this project is the creation of a simple table-top device that can perform general operations on 1-bit and 2-bit elliptical states. Ideally, this will pave the way for the creation of devices that can perform operations on 4-bit, 8-bit, and larger states.

  1. 1-bit state preparation and detection
  2. Standard 1-bit operators: X, Y, Z, and H
  3. Operator building-blocks: -i and +i phase filters
  4. Generic 1-bit operators: from X, Y, and Z
  5. Generic 1-bit operators: in two octants
  6. Generic 1-bit operators: in other octants
  7. 2-bit state preparation and detection
  8. 2-bit operators

1-bit states

A 1-bit "elliptical" state is different from a conventional, or "binary" bit. Whereas a binary bit can take on only two discrete values (0 and 1), a state is a 2-dimensional object that can take on a continuous range of values in addition to 0 and 1. These objects can be represented as:

A point on the computational sphere

The computational sphere is a normal 3d sphere like the surface of the Earth. Sometimes it has different names like Poincare or Bloch. This sphere has lines of latitude and longitude like the Earth, but these angles are called psi and chi instead. The computational sphere has the following properties:

  1. Every 1-bit state is a distinct point on the sphere at coordinates {psi, chi}.
  2. The psi angles start at the H axis and go from 0 to pi (rather than 2 * pi) anti-clockwise around the G axis.
  3. The chi angles start at the R axis and go from -pi/4 to pi/4 (rather than from -pi/2 to pi/2) toward the G axis.
  4. The H, V, D, and A axes are historically named after the horizontal, vertical, diagonal, and anti-diagonal polarizations of light, and the names have stuck.
  5. The G and R axes are sometimes named right and left (or vice-versa depending on the text), but I use the names green and red instead.
  6. Antipodal points on the sphere are orthogonal states (more about that later).
  7. Each pair of antipodal points defines a computational axis. The two endpoints of these axes are labeled +1 and -1, or 1 and 0.
  8. The two endpoints of each computational axis are called a basis for the sphere.
  9. Every point on the sphere, that is every 1-bit state, can be represented as a combination of any pair of basis states of the form c1 * b1 + c2 * b2 where b1 and b2 are the basis states and c1 and c2 are any complex numbers such that their sum of squared magnitudes is equal to 1. By convention, the phase of c1 is set to zero so that only the phase difference between c2 and c1 is important.
  10. All states on the sphere have a magnitude (length) of 1.
  11. All complex multiples of a state (= c * s for any state s and complex number c) are the same state. This includes the multiples -1 * s, i * s, and -i * s, among infinitely many others. Strictly speaking, a state is an infinite equivalence class of complex vectors, where the normalized vector (with mag = 1 and phase of first element = 0) is chosen as the representative of the class.
A 2-d ellipse

Every state on the computational sphere corresponds to an ellipse of a specific orientation, eccentricity, and sense (green or red). Hence the name "elliptical" state. There are many images on the web showing the locations of these ellipses across the sphere. The equator contains all degenerate (no area) ellipses of different orientations corresponding to the angle psi. These are also referred to as linearly polarized states. This orientation repeats itself every pi radians, rather than 2 * pi, because there is no "arrowhead" to the major axis of the ellipse. This is why the angle psi only ranges from 0 to pi in one full turn around the GR axis. States above or below the computational equator have eccentricities that approach 0 at the G and R poles. These are also referred to as circularly polarized states. All states above the equator are green, all those below it are red. Linear states are shown in yellow.

Or two cosine signals

Every 1-bit state can also be represented as a vector of 2 complex numbers. This is the actual mathematical representation used in calculations. These two numbers are historically called the H and V components of the state, and represent the state using the HV axis of the computational sphere as a basis. This vector can be depicted by two parallel cosine signals of different magnitudes and phases. Again by convention, the phase of the first signal is set to zero so that only the phase of the second signal with respect to the first matters. A cosine signal is chosen because the convention for complex numbers is to set the phase to zero on the X axis of the complex plane (at 1 on the unit circle) and have it increase anti-clockwise around the origin (so that the phase of i is pi/2, etc...). In the ellipse plot above, these two signals control the X and Y locations of the curve. The green dot shows the zero phase point (left edge of signals, maximum of X value), and the green color (sense) indicates that the curve orbits clockwise around the center. Red ellipses orbit anti-clockwise around the center.

In this project, the physical representation of every 1-bit state is as two continuous voltage signals in an analog electronic circuit. The magnitudes and phase difference of these signals can be set as input, by computer, in the electronics. All further computational processing is then performed on these signals within the electronics. The result of this processing, also a pair of signals, is sent back to the computer for analysis, as output.

You can play with a 1-bit object in magnitude/phase form in some old Javascript code here. By moving the sliders, you can create every 1-bit state on the computational sphere. Vary the V-phase to move the state around the HV axis. Vary the V- and H-magnitudes to move the state along the HV axis.

A 1-bit state can also be represented as a point (actually an infinite set of points) within a simple 3-d optical system called the computational dipole.

The overall process of computation consists of 3 steps:

  1. State preparation: generating the signals necessary to represent a specific state,
  2. State evolution: the sequence of operations performed on that state (the actual computation), and
  3. State detection: analyzing the resulting signals to determine the outcome of the computation.

1-bit state preparation

This part of the process generates the two DC analog voltage signals that represent a particular {psi, chi} point on the computational sphere. The {psi, chi} coordinates are first entered into a graphical C program (GCC 4.8.4, GTK 3.10.8) running on a Linux computer (Ubuntu 14.04, 64-bit, quad-core Intel i5 at 3.3 GHz), which creates a simple binary program that is sent to a digital microcontroller board, which generates two streams of binary signals (0 and 5 volts only), which then pass through a binary optical coupling device to the analog electronics, where they are finally filtered to produce accurate cosine signals of specific magnitudes and phases.

C program

With this program one sets the magnitudes and phases of the two H/V-basis analog signals by using the sliders or by selecting one of the canonical points of the sphere (H, V, D, A, G, and R). Random points on the sphere can also be generated. Each pair of signals (normalized to an overall magnitude of 1 and with an H phase of 0) corresponds to a specific {psi, chi} point on the sphere. The two mathematical curves are then used to generate a short program that controls the binary pin values (0 and 5 volts) of two pulsed signals (see below) that will interface the state to the analog electronics. This control program consists of commands for the specific pin states (low/high) and also microsecond delays between pin settings. For example:

288 bytes:

P1   P2   usecs-delay
--   --   -----------
 1    1   177
 1    0   477
 0    0   55
 1    1   196
 1    0   453
 0    0   61
 1    1   220
 1    0   411
 0    0   78
 1    1   250
 1    0   353
 0    0   106
 1    1   284
 1    0   282
 0    0   143
 1    1   321
 1    0   200
 0    0   189
 1    1   359
 1    0   110
 0    0   241
 1    1   397
 1    0   15
 0    0   297
Microcontroller program

The microcontroller board used for state preparation is a Sparkfun Redboard. This board contains an Atmel AVR ATMega328p MCU running at 16 MHz, peripheral digital electronics, and a USB interface to the computer. This MCU is programmed using the Arduino software environment, which is based on the GCC toolchain. A very simple C++ program running on the AVR reads incoming serial communication from the computer (the pin programs described above) for each desired state and then repeatedly cycles through the two output pin settings (which are binary pulses) to generate that state. In the image above, digital pins 8 and 9 (at top) are the outputs.

Digital electronics

The other digital electronics consist of two 4N25 binary optical couplers and two SN74LS06 hex inverter buffers. The purpose of these devices is to isolate the digital electrical system from the analog electrical system. The inverters are required because the output of the optical coupler is also inverted (high<-->low). In the image above, the digital inputs are at bottom, and the analog outputs at right. The signals sent through these devices consist of binary pulses of varying width. The width of each pulse corresponds precisely to the time-varying value of the mathematical curve defined in the C program above (i.e. wider pulses for larger voltage values, etc...). These pulses are played over and over to generate each period of the signal. A typical output is shown below:

Analog electronics

The analog signals begin on the ouput side of each inverter shown above. Each channel (upper and lower parts of the circuit) is then passed through 4 buffered low-pass RC filters (from left to right). Typical outputs at each stage of this filter chain are shown below:

The last display above shows an average of the output over time, to reduce noise. The resulting signals are fairly accurate cosines at a frequency of about 42 Hz. These signals have the relative magnitudes and phase difference required to represent a specific 1-bit state.

1-bit state detection

Analog electronics

At present there is no further processing of the analog signals before state detection. Once state preparation and detection have been calibrated, one or more operators will be applied to input states before detection, so that quantitative differences between inputs and outputs can be observed and recorded. The resulting signals leave the analog electronics through two IL300 linear optical couplers. In the image above, the analog inputs are at bottom, and the digital outputs are at top. At this point the signals have become part of the digital electrical circuit, but they still have continuous values.

Digital electronics

The outputs of each IL300 are buffered by an op-amp, and then sent to two of the analog input pins of another Sparkfun Redboard. The AVR has an onboard analog to digital converter which estimates the time-varying value of each signal and makes it available to another C++ program running on the MCU.

AVR program

This is another very simple C++ program also written using the Arduino software environment. It acquires the value of each signal as an integer from 0-1023 as fast as possible (using the Arduino analogRead() function), and sends a binary array of values (256 samples per channel for two channels) back to the computer several times a second via USB.

C program

This graphical program reads the acquired data from the serial port and performs the processing steps necessary to transform it back into {psi, chi} coordinates on the computational sphere. These steps include:

  1. Converting integer values to double precision floating point.
  2. Compensating for the phase difference between channels in the multiplexed ADC.
  3. Optional data smoothing.
  4. Calculation of data statistics; in particular: midline, magnitude, period, and phase.
  5. Modeling of data by a mathematically fitted cosine function using an iterative optimization method.

The final step of signal processing (modeling) is largely responsible for the accuracy of the overall state detection process, as it is relatively insensitive to slight temporal variations in signal parameters and noise. This step rejects signals which are not acceptable cosines, and "locks on" to those that are.

1-bit preparation and detection

Automated test system

State preparation and state detection can be combined in an automated way in order to test and improve the accuracy of mapping {psi, chi} values to {mag, phase} signals and back again. Ideally, the mapping is an identity and all psi/chi-outputs = psi/chi-inputs to within some mean error. The state preparation system generates a sequence of {psi, chi} values at regular intervals (every few seconds), either randomly or at the points of a grid, sends these one after another to the analog electronics for processing, while the state detection system continuously reads, processes, and logs the results of the analog computation. Log files for {psi, chi} inputs and outputs are collated and processed by other C programs to determine the overall accuracy of the system, numerically and graphically. Adjustments to the C and C++ code, and to the electronics, can improve this accuracy in a way that is easy to see and quantify.

In the image below, state generation occurs in the microcontroller board at lower left, state detection in the board at upper left, analog filtering occurs in the circuit on the left side of the breadboard, 5V power supply is at lower right, and the upper right side of the breadboard contains an additional circuit for generating an independent reference signal used in testing.

Grids and stats

Automated test runs can be performed with a sequence of input states that are distributed randomly, on a grid, on rings, or near the basis states of the computational axis. Other distributions of points are easy to create. In the plots below, green points are input states, yellow points are samples acquired by state detection (including signal modeling), blue points are the averages of samples, and red lines are the differences between input and output states. In a perfectly accurate system, all red lines would vanish and all blue and green points would be coincident. At present the average error between inputs and outputs (the angle between states on the computational sphere) is about 0.413 degrees with a maximum error of about 0.884 degrees.

Once acceptable accuracy for a null computation has been achieved, the analog electronics will be modified to include additional processing of input states. This additional processing is the topic of the next section and those that follow.

©Sky Coyote 2018