# Wedgies and multivals

The **wedgie** is a way of defining and working with an abstract regular temperament (that is, a regular temperament where no tuning has been decided on). Wedgies are in a one-to-one relationship with abstract regular temperaments.

In geometric terms, given JI ratios *u* and *v*, a rank-2 temperament's wedgie *W* is defined by the property that the number *W*(*u*, *v*) is (proportional to) the signed area of the parallelogram spanned by (tempered versions of) *u* and *v*. This is the determinant of the tempered versions of *u* and *v*. The musical interpretation of the parallelogram spanned by *u* and *v* is: If you want to consider intervals that are multiples of *u* apart the same note (for example, if you want an octave-equivalent scale), *W*(*u*, *v*) tells you how many generators of your rank-2 temperament it would take to get to *v*. The reason that wedgies work as unique identifiers of temperaments is that the value *W*(*u*, *v*) only depends on what the temperament does to *u* and *v*, and this dependence (in a sense) matches up exactly with what commas are tempered out by the temperament.

A wedgie is written as a list of entries that give the values of the wedgie on the basis elements of the JI subgroup that the temperament is on. By the alternating property [i.e. *W*(*u*, *v*) = −*W*(*v*, *u*)] and bilinearity [*W* is linear in each argument separately], specifying the values on basis elements of the JI subgroup is enough to define *W* as an alternating bilinear form on all of the JI subgroup. The simplest example is rank-2 wedgies: Let *a* and *b* be (non-contorted) vals on a JI subgroup *q*_{1}.[…].*q*_{n} (where the *q*_{i} need not be prime). Then the entries of the wedgie *W* corresponding to the rank-2 temperament *a*&*b* of the JI subgroup *q*_{1}.[…].*q*_{n} are (ignoring sign and normalization):

[math]W(q_i, q_j) = a(q_i)b(q_j) - a(q_j)b(q_i) \text{ for } i \lt j.[/math]

(Note that by the alternating property, *W*(*q*_{i}, *q*_{i}) = 0 for all *i*.)

For the *p*_{n}-prime limit, the entries of *W* are conventionally listed in the order

[math]\langle\langle W(2, 3) \ \ldots \ W(2, p_n) \ W(3, 5) \ldots \ W(3, p_n) \ldots W(p_{n-2}, p_{n-1}) \ W(p_{n-2}, p_n)\ W(p_{n-1}, p_n)]].[/math]

For example, a 5-limit wedgie is of the form

[math]\langle \langle W(2, 3) \ W(2,5) \ W(3, 5)]],[/math]

and a 7-limit wedgie is of the form

[math]\langle \langle W(2, 3) \ W(2,5) \ W(2, 7) \ W(3, 5) \ W(3, 7) \ W(5, 7)]].[/math]

More generally, if one takes *r* independent vals *V*_{1}, …, *V*_{r} in a rank-*n* JI subgroup *q*_{1}.[…].*q*_{n}, then the wedgie for the rank-*r* temperament *V*_{1}&…&*V*_{r} is defined by:

- Take the wedge product of the vals, producing an
*r*-**multival**. - Divide out the greatest common divisior of the entries.
- If the first non-zero entry of the result of step 2 is negative, every entry of the multival is multiplied by −1, changing the sign of the first non-zero entry to be positive.

The result is the wedgie of the rank-*r* temperament *V*_{1}&…&*V*_{r}, whose entries are (ignoring steps 2 and 3):

[math]W(q_{k_1}, \ldots, q_{k_r}) = \det[V_i(q_{k_j})]_{i,j}, \ \text{for} \ 1 \lt k_j \lt n, [/math]

where [math][V_i(q_{k_j})]_{i,j}[/math] denotes the *r*×*r* matrix whose (*i*, *j*) entry is [math]V_i(q_{k_j})[/math]. These are *r*-dimensional quantities, the volumes of the *r*-dimensional parallelograms spanned by *q*_{kj} in the temperament's lattice.

