# Lesfip scales

## Introduction

A **lesfip scale** (LEast Squares FIxed Point) is a scale which for some range of values for error tolerance, is a fixed point for the least squares algorithm minimizing the sum of squared error relative to some target list of intervals. That is, when we minimize the sum of the squares of all of the errors less than some fixed value such as seven cents, we obtain the same scale back again.

A lesfip scale may be found by choosing a scale, a target set of intervals, and an error tolerance. The least squares optimization is iterated until a fixed point is arrived at. Occasionally there may be a problem when the system becomes underdetermined, which can be fixed by increasing the error tolerance by some amount for one iteration. Two distinct scales can easily converge on one lesfip scale; an example is provided by the famous well temperaments Vallotti-Young and Werckmeister III, which converge onto the same temperament extraordinaire, val-werck. It can also happen that during the iteration two notes merge into one, decreasing the size of the scale.

## Definition

Suppose S are the notes of a scale, expressed in terms of a set of notes 0 < s < 1200, for s∊S. This is the set of pitch classes of the scale, excepting the unison/octave class, expressed in terms of cents, of a periodic scale. Let C likewise be a set 0 < c < 1200 for c∊C of consonance targets, for example the values in cents of all members of a q-limit tonality diamond. Let e be a positive real number denoting the maximum allowed error in an approximation of an interval of the scale to an element of the set of target consonances, expressed in cents.

Now form two sums: let A be the sum ∑(Xs - c)^2 over all pairs s∊S, c∊C with |s-c| < e, where Xs is a variable corresponding to s. Let B be the sum ∑(Xs - Xt - c)^2 over all triples s∊S, t∊S, c∊C with s>t and |s-t-c| < e, where Xs and Xt are variables corresponding to s and t. Now let Q = A+B. We define L(S, C, e) to be the set S' of values for the variables minimizing Q, if a unique minimum exists. This can be found by differentiating Q with respect to each of the variables, leading to n linear equations in n unknowns. If the system is underdetermined this might not lead to a unique solution; in this case L(S, C, e) is undefined. By adding more members to C, increasing the value of e, or both, it's possible to find a unique solution to a different, but related, problem.

A lesfip scale is a fixed point of L for a given choice of C and some range a < e < b of values for e; that is, a set S such that L(S, C, e) = S, together with (in Scala format) 1200, representing the octave class. Lesfip are discrete points in the space of possible n-note octave repeating scales, surrounded by a basin of attraction. They can be found by iterating L, discarding the extra note when two notes converge to the same value, and stopping when a fixed point is reached.

## Examples

Examples of lesfip scales can be found at Scalesmith.