# TOP tuning

## Contents

# Proportional error

A *tuning* for a regular temperament is defined by a vector T in Tenney tuning space whose entries are the size of the interval, in cents, which the k generators of the regular temperament (often the first k primes) are mapped to. T is denoted by a bra vector, and if M is a monzo then <T|M> is the size, in cents, of the interval defined by M in the tuning T. If q is the rational number which M represents, then we may also write this quantity as T(q).

Given a tuning T and a rational number q in the domain of T, the *signed error* of T on q is defined as Err(q) = T(q) - cents(q). The *absolute error* Arr(q) = |Err(q)| is the absolute value of the difference between the value in cents T assigns to q and the actual size in cents of q. The *absolute proportional error* is defined as 0 when q equals 1 and otherwise APE(q) = Arr(q)/cents(Ben(q)), where Ben(q) is the Benedetti height, the product of the numerator and denominator of q. Similarly, the *proportional error* PE(q) = Err(q)/cents(Ben(q)).

While the above definition seems to use cents to define proportional error, any logarithm base will lead to the same result, so that the definition is not in fact based on cents.

An equivalent way to write the above error metrics is as APE(q) = Arr(q)/(1200*Ten(q)) and PE(q) = Err(q)/(1200*Ten(q)), where Ten(q) is the Tenney height, and the 1200 in the denominator is only necessary to cancel out the use of cents in the numerator. Due to the use of the log-weighting in the denominator, these metrics are often collectively referred to as *Tenney-weighted error*.

# TOP tuning

For any tuning T, we may define the absolute proportional error APE(T) of T as the supremum (maximum) of the absolute proportional errors of all q belonging to the domain of T; that is, for which T provides a value. A **TOP tuning** for a regular temperament is a tuning supporting the temperament (ie, one which sends commas of the temperament to 0) with minimal APE. This minimal proportional error is a measure of the error of the temperament, which we might call the TOP error.

The concept of a TOP tuning was first suggested by Paul Erlich, who gave it its name, which stands for both Tenney OPtimal and Tempered Octaves Please, the latter due to the fact that usually the octaves are tempered.

# Maximal error semigroups

For a tuning T and absolute proportional error E = APE(T), consider the set S of all rational q>0 such that PE(q) = E. If a and b are elements of s, then PE(ab) = E. (In the product ab both errors and Tenney heights add; there can be no cancellation of prime factors since that would imply PE(ab) > E, contra hypothesis.) Hence S is a semigroup under multiplcation, with the structure of a finitely generated free abelian semigroup. A minimal set of generators consists of a finite set of primes or the inverses of primes, where one or the other is chosen so they are tuned sharply, which entails that PE(q)>0 in each case. This is the *sharp semigroup*; inverting the elements of S leads to a mirror image flat semigroup. This has the consequence that the tuning of S is defined entirely by the tuning of the primes in the sharp semigroup S or in the corresponding flat semigroup. From this we may conclude that E is the minimal weighted L-inf error and TOP tuning may also be defined as the minimal weighted L-inf error tuning.

For any regular temperament, we may define an *intrinsic prime* to be a prime dividing the numerator or denominator of some comma of the temperament. If the set of intrinsic primes generates the group on which the temperament is defined, we may call the temperament an *intrinsic temperament*. If the temperament is defined on a group generated by primes, then a prime which is not intrinsic is *extrinsic*. Consider a TOP tuning of an intrinsic temperament. As with any regular temperament there is a group of commas, the kernel, of rank n-k, where n is the dimension of the temperament and k is the rank of the temperament; n-k is the corank of the temperament. Since the TOP tuning minimizes the maximum sharp error, the rank of the sharp semigroup needs to be as large as possible, and this rank is k+1. If the set of sharp semigroup generators is {s₀, s₁, ...,sₖ} then {PE(s₀) - PE(s₁), PE(s₀) - PE(x₂), ..., PE(s₀) - PE(sxₖ)} is a set of k linear equations, which added to the n-k linear equations denoting setting the tempered commas to zero, gives n equations in n unknowns; the most we can set. Hence an intrinsic temperament has a unique kernel of rank n-k and a unique TOP tuning sharp semigroup of rank k+1. Conversely, if we add to the set of n-k comma generators a subset of k+1 elements of the set of primes and inverted primes of the intrinsic temperament, where for each prime either the prime or the inverse prime is selected, but not both, we obtain a *potential TOP tuning* on solving the n equations in n unknowns consisting of the n-k kernel equations and the k equations {PE(s₀) - PE(s₁), PE(s₀) - PE(x₂), ..., PE(s₀) - PE(sxₖ)} . Since the set of potential TOP tunings is finite, one way of finding the (unique) TOP tuning is simply to check all of them.

