# Weil norm, Tenney-Weil norm, and TWp interval and tuning space

If p/q is a positive rational number reduced to its lowest terms, then the Weil height is the integer $\max(p, q)$. This is sometimes referred to as the multiplicative Weil height, whereas often it is common to take the logarithm of this quantity, which is called the logarithmic Weil height.

In number theory, this is often just called the "height" of the rational, or sometimes the "classical height" or "naive height", although Gene Smith suggested the use of the term Weil height to differentiate it from the other height functions we use, such as Tenney height.

## Relationship to Kees expressibility

If we first remove all factors of 2 before taking the Weil height, we get an octave-equivalent measure called the Kees height or Kees expressibility, depending on if you are using the multiplicative or logarithmic version.

## Relationship to Tenney height and span

The Weil height has some interesting properties which make it very suitable for use in tuning theory. For starters, we have the following identity:

$\displaystyle \log \max(p, q) = \frac12\log(pq) + \frac12|\log(p/q)|$

On the right hand side of this equation (ignoring the factors of $\frac12$), the first term represents the Tenney height and the second represents the span of the interval. Thus, the Weil height can be thought of as an altered version of the Tenney height which also incorporates the span of an interval into the calculation, so that larger intervals are increased in complexity relative to smaller intervals. The log base in the above equation is arbitrary, but it is conventionally taken to be either base 2, in which case the span will be in octaves, or sometimes base e, in which the units are in nepers, where one neper is about 1731.234 cents.

## Generalized Tenney-Weil height

We can immediately derive a family of "interpolated" complexity measures, intermediate to the Tenney and Weil heights, by changing the coefficients in the right-hand side of the above equation from $\frac12$ to something else.

Although there are several ways to write it, we will simply take a weighted average of the Tenney and Weil height at first, adding a new free parameter $k$. We also note that for the Tenney height to scale properly with the Weil height, we will want to take the logarithm of the square root of $pq$, rather than just the logarithm of $pq$. We get:

$\displaystyle \text{TW}_k(p, q) = (1-k)\log((pq)^{\frac12}) + k\log \max(p,q)$

So that we have, for $k=0$, (half of) the Tenney height and $k=1$, the Weil height. This can be rewritten as

$\text{TW}_k(p, q) = (\frac12 - \frac{k}{2})\log(pq) + k\log \max(p,q)$

And using the previous identity, we get

$\text{TW}_k(p, q) = (\frac12 - \frac{k}{2})\log(pq) + k(\frac12\log(pq) + \frac12|\log(p/q)|)\\ = \text{TW}_k(p, q) = \frac12\log(pq) + \frac{k}{2}|\log(p/q)|$

So that we can see the parameter $k$ also simply measures how much priority we place on the span.

Since we only care about dyads, we can also drop the factor of $\frac12$ to get

$\text{TW}_k(p, q) = \log(pq) + k|\log(p/q)|$

although it is noteworthy that this factor becomes important when looking at generalizations of the Weil norm to larger chords; see Chord complexity.

## Weil and Tenney-Weil interval space

The Tenney height can also be thought of as a norm on monzos. This is a Banach space called Tenney interval space, where the Tenney norm is a type of scaled $L_1$ norm. The logarithmic Weil norm also has the property of being a norm on interval space, as does the entire family of Tenney-Weil norms, and thus we may refer to Weil or Tenney-Weil interval space.