## How the period and generator falls out of a rank-2 wedgie

The following is a procedure for finding a period and a generator for a rank-2 regular temperament on the 2.*q*_{1}.(…).q_{n} JI subgroup. We also give a (hopefully convincing and enlightening) proof of why the procedure always works. We'll assume that the equave is the octave, but non-octave JI equaves can be substituted for the octave if needed, by substituting the appropriate JI ratio for 2/1.

The following assumes that:

- you can think of JI ratios as vectors living in the
*n*-dimensional lattice of the "JI subgroup" - you know what a "period" and a "generator" of a rank-2 temperament are
- you know what a val is and how to work with one.

### The procedure

Consider the rank-2 temperament a&b, where a and b are two vals. Then the entries of the wedgie W corresponding to a&b are W(2, *q*_{1}), …, W(2, *q*_{n}), and W(*q*_{i}, *q*_{j}) for *i* < *j*, and the entry W(*p*, *q*) is given by a(*p*)b(*q*) - a(*q*)b(*p*).

To find the **period**: Let *d* = gcd(W(2, *q*_{1}), …, W(2, *q*_{n})). Then your period is 1\*d*.

To find (a JI interpretation of) the **generator**: Solve the equation W(2, *g*) = *a*_{1} W(2, *q*_{1}) + … *a*_{n} W(2, q_{n}) = *d* for the coefficients *a*_{1}, ..., *a*_{n} (using some algorithm such as the extended Euclidean algorithm). Then one valid generator for the temperament is (the tempered version of) *g* = *q*_{1}^{a1} … q_{n}^{an} (written additively, a linear combination g = *a*_{1}*q*_{1} + … + *a*_{n}*q*_{n}).

Now choosing an optimal tuning for the temperament is a matter of choosing a way to measure error from JI and minimizing the error with linear algebra (in practice, you can just use a program such as the x31eq temperament finder). For example, the TE and POTE tunings are based on minimizing TE error.

### Example

Consider the wedgie W = <<1 4 4|| for 2.3.5 meantone (the 12&19 temperament). We have W(2,3) = 1 and W(2,5) = 4, so d = 1, and our period is 1\1. Further, we have that 1*W(2,3) + 0*W(2,5) = 1, so we can use 3^1 * 5^0 = 3/1 as our generator.

Note that -3*(2,3) + 1*W(2,5) = -3*1 + 1*4 = 1, so *a*_{1} = -3, *a*_{2} = 1 is another solution to the equation. Thus 5/27 is also a valid generator. This octave reduces to the 40/27 grave fifth, which is equated to 3/2 in meantone.

### Proof (a bit technical)

The following additionally assumes that you know what the words "basis", "linear map", and "determinant" mean.

The period *p* (fraction of octave) and generator *g* form a basis for all the intervals of a rank-2 temperament. For example, p = 2/1 and g = 3/2 form a basis for meantone. But from a purely linear-algebra perspective, there's nothing special about the basis {p, g}; I could have chosen another basis, for example p' = 3/1 for my "period" and g' = 2/1 for my "generator". What makes the wedgie a unique identifier for a temperament is that rather than specify a basis directly, the wedgie acts more like a set of constraints that any basis for the temperament must satisfy.

In the language of linear algebra, the wedgie is an "alternating bilinear form" on the appropriate JI group M; this means that (ignoring sign) it acts like the operation of finding the determinant of two vectors on the appropriate quotient group M' = M/K of M, where K is the kernel of the bilinear form W. Using the fact that W = a&b where a and b are two edos (properly, rank-1 vals), you can verify that K is exactly the kernel of the rank-2 temperament, as follows. (Hence M/K' is a rank-2 lattice on which W is an alternating non-degenerate bilinear form, which justifies the intuition of viewing W as a determinant-like function.)

