# Implementing a System of Coupled Oscillators

• Implementing a continuous process as a series of discrete time slices
• The basic algorithm
• On each time slice
• For each oscillator i
• Update the period of i
• Update the phase angle of i

• To update the phase angle of oscillator i, add to its current phase angle
• The amount that it should move during a single time slice, given its current period
• The amount of adjustment due to phase coupling with other oscillators or the world
This equation is an example of an update rule. It tells how to set the phase angle (represented by the Greek letter phi) at time t + 1 in terms of what the phase angle is at time t, that is, one time slice earlier. The subscript i refers to the ith oscillator. We need this because each oscillator has its own phase angle and period. Because the phase angle and period (T) change with time, each is followed by t in parentheses; in other words, the phase angle and period are a function of time. Delta t refers to the amount of time that elapses in each time slice. So the second term on the right-hand side of the equation means the fraction of the oscillator's period represented by one time slice, that is, how much the oscillator's phase angle should advance during one time slice at the current period. The last term represents the change in the period due to coupling. This term is not spelled out here (that is, the computer would not know what to do with it), so we will have to worry about that later.

• To update the period of oscillator i, add to its current period
• An amount which moves it some distance towards its resting period
• The amount of adjustment due to period coupling with other oscillators
This equation, like the last one, is an update rule. The value of the period on the next time slice is expressed in terms of its value one previous time slice plus two other terms. The second term represents the change in period due to coupling with other oscillators. The third term represents the change in period due to movement in the direction of the oscillator's resting period. Both the second and third terms need to be spelled out so that the computer can understand what to do with them

• To decay the period of oscillator i towards its resting period, add some small proportion of the difference between the resting period and i's current period
This equation is not an update rule. It tells how to calculate the change in oscillator period due to its tendency to move back to its resting period. If its current period is too high, the change will be negative; if it's too low, the change will be positive. D is a constant which is greater than 0 but much less than 1. This ensures that the period will only move a small distance in the direction of the resting period on each time slice.

• To figure the amount of phase angle change due to coupling, add the amount due to coupling with other oscillators and the amount due to coupling with "the world" (input). We can ignore the world for our purposes, so we only consider the influence of other oscillators.

To figure the amount of phase angle change in oscillator i due to coupling with other oscillators, for each other oscillator j, take the difference of the phase angles of i and j and add some function (the coupling function) of this difference to the sum.

This equation expresses the change in phase angle of oscillator i due to coupling with other oscillators in terms of the difference in phase angles of those oscillators and oscillator i. Obviously this distance matters, but precisely how it matters, we will leave unspecified at the moment and simply say that there is some function f of the difference which determines the change in phase angle. The large sigma means that we are summing the effects of the phase angles differences over all of the oscillators. We refer to each oscillator with subscript j (to distinguish it from oscillator i, the one we are concerned with at the moment), and j has every value from 1 up to N, the total number of oscillators. The sigma says that we are to add the quantity after the sigma for all of these values of j. It is just a shorthand notation for a number of additions, used here because we do not in general know how many additions we will need to write down (because N can take on different values). Finally the whole sum is multiplied by a constant (C) so that we can control how fast coupling takes place. If C is close to 1, then on each time slice each oscillator moves quickly in the direction of other oscillator. If C is small, say, .01, each oscillator moves only very slowly in the direction of the others. Note that we still aren't done because we haven't yet said what the coupling function f actually is.

• Figuring changes in period due to coupling is similar to figuring phase angle changes

• Possible coupling functions

It will be convenient to think of phase angle differences as varying from -.5 to +.5. A difference of 0 means that the oscillators' phase angles are equal; they are perfectly aligned. A negative phase angle difference means that the oscillator we are considering, oscillator i, is behind the other oscillator, oscillator j. In general, coupling should cause oscillator's i's phase angle to increase in this situation, so the value of the coupling function will be positive. A positive phase angle difference means that oscillator i is ahead of oscillator j. In this case, coupling should in general cause oscillator i's phase angle to decrease, so the coupling function should have a negative value. Note that a difference of -.5 is the same as a difference of +.5; at that point we cannot say whether the I is ahead of or behind j.

• For this coupling function, the effect of one oscillator on another just increases linearly with the phase angle distance between them. That is, an increase in phase difference has the same effect whether the oscillators' phase angles are relatively close together or far apart.

• This is similar to the previous coupling function, but its slope goes to 0 at -.5 and +.5, which seems more reasonable. Note that it is no longer linear; the effect of an increase in phase difference depends on how far apart the oscillators' phase angles are.

• In the last two functions, there is a striking discontinuity at -.5/+.5, which are actually the same value. For negative phase angle differences, as the magnitude of the difference gets greater, the effect continues to grow. The same is true for positive phase angle differences. One way to avoid this effect is with a "window" which permits coupling only to happen when the two oscillators' phase angles are within some range of each other This plot shows one possibility; here the magnitude of the phase difference must be less than .2.

• Note that there are also discontinuities in the last function, at -.2 and +.2. Here is a smooth coupling function which avoids discontinuities altogether. Note that at -.5/+.5, there is no coupling at all.

• Other factors that go into coupling function
• Distance between oscillators
• Whether each oscillator has a pulse output, that is, whether it can only be "seen" within a narrow "window" around its 0 phase