In my previous post I tried to solve a differential equation using a port of Octave's adaptive Runge-Kutta 4/5 integration algorithm. It failed with energy explosions. Today I tried a different, much simpler, integration algorithm, and the energy explosions seem to be solved.

Velocity Verlet integration can be implemented for this problem in a few lines of code:

#include <math.h>// compute acceleration from positionstatic inline void f(double *a, const double x[2]) { a[0] = -exp(x[1] * x[1]) * x[0]; a[1] = -exp(x[0] * x[0]) * x[1]; }// Velocity Verlet integrationvoid compute() { const double h = 0.01; double x[2] = { 0, 1 }; double v[2] = { 1, 1 }; double a[2] = { 0, 0 }; f(a, x); v[0] += 0.5 * h * a[0]; v[1] += 0.5 * h * a[1]; while (1) { x[0] += h * v[0]; x[1] += h * v[1]; f(a, x); v[0] += h * a[0]; v[1] += h * a[1]; } }

You can download C99 source code for a JACK client which sonifies the chaotic coupled oscillators. I've been running it for 45mins at 48kHz sample rate, and no explosions yet, but be careful in case this is still transient behaviour...

No explosions may seem like a good thing, but what if the original differential equations are truly explosive, and the stability is a computational artifact? I still don't know the answer to that question.

]]>Simple harmonic motion is the solution to the differential equation:

\[\frac{\partial^2}{\partial t^2} x = -\omega^2 x\]

Interested in chaos I wanted to make the angular frequency \(\omega\) be cross-coupled in a pair of oscillators, and I came up with this differential equation:

\[\begin{aligned} \frac{\partial^2}{\partial t^2} x &= -e^{y^2} x \\ \frac{\partial^2}{\partial t^2} y &= -e^{x^2} y \end{aligned}\]

It sounds something like this: audio snippet.

I initially experimented with Octave's ode45() function, but it was rather slow, so I ported it to C99 (specialized to 4-vectors containing the displacement and velocity of each oscillator). Unfortunately it exploded after some time, with the amplitude of the oscillators swinging ever-larger, and the frequency of oscillation getting very very high too (which meant that the adaptive step size Runge-Kutta integration scheme would effectively get stuck and stop making progress).

Investigating this crisis, I thought to plot the energy of the system, and sure enough it exploded:

So this experiment failed, I'll have to try some other coupling expressions to see if they suffer the same fate or otherwise. Eventually I wanted to try controlling chaos by small perturbations to nudge the oscillators into unstable periodic orbits of various kinds, but no joy this week.

You can download the C source code for the integration calculations, gnuplot source code for the diagrams, and Octave source code for converting to audio.

]]>

a tap

dripslanding near the inside edge

of a metal bowl suspended in mid air

which goes "ting" when a drip landsthe drips flow down into the bowl

spreading out as they go

from sharp spikes of mass (impulse train)

becoming overlapping humps (near-Gaussian)

and eventually flatthe bowl has a small hole in the middle

when enough liquid has accumulated

from the flow of the drips into the bowl

to overcome surface tension

the liquid drips through the holeunderneath the hole in the bowl

is another bowl with a hole

which goes "ting" when a drip lands

near its inside edgethis goes on for some time

each bowl larger than the last

with a deeper "ting"the final bowl drips into a plant pot

it grows and flowers

Equations based on Dripping Faucet Dynamics Clarified by an Improved Mass-Spring Model by Ken Kiyono and Nobuko Fuchikami. Implemented in C++11 as part of dr1 on Gitorious dr1 on code.mathr.co.uk.

]]>I'm currently enjoying the Linux Audio Conference 2013 in Graz, Austria. On Saturday morning I'll present my paper Lyapunov Space of Coupled FM Oscillators:

I consider two coupled oscillators, each modulating the other's frequency. This system is governed by four parameters: the base frequency and modulation index for each oscillator. For some parameter values the system becomes unstable. I use the Lyapunov exponent to measure the instability. I generate images of the parameter space, implementing the number crunching on graphics hardware using OpenGL. I link the mouse position over the displayed image to realtime audio output, creating an audio-visual browser for the 4D parameter space.

I'll upload the slides and demos soon.

]]>I made this:

Most of the sounds were made using mutually-modulating oscillators on the edge of chaos, implemented in Pd, with CheeseTracker for bonus beats.

Devin Townsend - Ocean Machine - Biomech - 03 - Night

tired

motherboard 1 audio