Let K_1 = the kernel of the temperament (i.e. the set of commas tempered out by the temperament), and K_2 = ker W = {v ∈ M : W(v, w) = 0 ∀w ∈ M}. If v ∈ K1, then v is tempered out by both a and b, so W(v, w) = a(v)b(w)-a(w)b(v) = 0, and v ∈ K_2. Conversely, if v ∈ K_2, then W(v, w) = a(v)b(w)-a(w)b(v) = 0 for all w, which implies a(v)b(w) = a(w)b(v) (*) for all w. Since a and b both have rank 1 but a&b has rank 2, a and b are linearly independent in M* (the dual Z-module of M); so we can choose w such that a(w) = 0 but b(w) ≠ 0. Then (*) shows a(v) = 0. By the same argument, b(v) = 0. So v is in K_1 and K_1 = K_2, as claimed.

By the First Isomorphism Theorem it follows that M' is the group of intervals in the rank-2 temperament in question.

The key fact about the determinant we use here is that two integer vectors v_1, v_2 form a basis for the rank-2 integer lattice **Z**^{2} iff det(v_1, v_2) = ±1. So in order to find a period and generator for our tempearment, we need a pair of vectors {p, g} such that W(p, g) = 1 and p is 1\d for some integer d.

Let d = gcd(W(2/1, q_1), ..., W(2/1, q_n)). This tells you that for any JI ratio v in your JI subgroup, W(2/1, v) = 2n(v) for some number n(v) [that depends linearly on v]. This equation is also true when we replace 2/1 with any JI ratio u that is equated to 2/1. This tells us that for W(p, g) = 1, we (up to some choices) need p to be an interval such that d*p is equated to 2/1, i.e. p represents 1/d of the octave.

Choose a basis e_1, e_2 for the temperament group and write (the image of) 2/1 as 2/1 = a_1 e_1 + a2 e_2. Then:

- W(2/1, e_1) = W(a_2 e_2, e_1) = -a_2 W(e_1, e_2) = -a_2
- W(2/1, e_2) = W(a_1 e_1, e_2) = a_1 W(e_1, e_2) = a_1.

Divisibility (by d = gcd(W(2, q_1), ..., W(2, q_n))) and the fact that e1 and e2 represent JI ratios in the 2.q_1. ... q_n subgroup impliy that a_1 and a_2 are both divisible by d, and hence 2/1 is a dth power in M' (the temperament space). Since gcd(W(2, q_1), ..., W(2, q_n)) = d, we can always find a linear combination g = a_1 q_1 + ... + a_n q_n such that W(2, g) = a_1 W(2, q_1) + ... a_n W(2,q_n) = d using the extended Euclidean algorithm. Then since W(2, g) = W(d*p, g) = d*W(p, g) = d, we have W(p,g) = 1. Ta-da!

## Technical introduction

An alternating multilinear map which is a multilinear function taking a certain number n of monzos as arguments and returning an integer as a value we may call an **n-map**. This definition is quite a mouthful, and we will attempt to unpack it in more comprehensible language and explain why these things are valuable in tuning theory.

The simplest kind of n-map is the 1-map, or val. This takes p-limit rational numbers, which may be written as monzos, and returns an integer, and may be called both a group homomorphism and a module homomorphism. Vals are linear: if you take the product of two p-limit rationals (or equivalently, add the corresponding monzos) then the val applied to the product/sum is the sum of the val applied to each separately, and so forth. Next come the 2-maps. These are linear functions f(u,v), linear for u fixing v, and linear for v fixing u, and alternating. meaning that f(u,u)=0 and f(u,v)=-f(v,u).

