# Mathematics of MOS

 This is an expert page. It is written to allow experienced readers to learn more about the advanced elements of the topic.The corresponding beginner page for this topic is MOS scale.

## Definition

A MOS scale consists of:

1. A period "P" (of any size but most commonly the octave or a 1/N fraction of an octave)
2. A generator "g" (of any size, for example 700 cents in 12edo) which is added repeatedly to make a chain of scale steps, starting from the unison or 0 cents scale step, and then reducing to within the period
3. No more than two sizes of scale steps (Large and small, often written "L" and "s")
4. Where each number of scale steps, or generic interval, within the scale occurs in no more than two different sizes, and in exactly two if the interval is not a multiple of the period except in such cases as an ET.
5. The unison or starting point of the scale is then allowed to be transferred to any scale degree--all the modes of an MOS are legal.

Condition 4 is Myhill's property where, as a periodic scale, the scale has every generic interval aside from the initial unison interval and intervals some number of periods from it having exactly two specific intervals. Another characterization of when a generated scale is a MOS is that the number of scale steps is the denominator of a convergent or semiconvergent of the ratio g/P of the generator and the period.

These conditions entail that the generated scale has exactly two sizes of steps when sorted into ascending order of size, and usually that latter condition suffices to define a MOS. However, when the generator is a rational fraction of the period and the number of steps is more than half of the total possible, a generated scale can have only two sizes of steps and fail to be a MOS, meaning that not all non-unison classes have only two specific intervals.

### Characterizations

There are several equivalent definitions of MOS scales:

1. Maximum variety 2
2. Binary and has a generator
3. Binary and distributionally even
4. Binary and balanced (for any k, any two k-steps u and v differ by either 0 or L − s = c)
5. Mode of a Christoffel word. (A Christoffel word with rational slope p/q is the unique path from (0, 0) and (p, q) in the 2-dimensional integer lattice graph above the x-axis and below the line y = p/q*x that stays as close to the line y = p/q*x without crossing it.)

While each characterization has a generalization to scale structures with more step sizes, the generalizations are no longer equivalent:

## Properties

Let us represent the period as 1. This would be the logarithm base 2 of 2 if the period is an octave, or in general we can measure intervals by the log base P when P is the period. Suppose the fractions a/b and c/d are a Farey pair, meaning that a/b < c/d and bc - ad = 1. If g = (1-t)(a/b) + t(c/d) for 0 ≤ t ≤ 1, then when t = 0, the scale generated by g will consist of an equal division of 1 (representing P) into steps of size 1/b, and when t = 1 into steps of size 1/d. In between, when t = b/(b + d), we obtain a generator equal to the mediant (a + c)/(b + d) and which will divide the period into b+d equal steps. For all other values a/b < g < c/d we obtain two different sizes of steps, the small steps s, and the large steps L, with the total number of steps b+d, and these scales are the MOS associated to the Farey pair. When g is between a/b and (a + c)/(b + d) there will be b large steps and d small steps, and when it is between (a + c)/(b + d) and c/d, d large steps and b small ones.

While all the scales constructed by generators g with a/b < g < c/d with the exception of the mediant which gives an equal tuning are MOS, not all the scales are proper in the sense of Rothenberg. The range of propriety for MOS is (2a + c)/(2b + d) ≤ g ≤ (a + 2c)/(b + 2d), where MOS coming from a Farey pair (a/b, c/d) are proper when in this range, and improper (unless the MOS has only one small step) when out of it. If (2a + c)/(2b + d) < g < (a + 2c)/(b + 2d), then the scales are strictly proper. Hence the diatonic scale in 12et, with generator 7/12, is proper but not strictly proper since starting from the pair (1/2, 3/5) we find the range of propriety for these seven-note MOS to be [5/9, 7/12].

Given a generator g, we can find an MOS for g with period 1 by means of the semiconvergents to g. A pair of successive semiconvergents have the property that they define a Farey pair, and when g is contained in the pair, that is, a/b < g < c/d, we have defined a MOS for g with b+d as the number of notes in the MOS, with b notes of one size and d of the other.

