TOP and Tenney space

A real normed vector space is a real vector space with a norm, where "norm" is defined as follows:

If u and v are two vectors, and ||u|| denotes the norm, then

1. ||u|| >= 0

2. ||u|| = 0 iff u = 0 (the zero vector, not the number 0)

3. If c is a scalar, ||c u|| = |c| ||u||

4. ||u + v|| <= ||u|| + ||v||

A normed vector space is a metric space, with metric

d(u, v) = ||u - v||

An example of a normed vector space is the p-limit Tenney space, where the norm is

|| |u2 u3 u5 ... up> || = log2(2)|u2|+log2(3)|u3|+ ... + log2(p)|up|


The p-limit monzos live inside this space and form a lattice in the strict mathematical sense of a discrete subgroup of a normed vector space with compact quotient group. This lattice, whose lattice points have integer coordinates and where distance between them is given by the Tenney norm we may call the Tenney lattice.

A linear functional on a real vector space is a linear mapping from the space to the real numbers. It is like a val, but its coordinates can be any real number. An example is the size functional, JIP (where the acronym means Just Intonation Point.)

JIP = <log2(2) log2(3) ... log2(p)|

This functional maps every point of the Tenney space, not just lattice points, to a real number.

For any finite-dimensional normed vector space the space of linear functionals is called the dual space. It has a norm induced on it defined by

||f|| = sup |f(u)|/||u||, u not zero

We may change basis in the Tenney space by resizing the elements, so that the norm is now

|| |v2 v3 ... vp> || = |v2| + |v3| + ... + |vp|

This is called the L1 norm; the Tenney space with our original choice of basis is an L1 norm space also, but with a nonstandard choice of basis. Each of the basis elements now represents

something of the same size as 2, but that should not worry us.

It is a standard fact that the dual space to L1 is the L infinity norm, and vice-versa. This means (with this resizing of our basis vectors) that the correct norm for linear functionals on the Tenney space is

|| <f2 f3 ... fp| || = Max(|f2|, |f3|, ..., |fp|)

In terms of the original basis, this becomes

|| <f2 f3 ... fp| || = Max(|f2|, |f3/log2(3)|, ..., |fp/log2(p)|)

We may call the dual space to the Tenney space, with this norm, the val space. Just as monzos form a lattice in Tenney space, vals form a lattice in val space.

A regular tuning map T is a linear functional. If c is a comma which T tempers out, then T(c) = 0. If we have a set of commas C which are tempered out, then this defines a subspace Null(C) of the val space, such that for any T in Null(C), T(c)=0 for each comma tempered out. If we have a set of vals V, this defines a subspace Span(V) of the val space consisting of the linear combinations of the vals in V. Either way we define this subspace, it corresponds to a regular temperament. For points in this subspace, there will be a minimum distance to the JIP.

We may find this minimal distance, and the corresponding point, by finding the radius where a ball around the JIP first intersects it. In the val space, the unit ball looks like a measure polytope--which is to say a rectangle or rectangular solid of whatever the dimension of the space. It consists of all points v in the val space such that

|| v || <= 1

The corners of this measure polytope, one of which is the JIP, are

<+-1, +-log2(3), ..., +-log2(p)|

If n is the dimension of the Tenney space, and so of the val space, then there are 2^n such corners.

We may find TOP(S) in various ways, depending on the particular type of temperament, as detailed below.

Codimension One Temperaments

The codimension of a regular temperament is the dimension of its kernel, or the number of linearly independent commas needed to define it. A temperament of codimension one is defined by a single comma c. It is a linear temperament in the 5-limit, planar in the 7-limit, spacial in the 11-limit, and so forth. The subspace S in this case has codimension one, which means dimension n-1. Any line in the val space not parallel to S will meet it in exactly one point.

If S is such a subspace, we may find the points nearest to the JIP by taking a ball of radius r around the JIP, and expanding the radius until it touches S at a single point. Under special circumstances, it can have an entire line, face, etc of the ball touch at once. A prime q not in the factorization of of c but within the prime limit we are considering is unconstrained by c and can take any value and still have the resulting point in S. It can take any value within the minimal distance from the JIP and not affect that minimal value; in particular, it can always take the value of no distance from just intonation, where the coordinate for q is log2(q). We therefore define the TOP tuning for such q to be just intonation; in other words q is tuned to exactly q. We now may reduce the problem of TOP tuning a single-comma temperament to finding the points closest to the JIP within a subspace spanned by those primes which do appear in the factorization of c. Let us call this subspace, of dimension n, R.

Since we have 2^n corners to a ball, there are 2^(n-1) lines passing through the both the JIP and a corner, and intersecting R, and so 2^(n-1) possible solutions to the problem of finding the point on R nearest to JIP. If we simply check all of these we can find the nearest one. The point on R, which turns out to be unique, nearest to JIP together with just intonation for the remaining primes we define as TOP(c), the Tenney OPtimal tuning for the comma c.  The distance from TOP(c) to JIP is ERR(c), the Tenney-optimal temperament error term.