One use for such things is as "machines" for measuring complexity. If we consider the 1-map which is the val for 11-limit 31et, we find we have <31 49 72 87 107|. This tells us that it takes 72 steps of 31 equal to get to the approximate 5, which therefore has a complexity of 72 in this system. Now consider a 2-map "meantone(u,v)" which tells us, roughly speaking, how many generator steps it takes to get to v assuming u is being used as a period in septimal meantone. Using 2 as a period we can take (the approximate) 3/2 as a generator, in which case we have meantone(2,3)=1, meantone(2,5)=4, meantone(2,7)=10. With 3 as a period and 3/2 as a generator, we get meantone(3,5)=4 and meantone(3,7)=13. Finally, with if we take 5 as a period we find that four 3/2s give 5, so 5^(1/4) or equivalently 3/2 is the basic period. Using 3/2 as a period and 9/8 as a generator we get three generator steps to 7, and multiplying by four to be using 5 and not 5^(1/4) gives us meantone(5,7)=12. This description does not make clear where the signs come from, which will emerge from the discussion of the wedge product, but it may help to elucidate how these things are connected to complexity.

Given an n-map f and an m-map g we may define a new (n+m)-map, the wedge product of f and g, written f∧g, as follows:

[math]\displaystyle f\wedge g = \sum_s sgn(s)f(x_s(1),x_s(2),...,x_s(n))g(x_s(n+1),...,x_s(n+m))[/math]

where the sum is taken over S(n,m), the set of all permutations of the first n+m integers which are an (n,m) shuffles, and sgn(t) is the parity of the permutation t, which is +1 if t is even meaning an even number of transpositions of two numbers will get to t, and -1 if t is odd.

If f and g are both vals (1-maps) then this becomes especially easy: f∧g(u,v) = f(u)g(v) - f(v)g(u). Let's consider a specific example. Suppose E19 = ⟨19 30 44 53] is the equal temperament val for septimal 19et, and E31 = ⟨31 49 72 87] is the val for septimal 31et. Then writing intervals multiplicatively, we have

[math](E19\wedge E31)(2,3) = E19(2)E31(3) - E19(3)E31(2) = 19*49 - 31*30 = 1[/math]

We may continue in this way to consider (2,5), (2,7), (3,5), (3,7) and (5,7), and writing them in this alphabetical order yields <<1 4 10 4 13 12||. Here the double angle braces are to indicate that the object is a 2-map. In fact, it is a special kind of 2-map in that it is the result of taking a wedge product rather than being, eg, the sum of two wedge products and is called a **bival**. In the same way, triple wedge products yield trivals which we depict with three angle braces, and so forth. Just as vals as associatd to rank one (equal) temperaments, bivals are associated to rank two temperaments such as meantone, trivals to rank three temperaments, and so forth. In tuning theory the necessity to look at any n-maps aside from vals, bivals and trivals seldom arises, so this notation, which is not standardly mathematical but which has been adopted for convenience by tuning theorists, is quite practical. As we can see by comparing the numbers, E19∧E31 is the same object we were calling "meantone(u,v)" which gives us complexity measurements for meantone.

This particular bival has the properties that the first nonzero coordinate (1, in this case) is positive, and that the GCD of all of the coordinates is 1. An n-map with these properties we may call *reduced*, and reduced n-vals can be used to give unique names to regular temperaments.

These reduced n-vals, and particularly reduced bivals, are called *wedgies*, and the fact that they are reduced both makes the name unique and tells us that wedgies are projective, and hence the definition of regular temperaments in terms of them is projective. Thus, E24 = <24 38 56| is a perfectly valid val, but since it is not reduced, it does not define a 1-wedgie and hence there is no 5-limit 24et temperament to go with it. Sometimes such a temperament, where more than one set of notes exists in it each of which is unreachable from the others via intervals with defined prime mappings is called *contorted*. Wedgies do not name or signify contorted temperaments.

## Truncation of wedgies

A useful operation to perform on any multivector, including wedgies, is truncation of the wedgie to a lower prime limit. This in effect sets all the basis vectors of a p-limit wedgie which are greater than q, the prime limit being truncated to, to zero. An algorithm to produce the truncation is to list the r-subsets of the primes to p in alphabetical order, and add the corresponding coefficient to the list of the q-limit truncation if and only if the maximum prime in the r-subet is less than or equal to q. Truncating a wedgie can lead to a non-wedgie if the GCD of the coefficients is greater than one; this means that in the lower limit, contortion has appeared.