For example, suppose we want an MOS for 1/4-comma meantone. The generator will then be log2(5)/4, which has semiconvergents 1/2, 2/3, 3/5, 4/7, 7/12, 11/19, 18/31, 29/50, 47/81, 65/112... If we settle on 31 as a good size for our MOS, we see 18/31 is the mediant between the Farey pair 11/19 and 7/12, for which the range of strict propriety is 29/50 < x < 25/43. Since g is in that range and not equal to 18/31, we will get a strictly proper MOS.

## Visualizing MOS: Generator Chains, Pitch Space, and Hierarchies

As MOS Scales are generated by repeated iterations of a single interval, the generator, it is useful to visualize a contiguous "generator chain" that organizes the scale. For example, if the generator is some kind of perfect fifth, then the generator chain is a chain of fifths: FCGDAEB. We know that adjacent tones in the chain are a perfect fifth apart (possibly with octave-displacement), eg. F to C, and that tones two spaces away are some kind of second or ninth apart, eg. F to G. It is clear from the chain that B to F is *not* a perfect fifth, but must be something else (unless the chain closes to form a circle, as would be the case in 7edo). The generator chain shows us that every interval of the MOS scale represents a move on the generator chain some number of generators up or down.

Another common way to view the tones of an MOS scale is as points in logarithmic pitch space, with larger gaps between points representing larger intervals and smaller gaps between points representing smaller intervals. Then we see that our scale has large steps and small steps and intervals that are composed of some stackings of large and small steps. It is not obvious, looking at the generator chain or looking at the tones in pitch space, what the relationship is. Indeed, it is different for different MOS scales -- an "L" will not always represent the same number of generators up or down when we move to a different scale.

Since the generator chain and logarithmic pitch space are both 1-dimensional, it may be helpful to graph them together in 2 dimensions. Here is a diagram for sensi[8], an octatonic 3L_5s MOS scale with a generator of about 444¢. The x-axis shows the generator chain and the y-axis shows the nine tones (eight plus octave) in logarithmic pitch space. You can see that the vertical lines are evenly-spaced (since every generator is the same), while the horizontal lines have large and small gaps, representing the large and small steps of sensi[8].

And another way to visualize MOS scales is hierarchically. Every MOS scale with 3 or more tones:

1. contains at least one MOS scale with fewer tones (and in fact, more than one instance of it), and
2. is contained (more than once) in either
1. an MOS scale with more tones, or
2. an equal scale (when L:s = 2:1).

Below is a diagram showing four MOS scales in logarithmic pitch space generated by 7\37edo (approx. 227¢). Each contains the ones above it and is contained by the ones below it. There are additional MOS scales that would appear above the first line with 1, 2, 3, 4, and 5 tones, but they have been omitted. The bottom line is a case where L:s=2:1, which means that there are no more MOS scales to be had -- the next stopping point is at a complete chromatic scale of 37edo.

For more images showing the hierarchical arrangement of MOS scales, see MOS scales of 17edo, 31edo MOS scales, MOS Scales of 37edo, and MOS Scales of 127edo.

## Classification of MOS scales

Since MOS scales always consist of some number of large steps and some number of small steps, they can be classified simply by the number of large steps and the number of small steps, in the form #L#s--e.g., the diatonic scale can be described as 5L2s (5 large steps and 2 small steps) or simply [5, 2]. It is typical to ignore the period when specifying MOS scales and instead use the number of large and small steps that make up the interval of equivalence (typically assumed to be the octave--a frequency ratio of 2/1--unless otherwise specified). For instance, the diminished scale in 12-TET is typically classified as 4L4s rather than 1L1s, since there are 4 large and 4 small steps that make up an octave.

Alternatively, we could give a mediant for a Farey pair associated to the MOS, where this mediant is less than any generator for the MOS. In other words, we use the right hand part of the Farey pair interval, which means we must replace g with 1-g and use the complementary pair if g is in the left hand side. This method is rarely used in discussions, however.