Because of the transcendence and linear independence of the logs of odd primes, the coordinates of the point on R nearest the JIP can never be the same as any of the coordinates of JIP. TOP(c) therefore retunes every rational number whose prime factorization includes any of the primes in c by some amount, and this includes octaves unless c is a ratio of odd numbers; hence the alternative acronym of Tempered Octaves, Please for TOP.

For 5-limit temperaments, we have a defining comma |c2 c3 c5> which leads to a corresponding subspace of the val space,

c2 x2 + c3 x3 + c5 x5 = 0

One of the corners of the unit ball around the JIP is the origin. Since any subspace passes through the origin, one possible solution for any sort of temperament will be the null tuning, defined as the one which tunes by sending every note to the unison. Any "temperament" for which this is the optimal tuning solution obviously does not deserve the name, and so we may ignore this solution. If c involves 2, 3 and 5, so that c2, c3, and c5 are all nonzero, the other three 5-limit solutions are as follows, where p3 = log2(3) and p5 = log2(5):

|(c2+c3 p3+c5 p5)/(c2-c3 p3+c5 p5) | [2 c3 p3/(c2-c3 p3+c5 p5), -2 p3 (c2+c5 p5)/(c2-c3 p3+c5 p5),
2 p5 c3 p3/(c2-c3 p3+c5 p5)]
|(c2+c3 p3+c5 p5)/(c2+c3 p3-c5 p5)| [2 c5 p5/(c2+c3 p3-c5 p5), 2 p3 c5 p5/(c2+c3 p3-c5 p5),
-2 p5 (c2+c3 p3)/(c2+c3 p3-c5 p5)]
|(c2+c3 p3+c5 p5)/(c2-c5 p5-c3 p3)| [2 (c3 p3+c5 p5)/(c2-c5 p5-c3 p3), -2 p3 c2/(c2-c5 p5-c3 p3), -2 p5 c2/(c2-c5 p5-c3 p3)]

Here the first column gives the radius, and the second column gives the corresponding solution. Note that the expressions in the first column will have nonzero integer values for c2, c3, and c5, and hence the denominators above are distinct. If we consider p3 and p5 to be indeterminate quantities x and y, and remove the absolute value, we get rational functions of two variables. These are not the same; if we subtract one from another we do not get zero. Since p3 and p5 are independent and transcendental, it follows that the values we get for these are all different. Algebraically, the function field of rational functions in two indeterminates with rational coefficients and the field Q(p3, p5) which we get by adjoining p3 = log2(3) and p5 = log2(5) to the rational numbers Q are isomorphic, and so this result is immediate. Hence, to obtain TOP(S) in this case we simply find which of these three numbers is smallest, and the TOP tuning will be the corresponding one in column two.

If two of c2, c3, or c5 are zero, we are trying to temper out a prime number as a comma, and this we may ignore. If exactly one of them is zero, the above three expressions for the radius reduce to merely two. We find that if c5=0, so that the comma is a 3-limit comma, that the radius is |(c2 + c3 p3)/(c2 - c3 p3)|. For a {2,5}-comma, we get |(c2 + c5 p5)/(c2 - c5 p5)|, and for a BP comma involving only odd numbers, we get |(c3 p3 + c5 p5)/(c3 p3 - c5 p5)|. The corresponding TOP tunings are

{2,3}-comma: [2 c3 p3/(c3 p3 - c2), -2 p3 c2/(c3 p3 - c2), p5]

{2,5}-comma: [2 c5 p5/(c5 p5 - c2), p3, -2 p5 c2/(c5 p5 - c2)]

{3,5}-comma: [1, -2 p3 p5 c5/(c3 p3-c5 p5), 2 p3 p5 c3/(c3 p3-c5 p5)]

Planar temperaments in the 7-limit work in exactly the same way. Here if the comma is |c2 c3 c5 c7> and none of c2, c3, c5 or c7 are zero we get the following seven possible solutions:

|(c2+c3 p3+c5 p5+c7 p7)/(c2-c3 p3+c5 p5+c7 p7)| [2 c3 p3/(c2-c3 p3+c5 p5+c7 p7),
-2 p3 (c2+c5 p5+c7 p7)/(c2-c3 p3+c5 p5+c7 p7),
2 p5 c3 p3/(c2-c3 p3+c5 p5+c7 p7), 2 p7 c3 p3/(c2-c3 p3+c5 p5+c7 p7)]
|(c2+c3 p3+c5 p5+c7 p7)/(c2+c3 p3+c5 p5-c7 p7)| [2 c7 p7/(c2+c3 p3+c5 p5-c7 p7), 2 p3 c7 p7/(c2+c3 p3+c5 p5-c7 p7),
2 p5 c7 p7/(c2+c3 p3+c5 p5-c7 p7),
-2 p7 (c2+c3 p3+c5 p5)/(c2+c3 p3+c5 p5-c7 p7)]
(c2+c3 p3+c5 p5+c7 p7)/(c2+c3 p3-c5 p5-c7 p7) [2 (c5 p5+c7 p7)/(c2+c3 p3-c5 p5-c7 p7),
2 p3 (c5 p5+c7 p7)/(c2+c3 p3-c5 p5-c7 p7),
-2 p5 (c2+c3 p3)/(c2+c3 p3-c5 p5-c7 p7),
-2 p7 (c2+c3 p3)/(c2+c3 p3-c5 p5-c7 p7)]
|(c2+c3 p3+c5 p5+c7 p7)/(c2-c3 p3+c5 p5-c7 p7)| [2 (c3 p3+c7 p7)/(c2-c3 p3+c5 p5-c7 p7),
-2 p3 (c2+c5 p5)/(c2-c3 p3+c5 p5-c7 p7),
2 p5 (c3 p3+c7 p7)/(c2-c3 p3+c5 p5-c7 p7),
-2 p7 (c2+c5 p5)/(c2-c3 p3+c5 p5-c7 p7)]
|(c2+c3 p3+c5 p5+c7 p7)/(c2-c3 p3-c5 p5+c7 p7)| [2 (c3 p3+c5 p5)/(c2-c3 p3-c5 p5+c7 p7),
-2 p3 (c2+c7 p7)/(c2-c3 p3-c5 p5+c7 p7),
-2 p5 (c2+c7 p7)/(c2-c3 p3-c5 p5+c7 p7),
2 p7 (c3 p3+c5 p5)/(c2-c3 p3-c5 p5+c7 p7)]
(c2+c3 p3+c5 p5+c7 p7)/(c2+c3 p3-c5 p5+c7 p7) [2 c5 p5/(c2+c3 p3-c5 p5+c7 p7),
2 p3 c5 p5/(c2+c3 p3-c5 p5+c7 p7),
-2 p5 (c2+c3 p3+c7 p7)/(c2+c3 p3-c5 p5+c7 p7),
2 p7 c5 p5/(c2+c3 p3-c5 p5+c7 p7)]
|(c2+c3 p3+c5 p5+c7 p7)/(c2-c3 p3-c5 p5-c7 p7)| [2 (c3 p3+c5 p5+c7 p7)/(c2-c3 p3-c5 p5-c7 p7),
-2 p3 c2/(c2-c3 p3-c5 p5-c7 p7), -2 p5 c2/(c2-c3 p3-c5 p5-c7 p7), -2 p7 c2/(c2-c3 p3-c5 p5-c7 p7)]

If the 7-limit comma contains no factor of 7, and so is also a 5-limit comma, we simply add to the 5-limit tuning a just tuning for 7. If we are missing another prime, we take the three remaining primes and treat it just as in the 5-limit case, recalling that p2=1 should be considered a part of the formulas when we make substitutions. If it is missing two commas, we likewise proceed as we did in the 5-limit case.

Equal Temperaments

An equal temperament is defined by a val <a2 a3 ... ap|. This val defines a line passing thorough the origin, which we can parametrize with the parameter t as <a2 t a3 t ... ap t|. We want to find the value of t giving the closest point on this line to the JIP; this will be the size of the retuned octave. The distance between points on this line and the JIP is

|| <a2t a3t ... apt| - <1 p3 ... pp| || = Max(|a2t - 1|, |a3t/p3 - 1| ... |apt/pp - 1|)

If we equate these in pairs, once again we will obtain an extraneous solution--the 0-equal temperament--and n(n-1)/2 genuine possibilities, where n is the number of primes in our p-limit. If u and v are two of these primes, and if we set p2=1, these possibilities are all of the form 2 pu pv /(au pv + av pu). Once again, note that considered as rational functions, none of these are identical, and this time we need not concern ourselves with the possibility that au or av are zero, since they should be positive integers. Hence we have a unique TOP tuning.

Linear Programming

We can set up the general problem of finding the TOP tuning for any regular temperament as a linear programming problem. We start by introducing a variable d representing the minimal distance to the JIP, and variables x2, x3, ..., xp for each prime number in our prime limit. Suppose we have a set of commas C such that Null(C) defines our temperament. For each such comma |c2 c3 ... cp> we may produce a corresponding equation

c2 x2 + c3 x3 + ... + cp xp = 0

The TOP solution will give us a tuning <x2 x3 ... xp| where xu/pu is approximately 1 for each prime u in our limit. We have for each prime the two inequality constraints

d >= xu/pu - 1

d >= 1 - xu/pu

The distance d and x2, x3, ... , xp should all be positive, so we may add positivity contraints

d >= 0

x2 >= 0


xp >=0

Finally, note that we are attempting to minimize distance, so d is our objective function. Putting this objective function and all of these equations and inequalities together gives us a standard linear programing minimization problem, which we can easily solve if we have the software available. If we want to find and solve the dual standard maximization problem as a means of solving this minimization problem, we can also do that by replacing each of the comma equalities with two inequalities, and dualizing.

We now check our commas, and see which primes q appear in the factorization of none of them. For these primes, we replace whatever optimal solution our program gave with the just intonation value of log2(q). This gives us our unique TOP tuning.

When coding this, I've found it's convenient to code for linear temperaments, and then set commas equal to 1 for planar, etc. temperaments. The TOP tuning starting from a wedgie is easily found by finding commas which generate it.