## Conditions on being a wedgie

If we take any three integers <<a b c|| such that GCD(a, b, c) = 1 and a ≥ 1 the result is always a wedgie, the wedgie tempering out the dual monzo |c -b a>. Since three such integers chosen at random are unlikely to produce a suitably small comma, the temperament will probably not be worth much, but at least it can be defined.

However, this is no longer the case in higher limits. There, not everything which looks like a wedgie will be one; for instance the wedgies must also satisfy the condition, for any wedgie W, that W∧W = 0, where the "0" means the multival of rank 2r obtained by wedging W with W. For prime limits 7 and 11 this condition suffices for rank two, but in general we need to check, for every prime q ≤ p and every basis val v sending q to 1 and everything else to 0, that (W∨q)∧W and (W∧v)º∧Wº = 0, where "∨" denotes the interior product. These conditions, the complete set along with the basic reduction conditions for being a wedgie, are known as the Plücker relations. Note that the Plücker relations must be satisfied, since for a rank r multival, W∨q is a rank r-1 multival corresponding to tempering out all the commas of W, as well as q.

In the 7-limit case, if we wedge a prospective rank two multival W = <<a b c d e f|| with itself, we obtain W∧W = 2(af-be+cd). The quantity af-be+cd is the Pfaffian of the wedgie, and that the Pfaffian is zero tells us that in the five-dimensional projective space **P⁵** in which wedgies live, the wedgie lies on a (four-dimensional) hypersurface, known as the Grassmannian **Gr**(2, 4). For an 11-limit rank-two wedgie W = <<w1 w2 w3 w4 w5 w6 w7 w8 w9 w10|| we have that W∧W = 2<<<<w1w8-w2w6+w3w5, w1w9-w2w7+w4w5, w1w10-w3w7+w4w6, w2w10-w3w9+w4w8, w5w10-w6w9+w7w8|||| is zero. These conditions allow us to solve for three of the coefficients in terms of the other seven, and so that **Gr**(2, 5), the Grassmannian of rank-two 11-limit temperaments, is a six-dimensional projective algebraic variety in nine-dimensional projective space **P⁹**. Wedgies correspond to rational points on this variety. For 11-limit rank three temperaments, we have w6w1-w5w2+w4w3 = w9w1-w8w2+w7w3 = w10w1-w8w4+w7w5 = w10w2-w9w4+w7w6 = w10w3-w9w5+w8w6 = 0; again, this leads to a six-dimensional variety, this time **Gr**(3, 5).

## Constrained wedgies

Most of the wedgies which are legitimate according to the previous section do not represent temperaments which are in any way reasonable. To get temperaments which are, we need to constrain the relevant metrics--complexity should not be too high, error should not be too high, and badness should not be so high that competing temperaments are much better. Let us consider how bounding relative error E, aka simple badness, constrains a 7-limit rank two wedgie W = <<a b c d e f||.

By definition, E = ||J∧Z||, where Z is the weighted version of W; if q3, q5 and q7 are the logarithms base two of 3, 5, and 7, then Z = <<a/q3 b/q5 c/q7 d/(q3q5) e/(q3q7) f/(q5q7)||. We now have

[math]\displaystyle (\frac{d}{q_3q_5}-\frac{b}{q_5}+\frac{a}{q_3})^2+(\frac{e}{q_3q_7}-\frac{c}{q_7}+\frac{a}{q_3})^2+(\frac{f}{q_5q_7}-\frac{c}{q_7}+\frac{b}{q_5})^2 \\ +(\frac{f}{q_5q_7}-\frac{e}{q_3q_7}+\frac{d}{q_3q_5})^2 = 4 E^2[/math]