The two systems are equivalent; in the Algorithms section you will find code for routines starting from the mediant and going to the Ls pair (the "Ls" routine) and for starting from an Ls pair and going to the mediant (the "medi" routine.) The Ls routine uses modular inverses, whereas the medi routine uses continued fractions.

If the period is assumed to be 2^(1/n) for some integer n, we can give instead the total number of large and small steps in the octave, instead of just the period, and this is commonly done. In this case, GCD(L, s) gives the number of periods in an octave.

## Classification via the ? function

Yet another way of classifying MOS is via Minkowski's ? function. Here ?(x) is a continuous increasing function from the real numbers to the real numbers which has some peculiar properties, one being that it sends rational numbers to dyadic rationals. Hence if q is a rational number 0 < q < 1 in use in the mediant system of classifying MOS, r = ?(q) = A/2^n will be a dyadic rational number which can also be used. Note that the ? function is invertible, and it and its inverse function, the Box function, have code given for them in the algorithms section at the bottom of the article.

The integer n in the denominator of r (with A assumed to be odd) is the order (or n+1 is, according to some sources) of q in the Stern-Brocot tree. The two neighboring numbers of order n+1, which define the range of propriety, can also be expressed in terms of the ? and Box functions as Box(r - 2^(-n-1) and Box(r + 2^(-n-1)). If r represents a MOS, the range of possible values for a generator of the MOS will be Box(r) < g < Box(r + 2^(-n)), and the proper generators will be Box(r) < g < Box(r + 2^(-n-1)). So, for example, the MOS denoted by 3/2048 will be between Box(3/2048) and Box(4/2048), which means that 2/21 < g < 1/10, and will be proper if 2/21 < g < 3/31. Hence 7/72, a generator for miracle temperament, will define a MOS but it will not be proper since 7/72 > 3/31 = Box(3/2048 + 1/4096)).

## MOS in equal tunings

In an equal tuning, all intervals are integer multiples of a smallest unit. If the equal tuning is N-edo and the period is an octave, the sizes of the large and small steps will be p/N and q/N, with p > q. We then have L(p/N) + s(q/N) = 1, which on multiplying through by N gives us

Lp + sq = N.

which is a linear diophantine equation. Solving this by standard methods, and requiring L and s to be positive, gives us the [L, s] pair for the MOS. If some other quantity of equal steps gives the period, we may make the appropriate adjustment.

## Blackwood R constant

In the context of the "recognizable diatonic" scales deriving from the Farey pair [1/2, 3/5] Easley Blackwood Jr. defined a characterizing constant R which we may generalize to any MOS as follows. If a/b < g < c/d is a generator with the given Farey pair, take the ratio of relative errors R = (bg - a)/(c - dg). Since this is a ratio of positive numbers, it is positive. As g tends towards a/b it tends to zero, and as g goes to c/d R goes to infinity. When g equals (a + c)/(b + d) it takes the value 1, and the range of propriety is 1/2 ≤ R ≤ 2.

When R is less than 1, it represents the ratio in (logarithmic) size between the smaller and the larger step. When it is greater than 1, it is larger/smaller. By replacing g with 1 - g if necessary, we can reduce always to the case where R>1 (or R<1 if we prefer.)

## Algorithms

Below is some Maple code for various mathematical routines having to do with MOS. If you have access to Maple, you can of course copy and run these programs. Even if you do not, since Maple code makes better pseudocode than most languages or computer algebra packages afford, it can be used as pseudocode. For that purpose, it will be helpful to know that `modp(x, n)` means reducing x mod the integer n to 0, 1, ..., n-1 not only when x is an integer, but also when it is a rational number with denominator prime to n. In that case, p/q mod n = r means p = qr mod n.

Note that some procedures below depend on others. Special procedure names (i.e. not built into Maple) are shown in `bold type`.