# Finding the tuning

For a temperament with both intrinsic and extrinsic primes, we may find the set of TOP tunings by first computing the tuning of the intrinsic primes. Then if r is an extrinsic prime, the tuning may be anything in the range where APE(r) ≤ E. The limit of the Lp tuning as p tends to 1 and the centroid of the region of TOP tunings both lead to choosing the JI tuning for r. This produces the canonical TOP tuning, called TIPTOP. To find the TIPTOP tuning one method is to solve for all the potential TOP tunings of the intrinsic primes, find the tuning with least error, and then tune all the extrinsic primes purely. An alternative method is to first set up a linear programming problem; if T is a val with indeterminate coefficients T = <t₁ t₂ ... tₖ| then minimize E subject to nonnegativity and the linear constraints {tₙ/log₂(pₙ) - 1 ≤ E, 1 - tₙ/log₂(pₙ) ≤ E, <T|cₖ> = 0} where the pₙ are the primes of the temperament, and the cₖ are the commas. We then may replace the tuning of all of the extrinsic primes with the pure JI tuning to get TIPTOP.

We may solve the sharp semigroup equations exactly to obtain solutions in the transcendental extension Q(log₂(q₁), log₂(t₂), ..., log₂(qₖ)) where the qₙ are the intrinsic primes other than 2. For example, take 5-limit meantone. Since 2 and 5 divide 80 and 3 divides 81. this is an intrinsic temperament. Solving for the TOP tuning either by linear programing or checking all the potential TOP tunings, we find the sharp semigroup is generated by {2, 1/3, 5}. Solving the sharp semigroup equations gives us a TOP tuning T = <3q₃/log₂(6480) (8q₃ + 2q₃q₅)/log₂(6480) 8q₃q₅/log₂(6480)|. Here q₃ = log₂(3), q₅ = log₂(5), and the denominator can also be written 4 + 4q₃ + q₅. A more complex example including an extrinsic prime is 13-limit parahemif temperament. Setting D = 22 + q₁₁ + 5q₁₃, we have T = <(2q₁₁ +10q₁₃)/D (18q₁₁ + 2q₁₃)/D q₅ (102q₁₁ - 62q₁₃)/D 44q₁₁/D 44q₁₃/D|. Note that all the prime tunings except for that of 5 lie in the field Q(q₁₁, q₁₃), where 1/2, 11 and 13 generate the sharp semigroup; 5 is of course the extrinsic prime. The tuning of the other primes is the same as the tuning for hemif temperament, which has the same commas, generated by {144/143, 243/242, 364/363}, and the same sharp semigroup, but which tempers the 2.3.7.11.13 subgroup.

If we want a pure-octaves tuning, we may divide the TIPTOP tuning by the tuning of 2, giving what may be called the Pure Octaves TIPTOP tuning, or POTT. The POTT tuning is sometimes in the simple form of prime tunings which can be expressed by way of fractional monzos; for 5- and 7-limit meantone and 11-limit meanpop, we get the 1/4-comma tuning which is also the eigenmonzo 5 minimax tuning. For 7- and 11-limit pajara, we also get the eigenmonzo 5 tuning, with pure 5/4s, and for 13-limit POTT, we get the eigenmonzo 13 tuning. For 5-, 7-, 11-, and 13-limit myna, the POTT tuning is pure 3s. And so forth, for many other examples. The same thing can happen in higher ranks: 7-limit starling has the 3 and 7 eigenvalue tuning, and 11 and 13 limit thrush the 3 and 11 eighenvalue tuning, etc.

# TOP commas and TOP extensions