From this we can conclude that d, e and f satisfy |d - q3b + q5a| ≤ 2Eq3q5, |e - q3c + q7a| ≤ 2Eq3q7 and |f - q5c + q7d| ≤ 2Eq5q7. This has an interesting interpretation: since <1 q3 q5 q7|∧<0 a b c| = <<a b c q3b-q5a q3c-q7a q5c-q7b||, if E ≤ 1/(4q5q7), then the full wedgie can be recovered from the octave equivalent (OE) portion of the wedgie simply by wedging it with <1 q3 q5 q7| and rounding to the nearest integer. This is not a very serious constraint to place on relative error; it seems unlikely anyone would be interested in a temperament which did not fall well under this low standard. Hence we may compile lists of reasonable temperaments by presuming "reasonable" requires this bound to be met, searching through triples <<a b c ...|| (note that if all of these are zero, 2 is being tempered out) up to some complexity bound, wedging with <1 q3 q5 q7| and rounding, then checking if the GCD is one and the Pfaffian af-be+cd is zero. Then we may toss everthing which does not meet the bound on relative error; however, for a reasonable list we will want a tighter bound.

If C = ||W|| is the TE complexity, then the formula for the logflat badness B in the 7-limit rank-two case is particularly simple: B = CE. If complexity is bounded by, for example, 20 (which allows for some quite complex temperaments) then since E ≤ 1/(4q5q7), B ≤ 20/(4q5q7) = 0.767. This badness figure is easily met. While simply bounding complexity will lead to a finite list, the list would be enormous. An alternative is also to bound badness; for instance, we might produce a list of 7-limit rank-two temperaments with complexity less than 20 and a more reasonable badness limit, such as 0.05 or 0.06.

## Reconstituting wedgies in general

Essentially the same situation obtains for rank two temperaments in higher limits. The rule then is that if E ≤ 1/(C(n, 3)lb(q)lb(p)) then wedging K = <1 lb(3) lb(5) ... lb(p)| with the val consisting of 0 followed by the first n-1 coefficients of the wedgie and rounding will give the wedgie. Here p and q are the largest and second largest primes in the prime limit, lb(x) is log base two, and C(n, 3) is n choose three, n(n-1)(n-2)/6.

More generally, we can reconstitute W by rounding Y = (W∨2)∧K to the nearest integer coefficients, where K is the JI point <1 lb(3) lb(5) ... lb(p)| in unweighted coordinates. Then we have ||(W-Y)+Y|| ≤ ||W-Y|| + ||Y|| by the triangle inequality, and since ||W-Y|| is bounded by the fact that W has been obtained by rounding, complexity, which is ||(W-Y)+Y||=||W||, can be bounded by ||Y||; which means it can be bounded by the coefficients of Y, which are those coefficients of W which can be found in W∨2 and over which we could be conducting a search. Moreover, we have from Y∧K = ((W∨2)∧K)∧K = 0 that relative error, which is ||W∧K||, is ||((W-Y) + Y)∧K||=||(W-Y)∧K||, hence relative error is also bounded by the fact that ||W-Y|| is bounded. This means that unless relative error is large, W can be recovered by rounding Y, and hence all wedgies within such a bound, which we may call *recoverable*, can be found by a search on only some prospective coefficients. Temperaments which are not recoverable seem of little interest and may be ruled out of consideration. Search spaces for complexity measures such as TE complexity which are defined in terms of the wedgie can be obtained by assuming all wedgie coefficients which are not being used to recover a wedgie are zero, which gives a minimum value for the complexity. In the case of rank two temperaments, an especially efficient complexity measure for such searches, and one with some other desirable properties, is generator complexity.

In the particular case of the 11-limit in rank three, we have that (W∨2)∧K gives the full wedgie, which has ten coefficents, in terms of the first six upon rounding off. Using this for a search is less difficult than it sounds, since the complexity numbers for rank three are so much lower. If the relative error E satisifes E ≤ 1/(2√5 q5q7q11), then the rounding off is guaranteed to lead to the correct result. This amount, 0.0099, is again easily met.