```log2 := proc(x)
# logarithm base 2
evalf(ln(x)/ln(2)) end:
```
```nextfarey := proc(q, n)
# next in row n of Farey sequence from q, 0 <= q <= 1
local a, b, r, s;
if q >= (n-1)/n then RETURN(1) fi;
a := numer(q);
b := denom(q);
s := n - modp(n + 1/a, b);
r := modp(1/b, s);
r/s end:
```
```prevfarey := proc(q, n)
# previous in row n of Farey sequence from q, 0 <= q <= 1
local a, b, r, s;
if q=0 then RETURN(0) fi;
if n=0 then RETURN(0) fi;
a := numer(q);
b := denom(q);
s := n - modp(n - 1/a, b);
r := modp(-1/b, s);
r/s end:
```
```fareypair := proc(q)
# Farey pair with q as its mediant
local n;
n := denom(q);
[prevfarey(q, n), nextfarey(q, n)] end:
```
```mediant := proc(u, v)
# mediant of two rational numbers u and v
(numer(u) + numer(v))/(denom(u) + denom(v)) end:
```
```convergents := proc(z)
# convergent list for z
local q;
convert(z,confrac,'q');
q end:
```
```exlist := proc(l)
# expansion of a convergent list to semiconvergents
local i, j, s, d;
if nops(l)<3 then RETURN(l) fi;
d[1] := l[1];
d[2] := l[2];
s := 3;
for i from 3 to nops(l)-1 do
for j from 1 to (numer(l[i])-numer(l[i-2]))/numer(l[i-1]) do
d[s] :=
(j*numer(l[i-1])+numer(l[i-2]))/(j*denom(l[i-1])+denom(l[i-2]));
s := s+1 od od;
convert(convert(d, array), list) end:
```
```semiconvergents := proc(z)
# semiconvergent list for z
exlist(convergents(z)) end:
```
```penult := proc(q)
# penultimate convergent to q
local i, u;
u := convergents(q);
if nops(u)=1 then RETURN(u[1]) fi;
for i from 1 to nops(u) do
if u[i]=q then RETURN(u[i-1]) fi od;
end:
```
```Ls := proc(q)
# large-small steps from mediant q
local u;
u := fareypair(q);
[denom(u[2]), denom(u[1])] end:
```
```medi := proc(u)
# mediant from Large-small steps
local q, r;
if u[2]=1 then RETURN(1/(u[1]+1)) fi;
r := igcd(u[1], u[2]);
if r>1 then RETURN(medi([u[1]/r, u[2]/r])) fi;
q := penult(u[1]/u[2]);
if q > u[1]/u[2] then RETURN((numer(q)+denom(q))/(u[1]+u[2])) fi;
(u[1]+u[2]-numer(q)-denom(q))/(u[1]+u[2]) end:
```
```Lsgen := proc(g, n)
# given generator g and scale size n determines large-small steps
local q, u, w;
q := round(n*g)/n;
w := n/denom(q);
u := fareypair(q);
if g<u[1] or g>u[2] or g=q then RETURN('false') fi;
if g0 do
i := i+1;
if modp(n,2)=0 then
n := n/2^d[i];
else
n := (n-2^d[i]+1)/2^d[i] fi od;
e := convert(convert(d, array), list);
e := subsop(1=NULL,e);
w := ceil(-log2(y));
e := [op(e), w];
e := [op(e), floor(x)];
e := revlist(e);
n := invcon(e);
w := n[nops(n)];
if type(x, rational) and modp(denom(x), 2)=0 then RETURN(w) fi;
evalf(w) end:
```

## Proofs

### Definition of MOS

A periodic scale is MOS if it has maximum variety 2. This in particular implies that MOS scales are binary.

### MOS scales aL bs with gcd(a, b) > 1 reduce to single-period MOS scales on a smaller period

Assume that gcd(m, n) > 1 and assume that (n/d)-steps came in 2 sizes, pa+qb and ra+sb. Then at least one size, say pa+qb, must differ from (a/d)L + (b/d)s. WLOG p > a/d and pa+qb occurs on degree 0. Since equave = aL + bs, on a degree k(n/d) for some integer k > 0, there must be another (n/d)-step with fewer L's than a/d. This involves more than two changes from L to s. Scooting an (n/d)-step one step at a time from degree 0 to k(n/d) changes its size one step size substitution at a time, showing that intermediate (n/d)-steps also exist. This violates the MOS property, whence (n/d)-steps have only one size, which must be the period.