Suppose T is a TOP tuned temperament with i intrinsic primes, e extrinsic primes, and a sharp semigroup of rank k+1. Then the dimensionality of T is n = e+i; the corank (rank of the comma group) is i-k and so the rank of the temperament is n-(i-k) = e+k. If we move a prime from intrinsic to extrinsic, the rank is therefore increased by 1 and the corank decreased by 1, leaving the dimensionality the same. If νₚ is the valuation val from prime p, meaning all coefficients bu the one for p are zero and the p coefficient is 1, then this "moving" can be accomplished by adding νₚ, for some prime p which is intrinsic but not a prime or inverse prime of the sharp semigroup, as the bottom row of the val list (mapping matrix) for T, or equivalently wedging it with the wedgie for T. This process can continue until all intrinsic primes except those for the sharp semigroup are moved to extrinsic primes. In this case, i=k+1 so the corank is i-k = (k+1)-k = 1, and there is only one comma, defined as usual as a rational number number greater than one which is not a square, cube or other power, generating the kernel. Since either this comma or its inverse is a product in the sharp semigroup, its absolute proportional error is equal to APE(T). The result is that for any regular temperament, there is a unique comma of the temperament such that the absolute proportional error in any TOP tuning is equal to the maximal absolute proportional error for the temperament. This comma we may call the *TOP comma*.The TOP comma in a sense encapsulates the error of the temperament. Any TOP tuning of the temperament, including TIPTOP, is also a TOP tuning of the codimension one temperament defined by the TOP comma.

For an example of how this works, in the 5 and 7 limits, the TOP comma for magic temperament is 3125/3072; in the 11-limit, |0 -11 15 0 -5>; in the 13 limit, |0 0 46 0 -19 -11>. Putting these in Graham's app will show how closely these are associated with magic. In many cases, the association is even more emphatic.

# TOP with "Inconsistent" Rational Tuning Extensions

It can sometimes be useful to look not just at "indirect" prime-based mappings, but also add extra "direct" mappings for important rationals -- deliberately inconsistent with the indirect ones -- for which the indirect mapping is subpar.

A good example of this is in 16-EDO, which has a perfectly good 9/8 at 225 cents, but which does not agree with the mapping of 3/2 at 675 cents. In this instance, the associated "2.3.5.9" sval would be [math]\langle 16\, 25\, 37\, 51|[/math], where it is seen that the mapping of 51 steps for 9 is "inconsistent" with the mapping of 25 steps for 3.

Note that there is no mapping for 3 at all which will map 9/1 to 51 steps, since 51 is an odd number, so it is useful to have both mappings: the regular 9/1, for use in chords such as the "Mavila" major 9 chord of 0-375-675-1050-1350, so that the 1350 cent 9/4 is a stack of two ~675 cent 3/2's, and the tempered 4:7:9 at 0-975-1425, which need not have any 3/2 at all.

It so happens that for some full prime-limit temperament, the TOP tuning remains optimal even if we use "inconsistent" mappings for any composite rational - or even *every* rational - as long as we are willing to go with the restriction that such mappings only be used if they are tuned better than the regular consistent ones. We will call tuning maps that obey this restriction **admissible.**

As an example, if our tuning map has the "consistent" 9/8 tuned to 204, but where we have an extra "inconsistent" 9/8 mapping that is tuned to 230 cents - that would be an **inadmissible** tuning map, because we have added an extraneous extra 9/8 tuning that is worse than the original. In such situations we would throw away the extra inconsistent 9/8 entirely as it serves no purpose, and only use the consistent mapping.

Given this restriction, the proof is easy: for any rational number, any "inconsistent" tuning must have a weighted error that is no worse than the "consistent" tuning, which in turn is no worse than the worst weighted prime error. However, there is no such thing as an "inconsistent prime mapping" - the mapping of a prime must always be consistent with itself! As a result, the worst-weighted error of the entire temperament cannot be changed by improving the errors of individual composite rationals - it will always be found at the worst-weighted prime, which will never change in this way.

As a result, the tuning that minimizes the max Tenney-weighted error on the primes is the same tuning that minimizes the max Tenney-weighted error on all rationals, even if there exist rationals with extra inconsistent mappings that have better tunings than the consistent ones.

Note that the above proof is only for full-prime limits: for arbitrary subgroups, some care is needed to extend the above argument, as it is possible (for instance) to work in the 2.5.9 subgroup without mapping 3 at all. In this situation, it is no longer the case that we have an extra mapping for 9/1 that is "inconsistent" with the mapping for 3/1, because there is no mapping for 3/1 at all, so 9/1 needs to be treated as thought it were a "prime." While a more thorough treatment of inconsistent mappings on arbitrary subgroups is needed, it is easy to see that for subgroups with a basis consisting only of prime powers, the same argument is easily shown to hold, with the worst weighted error being found at a prime power rather than a prime.

Most importantly, the above result holds without any hitches for prime-limit subgroups as the limit tends to infinity, and in particular for infinite-limit generalized patent vals, where the TOP tuning minimizes the error on all rationals regardless of whether those rationals are mapped "consistently" given the mapping on the primes, or "inconsistently" given their direct rounding to the nearest EDO-step.