Given some $n$-limit monzo $m$ = [$x_2$ $x_3$ $x_5$ $\ldots$ $x_n$, using the identity above, the Weil norm can be expressed as

$\displaystyle \|m\|_{W_1} = |x_2| \log(2) + |x_3| \log(3) + \ldots + |x_n| \log(n) + |x_2\log(2) + x_3\log(3) + \ldots + x_n\log(n)|$

where $W_1$ refers to the Weil norm (this notation will be explained later below). For the general Tenney-Weil norm, we have

$\displaystyle \|m\|_{TW_{1,k}} = |x_2| \log(2) + |x_3| \log(3) + \ldots + |x_n| \log(n) + k \cdot|x_2\log(2) + x_3\log(3) + \ldots + x_n\log(n)|$

Note that the last term on the right is equal to the span. If we have $k=0$, we get the Tenney norm, and if we have $k=1$, we get the Weil norm.

This can be expressed as a matrix multiplication. We can form the following matrix

$X_{k} = \begin{bmatrix} \log(2) & 0 & 0 & \cdots & 0 \\ 0 & \log(3) & 0 & \cdots & 0 \\ 0 & 0 & \log(5) & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & 0 \\ 0 & 0 & 0 & \cdots & \log(n) \\ k\log(2) & k\log(3) & k\log(5) & \cdots & k\log(n) \end{bmatrix}$

Or, if $W$ is the usual monzo-weighting matrix, and $J$ is the JIP, we can think of this as forming the block matrix

$\displaystyle X_{k} = \begin{bmatrix} W \\ \hline k\cdot J \end{bmatrix}$

Then we have the Tenney-Weil norm of our monzo $m$ is simply

$\|m\|_{TW_{1,k}} = \|X_{k} \cdot m\|_1$

This maps every monzo $m$ = [$x_2$ $x_3$ $x_5$ $\ldots$ $x_n$ to the "weighted augmented vector" [$w_2$ $w_3$ $w_5$ $\ldots$ $w_n;$ $k$ $\cdots$ in a one-dimensional-larger space, where the $w_n$ are weighted coordinates, $k$ is the coefficient on the span, and the semicolon is just to make clear where this extra spurious coefficient is. The $L_1$ norm of this augmented vector is the result.

So that even the arbitrary Tenney-Weil norm can be thought of as an $L_1$ norm, although in a vector space expanded by one dimension. This definition can easily be extended to arbitrary subgroup by first embedding the subgroup monzos into the full $n$-limit, and then applying the above.

TODO: add pictures of 2D unit sphere for different values of $k$

## Generalized Weil and Tenney-Weil "$W_p$" and "$TW_{p,k}$" norms

Similarly to the Tenney-Euclidean norm, we can use this to define a variety of generalized "$L_p$-style" norms, some of which are easier to work with than the original Weil norm. To do this, we simply change the above expression from an $L_1$ norm to some other kind of norm. So we get

$\displaystyle \|m\|_{TW_{p,k}} = \left((|x_2| \log(2))^p + (|x_3| \log(3))^p + \ldots + (|x_n| \log(n))^p + (k \cdot|x_2\log(2) + x_3\log(3) + \ldots + x_n\log(n)|)^p \right)^{1/p}$

We can rewrite this simply using our matrix notation as

$\|m\|_{TW_{p,k}} = \|X_{k} \cdot m\|_p$

Where we have simply changed the $p$-norm from 1 to a different value of $p$.

### Weil-Euclidean norm

The special value of $p=2$ is called the Weil-Euclidean or WE norm, analogously to the Tenney-Euclidean or TE norm. We can similarly declare the Tenney-Weil-Euclidean or TWE family of norms for different values of $k$, with the TE and WE norms being special cases.

However, it so happens that our TWE norm is really just a reinvention of the Cangwu norm, although with some difference in scaling with our parameter $k$. Still, it is the same thing, up to a simple change in variables. We will treat these as generally synonymous.

The unit sphere of this norm is an ellipsoid which has been "squished" in monzo space along the axis measuring the span of a comma (this can be visualized as a squishing along the direction of the JIP, but treated as though it were a monzo). As the value of $k$ increases, this sphere is increasingly squished, meaning that larger commas are given a greater norm.

### Kees-Euclidean seminorm

Given the Kees-Euclidean norm, we can quotient out by octaves to arrive at the Kees-Euclidean seminorm. This seminorm can be thought of as a "L2-ified" version of the Kees expressibility, similarly to how the Weil-Euclidean norm is an L2-ified version of the Weil height. With some care in dealing with the divergences, this can be used to compute a Kees-Euclidean tuning which very closely approximates, but is not exactly equal to, the POTE tuning. This unique tuning happens to be identical to the "octaves-constrained" Weil-Euclidean tuning.

## Geometric interpretation and alternative formulation

The Weil norm skews the interval space by way of introducing an extra dimension. If we remove a layer of Tenney weight from the Weil norm, we get the equilateral-Weil norm. The figure shows an equilateral-Weil interval space. As each instance of either prime contributes positively to the extra dimension, the angle θ between two formal primes decreases. The measure cos θ is the cosine similarity between any two formal primes. If the length of each prime is set to unity, and if the contribution factor to the extra dimension is sqrt (s), then the contribution factor to the original dimension is sqrt (1 - s). It can be shown that cos θ = s.

k is the slope of the extra dimension. s and k can be related by

$\displaystyle k = \sqrt {s/(1-s)} \\$

When k = 1, s = 1/2. So we see the Weil norm skews the space to θ = arccos s = 60 degrees.

An alternative formulation which gives identical results in the Euclidean space as above is to skew the space within the dimension through constructing each unit vector that is 60 degrees from all previous unit vectors. Here is an algorithm to do so.

1. Let the first unit vector be x1 = [1.
2. Given the first j-th unit vectors, to find the (j + 1)-th, solve the j + 1 equations of the form
$\displaystyle \vec x_{j + 1} \cdot \vec x_i = \cos (\theta), i = 1, 2, \ldots, j \\ \left\Vert \vec x_{j + 1} \right\Vert_2 = 1$
3. Compose the transformation matrix X as
$\displaystyle X = \begin{bmatrix} \vec x_1 & \vec x_2 & \ldots & \vec x_n \end{bmatrix}$
4. Return X.

The result is without Tenney weighting. For the Tenney-weighted form, multiply it by the Tenney height transformation matrix on the right.

## Dual norms

These norms also induce dual norms on the dual space of vals and tuning maps. In general, the $TW_{p,k}$ norm on any $n$-limit monzo can be given by first embedding it into another vector space augmented with one extra dimension, and then taking the $p$-norm on that space. The free parameter $k$ determines at which angle the $n$-limit is being embedded into this augmented space. The norm on the original space is then induced as a "slice" through this larger space.

To get the "dual $TW_{p,k}$" norm on the space of vals, we first build the dual on this augmented space in the standard fashion; this is just the dual of the $L_p$ norm on the larger space. Then, since the norm on the original space was induced as a subspace of this larger space, the norm on the original dual space of vals will be induced as a quotient space of the dual of this larger space, as a corollary to the Hahn-Banach theorem.

Since we are mapping monzos to these "augmented monzos", which we are doing via the aforementioned matrix multiplication, the dual space of this larger space is made up of "augmented vals" of the form $v_2$ $v_3$ $v_5$ $\ldots$ $v_n;$ $\text{junk}$] where "junk" is an extra junk coefficient that we don't care about, formed as a byproduct of adding the augmented coefficient to monzos. The dual transformation of our matrix maps back from these augmented vals to regular ones, in effect "co-tempering" them to the original vals. We do this simply by multiplying the matrix on the other side, so that instead of mapping from monzos to augmented monzos via $\hat m = X_k \cdot m$, we map from augmented vals to regular vals via $v = \hat v \cdot X_k$.

Every val in our original space corresponds to an entire equivalence class or coset of augmented vals which are in the preimage of this dual transformation. It so happens that two of these augmented vals are in the same equivalence class if they differ by the augmented val $k$ $k$ $k$ $\ldots$ $k;$ $-1$], which is the left nullspace of our $X_k$ above.

So to make this clear, if we want to compute the dual $TW_{p,k}$ norm of some $n$-limit val

$v = \langle v_2 \, v_3 \, v_5 \ldots v_n]$

It so happens that all of the vals in the preimage of this, in our augmented val space, will be of the form

$v = \langle v_2 \, v_3 \, v_5 \ldots v_n;0| + r\cdot \langle k \, k \, k \ldots k;-1]$

Note that $k$ is determined ahead of time as the free parameter we have chosen from our $TW_{p,k}$ norm, so the only free variable we have here is $r$. Then the norm on our original val $v$ is the quotient norm induced on this new space:

$\|v\|_{TW_{p,k}} = \min_r{\|\langle v_2 \, v_3 \, v_5 \ldots v_n;0] + r\cdot \langle k \, k \, k \ldots k;-1]\|_q}$

where $q$ is the $q$-norm such that $\frac1q + \frac1p = 1$ (the standard definition of the dual of the $p$-norm).

Solving the minimization problem, we find the val transformation matrix X in the equilateral-weighted space is of the form

$\displaystyle X = \begin{bmatrix} I - krJ & r\vec j \end{bmatrix}$

where J is the all-ones matrix, and similarly j is the all-ones vector. For the Tenney-weighted space, multiply it by the Tenney weighter on the left.

The special case of the Tenney-Weil-Euclidean or Cangwu norm can be easily computed using the pseudoinverse, and r is given by

$\displaystyle r = k/(nk^2 + 1)$

where n is the dimensionality of the subgroup.