### Maximally even scales are MOS

Let 1 < m < n, gcd(m, n) = d, and ME(m, n) be as in Maximal evenness. An arbitrary k-step in ME(m, n) has size floor((i + k)n/m) − floor(in/m), and

[math]\lfloor in/m \rfloor + \lfloor kn/m\rfloor - \lfloor in/m\rfloor = \lfloor kn/m\rfloor ≤ \lfloor(i+k)n/m \rfloor - \lfloor in/m \rfloor ≤ \lfloor in/m \rfloor + \lfloor kn/m \rfloor - \lfloor in/m \rfloor + 1 = \lfloor kn/m \rfloor + 1.[/math]

As floor((i + k)n/m) − floor(in/m) is an integer, the above proves that there are at most two possible values for it and that if there are two sizes for k-steps, the two sizes must differ by 1.

Steps of ME(m, n) have exactly two sizes because if it were one size, we would have m | (n/d), which is a contradiction. This maximally even MOS has n % m large steps and m − (n % m) small steps.

### Binary generated scales with independent period and generator are MOS

This proof justifies the common description of "stack until binary" for MOS building and Erv Wilson's terminology moment of symmetry where MOS sizes are "moments" in time (when stacking) where the "symmetry" of binarity and MV2 holds.

By generatedness, we mean that every interval in the scale is of the form jg + kp where g is a generator, p is the period, and j, kZ, and that either g or −g occurs on every note. We claim that any interval class not p-equivalent to 0 has exactly 2 sizes in any scale satisfying the antecedent.

Suppose that such a scale S (with n ≥ 2 notes) has a-many L steps and b-many s steps per period p, and has generator g. Since S is generated, the interval sizes modulo p that occur in S are:

{(−n + 1)g, ..., −g, 0, g, ..., (n − 1)g},

and all sizes {0, g, ..., (n − 1)g} are distinct.

We thus have:

L = cg + dp

s = eg + fp

for appropriate integers c, d, e, f, where |c| < n and |e| < n.

Now we assume that g and p are linearly independent. By assumption aL + bs = (ac + be)g + (ad + bf)p = p. Since aL + bs occurs on the "brightest" mode, from generatedness we have ac + be ∈ {0, ..., n − 1}. Hence we must have ac + be = 0, and thus c = ±b and e = ∓a, from the assumption that gcd(a, b) = 1. In fact, {L, s} is another valid basis for the abelian group with basis {p, g}, since by binarity we have p, g ∈ span(L, s). Assume c = b and e = −a. [This corresponds to assuming that g is the "bright" generator.] Let χ = L − s > 0; then χ is p-equivalent to +ng. Now by generatedness and binarity, any interval class that has at least two sizes must have sizes separated by ng (the separation corresponding to changing an L step to an s step). Since g and p are linearly independent, for each j ∈ {1, ..., n − 1} there exists at most one k = k(j) ∈ {1, ..., n − 1} such that jg is p-equivalent to one size of k-step. Hence if the class of k-steps has at least two sizes, the sizes must be j(k)g and (j(k) − n)g; any other size must leave the range −(n − 1)g, ..., 0, ..., (n − 1)g. Thus the class of k-steps has at most two sizes for 1 ≤ k ≤ (n − 1). Each non-p-equivalent class must have exactly two sizes, since the inverse of the k-step that is equivalent to jg is an (nk)-step equivalent to −jg, which by linear independence must be distinct from an (nk)-step equivalent to a positive number of g generators. (Note that the latter (nk)-step does occur in the "brightest" mode of S, i.e. the mode with the most g generators stacked up rather than down from the tonic.) This completes the proof.

The previous argument cannot be used for the non-linearly independent case. This is because not all binary generated scales with rational step ratios are limit points of binary generated scales with irrational step ratios. A counterexample is the 13-note scale ssLsLssLsLss (s = 1\17, L = 2\17), which is obtained from LsLsLssLsLss (5L7s) by stacking one more 10\17 generator.