Defactoring: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Cmloegcmluin (talk | contribs)
Cmloegcmluin (talk | contribs)
Line 376: Line 376:
=== cases temperaments can be regarding which of their mapping forms equal each other ===
=== cases temperaments can be regarding which of their mapping forms equal each other ===


[[File:Cases for temperament mapping forms.png|300px|right]]
[[File:Cases for temperament mapping forms3.png|300px|thumb|right]]
 
Considering only full-rank, integer mappings, we find three cases for a given temperament which is not enfactored. In all three cases, HNF is the same as DCF:
Considering only full-rank, integer mappings, we find three cases for a given temperament which is not enfactored. In all three cases, HNF is the same as DCF:
# The RREF, IRREF, and HNF are all ''different''. Example: [[Porcupine_family#Porcupine|porcupine]] with RREF of {{vector|{{map|1 0 <span><math>-\frac13</math></span>}} {{map|0 1 <span><math>\frac53</math></span>}}}}, IRREF of {{vector|{{map|3 0 -1}} {{map|0 3 5}}}}, and HNF of {{vector|{{map|1 2 3}} {{map|0 3 5}}}}.  
# The RREF, IRREF, and HNF are all ''different''. Example: [[Porcupine_family#Porcupine|porcupine]] with RREF of {{vector|{{map|1 0 <span><math>-\frac13</math></span>}} {{map|0 1 <span><math>\frac53</math></span>}}}}, IRREF of {{vector|{{map|3 0 -1}} {{map|0 3 5}}}}, and HNF of {{vector|{{map|1 2 3}} {{map|0 3 5}}}}.  

Revision as of 01:43, 17 September 2021

A regular temperament mapping is in defactored canonical form (DCF) when it is put into Hermite Normal Form (HNF) after being "defactored".

vs. normal form

"normal" vs. "canonical"

A mapping in canonical form uniquely identifies a set of mappings that are equivalent to it. Historically, the xenharmonic community has most often used the word normal for this idea, and evidence of this can be found on many pages across this wiki. And this is not wrong; normal forms are indeed often required to be unique. However, canonical forms are required to be unique even more often that normal forms are[1], and so we prefer the term canonical to normal for this purpose.

Also, using "canonical" helps establish a clear distinction from previous efforts to establish unique representations of equivalent mappings; due to its lack of historical use in RTT, it appears to be safe to simply use "canonical form" for short to refer to matrices in defactored canonical form.

vs. HNF

More importantly, and perhaps partially a result of this weak understanding of the difference between the conventions for normal and canonical forms, the xenharmonic community has mistakenly used HNF as if it provides a unique representation of equivalent mappings. To be more specific, HNF does provide a unique representation of matrices, i.e. from a perspective of pure mathematics, and so you will certainly find throughout mathematical literature that HNF is described as providing a unique representation, and this is correct. However, when applied to the RTT domain, i.e. to mappings, the HNF sometimes fails to identify equivalent mappings as such.

The critical flaw with HNF is its failure to defactor matrices[2]. The DCF that will be described here, on the other hand, does defactor matrices, and therefore it delivers a truly canonical result.

defactoring

Defactoring a matrix means to perform an operation on it which ensures that it is not "enfactored". And a matrix is considered to be "enfactored" if linear combinations of its rows can produce another row whose elements have a common factor (other than 1). This definition includes matrices whose rows already include a common factor, such as 24 38 56] which has a common factor of 2. Being enfactored is a bad thing. Enfactored matrices — those in the RTT domain, at least — are sick, in a way[3]; it's no accident that "enfactored" sounds sort of like "infected". Fortunately, the remedy is simple: all one has to do is "defactor" it — identify and divide out the common factor — to produce a healthy mapping.

Due to complications associated with enfactored mappings which we'll get into later in this article, we discourage treating them as representations of true temperaments.[4] Instead we recommend that they be considered to represent mere "temperoids": temperament-like structures.

vs. IRREF

Elsewhere, Integer Reduced Row Echelon Form, or IRREF, has been proposed as a normal form for mappings. It has a similar problem as HNF does, however, in that it does not always defactor matrices. Worse, even, sometimes IRREF introduces enfactoring where before there was none! For example, consider this mapping for 5-limit porcupine, [7 11 16] 22 35 51]. This mapping is not enfactored, but its IRREF is [3 0 -1] 0 3 5], which is 3-enfactored. More on this later.

defactored & enfactored vs. saturated and (con)torted

If you've studied RTT extensively, you've probably encountered the terms "saturated" and "contorted" that are sometimes used to describe mappings. These two terms each have several flaws, and so this article presents alternative terms that are clearer and more descriptive: "defactored" and "enfactored", respectively. These new terms were coined by Dave Keenan in collaboration with Douglas Blumeyer in June of 2021[5].

Several concerns with the term "saturation" may be identified:

  1. It does not have any obvious musical or mathematical meaning in this context (whereas enfactored and defactored do have obvious mathematical meaning).
  2. It has another unrelated meaning within xenharmonics: https://en.xen.wiki/w/Anomalous_saturated_suspension
  3. The most common everyday usage of that word is for "saturated fats", which are the bad kind of fats, so it has negative associations, despite "saturation" being the good state for a matrix to be in.
  4. Research on the tuning list archives suggests that Gene Ward Smith chose the word "saturation" because it was used in the mathematical software he was using at the time, Sage[6]. However, there is another common but conflicting sense of saturation for matrices which clamps entry values to between -1 and 1[7]. We think we should avoid propagating Sage's decision to overload matrix saturation with a second meaning.

As for the term "contorsion", the concerns with it are:

  1. Again, it does not have any obvious musical or mathematical meaning in this context.
  2. It's a word that was invented for RTT and has no meaning outside of RTT[8].
  3. It was made up due to false assumptions[9]. Through researching on tuning list archives, Dave and Douglas concluded that the associated concept of "torsion" was first described in January of 2002[10], with regards to commas used to form Fokker periodicity blocks. The concept of enfactoring was recognized in temperament mappings (though of course it did not yet go by that name), and — because torsion in lists of commas for Fokker blocks looks the same way as enfactoring looks in temperament comma-bases — torsion got conflated with it[11]. But they can't truly be the same thing; the critical difference is that periodicity blocks do not involve tempering, while temperaments do. In concrete terms, while it can make sense to construct a Fokker block with [-4 4 -1 in the middle and [-8 8 -2 = 2[-4 4 -1 at the edge, it does not make sense to imagine a temperament which tempers out 2[-4 4 -1 but does not temper out [-4 4 -1. Unfortunately, however, this critical difference seems to have been overlooked, and so it seemed that enfactored comma-bases exhibited torsion, and thus because mappings are the dual of comma-bases, then enfactoring of a mapping should be the dual of torsion, and because the prefix co- or con- means "dual" (as in vectors and covectors), the term "con-torsion" was coined for it. "Torsion" already has the problem of being an obscure mathematical term that means nothing to most people, "contorsion" just compounds that problem by being made up, and it is made up in order to convey a duality which is false. So while "torsion" could be preserved as a term for the effect on periodicity blocks (though there's almost certainly something more helpful than that, but that's a battle for another day[12][13]), the term "contorsion" must be banished from the RTT community altogether.

In accordance with this research and reasoning, this article henceforth will eschew the terms saturation and contorsion in favor of defactored and enfactored.

deeper dive on concerns re: contorsion concept; enfactorization illustrated with lattices to demonstrate pathology of temperoids

identifying enfactored mappings

immediately apparent enfactoring

Sometimes the enfactoring of a mapping is immediately apparent. For example:

24 38 56]

This mapping has only a single row, and we can see that every element in that row is even. Therefore we have a common factor of at least 2. In this case it is in fact exactly 2. So we can say that this is a 2-enfactored mapping.

Being enfactored tells us that it's wasteful to use this mapping. Specifically, being 2-enfactored tells us that we have 2x as many pitches as we need. Said another way, half of the pitches in our system are bringing nothing to the table, at least not in terms of approximating intervals built out of the 5-limit primes 2, 3, and 5, which is the primary goal of a temperament.

This is the mapping for 5-limit 24-ET. To be clear, we're not saying there's a major problem with 24 as an EDO. The point here is only that — if you're after a 5-limit temperament — you may as well use 12-ET. So we would consider 24-ET to stand for 24 Equal Temperoid.

Think of it this way: because every element is even, any JI interval you'd map with with the mapping must come out as an even number of steps of 24-ET, by the definition of the dot product, and every even step of 24-ET is just a step of 12-ET. Examples: [1 -2 1.24 38 56] = 24 - 76 + 56 = 4, [1 1 -1.24 38 56] = 24 + 38 - 56 = 6.

hidden enfactoring

Other times, enfactoring is less apparent. Consider this example:

[3 0 -1] 0 3 5]

This is a form of 5-limit porcupine, a rank-2 temperament. Looking at either row, neither map has a common factor. But remember that we also need to check linear combinations of rows. If we subtract the 2nd row from the 1st row, we can produce the row 3 -3 -6], which has a common factor of 3. So this mapping is also enfactored, even though it's not obvious from just looking at it.

If you're unsure why this 3 -3 -6] matters despite not being in [3 0 -1] 0 3 5], we may need to quickly review some linear algebra fundamentals. It may take some getting used to, but a mapping can be changed to another equivalent mapping (both mappings will map input vectors to the same scalars) by replacing any row with linear combinations of its rows. That is, we could replace either 3 0 -1] or 0 3 5] in our original matrix [3 0 -1] 0 3 5] to get [3 -3 -6] 0 3 5] or [3 0 -1] 3 -3 -6] and any of these mappings represent the same temperament.

well-hidden enfactoring

Sometimes the hidden common factor is even harder to find. Consider the mapping [6 5 -4] 4 -4 1]. To find this common factor, we need to linearly combine two of the first row 6 5 -4] and negative three of the 2nd row 4 -4 1] to produce 0 22 -11]. So we can see here that its common factor is 11. But there's no clear relationship between the numbers 2 and 3 and the number 11. And so we can begin to see that the problem of identifying enfactored mapping may not be very simple or straightforward.

defactoring methods

Even better than identifying enfactored mappings is actually full-on defactoring them. Here are two methods that do just that: Smith defactoring, developed by Gene Ward Smith[14], and column Hermite defactoring, developed by Dave and Douglas (the name comes, of course, from Hermite normal form, which it uses[15]).

Neither of these methods have been rigorously proven to always defactor mappings, but tests Douglas ran on thousands of random mappings strongly suggested that both methods work and give the exact same results as each other.

This article prefers column Hermite defactoring to Smith defactoring because it is:

  • Cheaper computationally, wasting less resources computing things irrelevant to the result[16],
  • Is easy to understand how it works, and can be worked out by hand (as we will demonstrate below),
  • If interested, you can see what the common factor is, if there was any.

Column Hermite defactoring could not have been developed, however, were it not for Gene's pioneering work with the Smith defactoring (what he calls the process of "saturating" a mapping). At first Dave and Douglas had no idea what the right reducing matrix of the Smith decomposition (the process which also provides the Smith normal form) had to do with common factors, only that it somehow magically worked. So they analyzed the Smith decomposition until they isolated its key actions which actually effect the defactoring, and then honed their method down to do only these necessary actions. Again, they wouldn't have known where to start were it not for Gene.

precedent: Smith defactoring

Dave and Douglas did much of their work in Wolfram Language (formerly Mathematica), a popular programming language used for math problems. In this section we'll give examples using it.

An input mapping [math]\displaystyle{ m }[/math], such as the example Gene gives on the xen wiki page for Saturation, [12 19 28 34] 26 41 60 72], in Wolfram Language you would have to write as a list:

m = {{12,19,28,34},{26,41,60,72}};

The implementation of Gene's method in Wolfram Language is simple. Just two lines:

rightReducingMatrix[m_] := Last[SmithDecomposition[m]]
smithDefactor[m_] := Take[Inverse[rightReducingMatrix[m]], MatrixRank[m]]

So the first thing that happens to [math]\displaystyle{ m }[/math] when you pass it in to smithDefactor[] is that it calls rightReducingMatrix[] on it. This will find the Smith decomposition (using a function built in to Wolfram Language), which gives you three outputs: the Smith normal form, flanked by its left and right reducing matrices. We're asked only for the right reducing matrix, so we grab that with Last[]. So that's what the function on the first line, rightReducingMatrix[], does.

Then Gene asks us to invert this result and take its first [math]\displaystyle{ r }[/math] rows, where [math]\displaystyle{ r }[/math] is the rank of the temperament. Invert[] takes care of the inversion, of course. MatrixRank[m] gives the count of linearly independent rows to the mapping, AKA the rank, or count of generators in this temperament. In this case that's 2. And so Take[list, 2] simply returns the first 2 entries of the list.

Almost done! Except Gene not only defactors, he also calls for HNF, as we would, to achieve canonical form.

normalize[m_] := Last[HermiteDecomposition[m]]

Similar to the Smith Normal Form, we do a decomposition, which gives you the normal form plus some other bonus results. In this case we actually want the normal form itself, and it happens to be the last element in the result list. So putting it all together, we defactor and then normalize:

rightReducingMatrix[m_] := Last[SmithDecomposition[m]];
smithDefactor[m_] := Take[Inverse[rightReducingMatrix[m]], MatrixRank[m]];

normalize[m_] := Last[HermiteDecomposition[m]];

m = {{12,19,28,34},{26,41,60,72}};
normalize[smithDefactor[m]]
→ {{1,0,-4,-13},{0,1,4,10}}

And that result matches what Gene finds in that xen wiki article. Defactoring and normalizing is equivalent to canonicalization. 

new development: column Hermite defactoring

Here is the implementation for column Hermite defactoring:

hermiteUnimodular[m_]:=Transpose[First[HermiteDecomposition[Transpose[m]]]]
columnEchelonDefactor[m_]:=Take[Inverse[hermiteUnimodular[m]],MatrixRank[m]]

So this implementation begins by transposing the matrix, so that when it then performs the Hermite Decomposition, it is doing a column decomposition. We then take the unimodular matrix from the decomposition using First[], and Transpose[] it to in effect undo the transposition we did at the beginning.

by hand

In an effort to demystify the effects of column Hermite defactoring, we will here walk though an example manually. It's a silly example, but suppose we have the mapping [6 5 4] 4 -4 1]. Spoiler alert: it is 11-enfactored.

This is pretty long so I've put it in a collapsible section. Just click "expand" if you're interested:

canonical comma-bases

DCF is not only for mappings. Comma-bases — the duals of mappings — may also be put into DCF, as long as they are first antitransposed[17], and then antitransposed again at the end, or in other words, you sandwich the defactoring and HNF operations between antitransposes.

DCF is arguably even more important for comma-bases than it is for mappings, because enfactored mappings at least have clear musical meaning, while enfactored comma-bases are little but a wellspring of confusion. In other words, 24 38 56] may not be a true temperament, but it still represents a temperoid and an EDO. However, {{

other stuff to report

The rest of the material in this article is not strictly necessary to understand canonical form and defactoring, but for posterity the work Dave and Douglas did to attain their insights has been summarized here in case it may be helpful to anyone else who might want to iterate on this later.

criteria

In addition to being canonical and defactored, DCF has other important properties, which probably go without saying in the context of RTT mappings, but here they are just in case:

  • integer: contains only integer terms.
  • full-rank: removes rank deficiencies, or in other words, rows that are all zeros
  • preserves genuine unit-fraction-of-an-prime periods: at first glance, when a pivot is not equal to 1, it might trigger you to think that the mapping is enfactored. But temperaments can legitimately have generators that divide primes evenly, such as 5-limit Blackwood, [5 8 0] 0 0 1], which divides the octave into 5 parts.[18]

exclusion of generator size target criteria; mingen form

Initially, Dave and Douglas considered the proposal of a new standard RTT mapping form as an opportunity to include everything and the kitchen sink — in this case, to additionally massage generator sizes to fit a desirable rubric. It was ultimately decided to stay conceptually focused when drafting the proposal, leaving generator size out of the mix. Also, the particular generator size target they sought — named "mingen" — turned out to be a bit of a rabbit hole, especially above rank-2, both in terms of mathematical reality and engineering practicality. The results of those efforts are documented here: Generator size manipulation#mingen_form

relationship between various matrix echelon forms

There are several well-known echelon forms for matrices that predate DCF. Let's review them and their properties.

The most general form, with the fewest constraints, is simply called Row Echelon Form, or REF. Its only constraint is echelon[19] form: each row's pivot, or first nonzero entry, is strictly to the right of the preceding row's pivot. This single constraint is fairly weak, and therefore REF does not produce a unique representation. This constraint is shared by every matrix form discussed here.[20][21]

In the below example, [math]\displaystyle{ x_{ij} }[/math] represents any number.

REF
x₁₁ x₁₂ x₁₃ x₁₄ x₁₅
0 x₂₂ x₂₃ x₂₄ x₂₅
0 0 0 x₃₄ x₃₅

Integer Row Echelon Form, or IREF, is, unsurprisingly, any REF which meets an additional integer constraint, or in other words, that all of its entries are integers. This is still not a sufficiently strict set of constraints to ensure a unique representation.

In the below example, [math]\displaystyle{ n_{ij} }[/math] represents any number.

IREF
n₁₁ n₁₂ n₁₃ n₁₄ n₁₅
0 n₂₂ n₂₃ n₂₄ n₂₅
0 0 0 n₃₄ n₃₅

Reduced Row Echelon Form, or RREF, takes REF in a different direction than IREF. Instead of stipulating anything about integers, it requires that the matrix is reduced, i.e. that the pivots are exactly equal to 1. This may require dividing rows by a number such that some resulting entries are no longer integers. Actually, there's a second part to the "reduced" constraint: each pivot column (a column which contains any row's pivot) has zeros for all other entries besides the pivot it contains. Due to these strict constraints, the RREF of a matrix is the first one we've looked at so far here which does ensure uniqueness.

RREF
1 0 x₁₃ 0 x₁₅
0 1 x₂₃ 0 x₂₅
0 0 0 1 x₃₅

So IREF and RREF make a Venn diagram inside the category of REF: some IREF are RREF, but there are some RREF that are not IREF and some IREF that are not RREF. When we scope the situation to a specific matrix, however, because RREF is a unique form, this means that one or the other sector of the Venn diagram for RREF will be empty; either the unique RREF will also be IREF (and therefore the RREF-but-not-IREF sector will be empty), or it will not be IREF (and vice versa).

Integer Reduced Row Echelon Form, or IRREF is the next form to discuss. Based on the name, one might expect this form to be a combination of the constraints for RREF and IREF, and therefore if represented in an Euler diagram (generalization of Venn diagram) would only exist within their intersection. However this is not the case. That's because the IRREF does not include the key constraint of RREF which is that all of the pivots must be 1. IRREF is produced by simply taking the unique RREF and multiplying each row by whatever minimum value is necessary to make all of the entries integers[22]. Of course, this sometimes results in the pivots no longer being 1, so sometimes it is no longer RREF. It is always still REF, though[23], and because it is also always integer, that makes it always IREF; therefore, IRREF is strictly a subcategory of IREF. And because the RREF is unique, and the conversion process does not alter that, the IRREF is also unique.

IRREF
n₁₁ 0 n₁₃ 0 n₁₅
0 n₂₂ n₂₃ 0 n₂₅
0 0 0 n₃₄ n₃₅

The multiplication of rows by whatever integer is required to clear the denominators of the RREF form is the action which is responsible for causing enfactoring, whenever the IRREF produces an enfactored mapping from a defactored one.

It is not possible for an RREF to be IREF without also being IRREF.

Hermite Normal Form, or HNF, is the last form to discuss. This one's constraints begin with echelon form and integer, therefore every HNF is also IREF. But HNF is not exactly reduced; instead, it is normalized, which — similarly to reduced — is a two-part constraint. Where reduced requires that all pivots be exactly equal to 1, normalized requires only that all pivots be positive (positive integers, of course, due to the other integer constraint). And where reduced requires that all entries in pivot columns besides the pivots are exactly equal to 0, normalized requires only that all entries in pivot columns below the pivots are exactly equal to 0, while entries in pivot columns above the pivots only have to be strictly less than the pivot in the respective column (while still being non-negative).[24][25][26] The normalization HNF uses is cool because this constraint, while strictly less strict than the reduced constraint used by RREF, is still strict enough to ensure uniqueness, but loose enough to ensure the integer constraint can be simultaneously satisfied, where RREF cannot ensure that.

So HNF has a lot in common with IRREF, which is the IREF you find by converting the RREF, but it is not always the same as IRREF.

Defactored Canonical Form, or DCF is closely related to HNF, because the second step of finding the DCF is taking the HNF. So the DCF is always a HNF, and therefore it has all the same properties of being echelon, integer, and normalized, and in turn therefore it also provides a unique representation. However it is not necessary the same HNF of the original mapping, due to the first step being defactoring; it is the same as as HNF except when the original mapping is enfactored.

In the below example, [math]\displaystyle{ p_{ij} }[/math] represents any positive integer, and [math]\displaystyle{ a_{ij} }[/math] represents any nonnegative integer less than the [math]\displaystyle{ p }[/math] in its column.

HNF and DFC
p₁₁ a₁₂ n₁₃ a₁₄ n₁₅
0 p₂₂ n₂₃ a₂₄ n₂₅
0 0 0 p₃₄ n₃₅

There is also the Smith Normal Form, or SNF, but we won't be discussing it in this context, because putting a mapping into SNF obliterates a lot of meaningful RTT information. SNF is also echelon, and integer, so like HNF it is also always IREF. But SNF requires that every single entry other than the pivots are zero, and that the pivots all fall exactly along the main diagonal of the matrix. The SNF essentially reduces a matrix down to the information of what its rank is and whether it is enfactored. For example, all 5-limit rank-2 temperaments such as meantone, porcupine, mavila, hanson, etc. have the same SNF: [1 0 0] 0 1 0]. Or, if you 2-enfactor them, they will all have the SNF [1 0 0] 0 2 0]. So while the SNF is closely related to defactoring, it is not itself a useful form to put mappings into.[27]

SNF
p₁₁ 0 0 0 0
0 p₂₂ 0 0 0
0 0 p₃₃ 0 0

cases temperaments can be regarding which of their mapping forms equal each other

Considering only full-rank, integer mappings, we find three cases for a given temperament which is not enfactored. In all three cases, HNF is the same as DCF:

  1. The RREF, IRREF, and HNF are all different. Example: porcupine with RREF of [1 0 [math]\displaystyle{ -\frac13 }[/math]] 0 1 [math]\displaystyle{ \frac53 }[/math]], IRREF of [3 0 -1] 0 3 5], and HNF of [1 2 3] 0 3 5].
  2. The RREF, IRREF, HNF are all the same. Example: meantone with all equal to [1 0 -4] 0 1 4]. This case is quite rare.
  3. The IRREF and HNF are the same, but the RREF is different. Example: hanson with IRREF and HNF of [1 0 1] 0 6 5] but RREF of [1 0 1] 0 1 [math]\displaystyle{ \frac56 }[/math]].

And there are three corresponding cases when a temperament is enfactored. In all three cases, the key difference is that HNF is no longer the same as DCF, with the only difference being that the common factor is not removed. In all cases below, the examples are shown with a common factor of 2 introduced in their second row, which stays behind in the second row of the HNF:

  1. Now all four are different. Example: enfactored porcupine, e.g. [15 24 35] 14 22 32] causes the HNF to be [1 2 3] 0 6 10].
  2. Everything is still the same now, except HNF. Example: enfactored meantone, e.g. [5 8 12] 14 22 32] causes the HNF to be [1 0 -4] 0 2 8]. This case, like the corresponding unenfactored state, is also quite rare.
  3. The only match now is between IRREF and DCF. In other words, the HNF and DCF diverged, and it was the DCF which remained the same as IRREF. Example: enfactored hanson, e.g. [15 24 35] 38 60 88] causes the HNF to be [1 0 1] 0 12 10].

There is also a final case which is incredibly rare. It can be compared to the #3 cases above, the ones using hanson as their example. The idea here is that when the HNF and DCF diverge, instead of DCF remaining the same as IRREF, it's the HNF that remains the same as IRREF. I haven't found any practical temperoids with this case, but [165 264 393] 231 363 524] will do it[28], with IRREF and HNF of [33 0 -131] 0 33 131], DCF of [1 1 0] 0 33 131], and RREF of [1 0 [math]\displaystyle{ \frac{-131}{33} }[/math]] 0 1 [math]\displaystyle{ \frac{131}{33} }[/math]].

sum-and-difference defactoring

When in development on an ideal defactoring method — the effort which culminated in column Hermite defactoring — Dave and Douglas invested a great deal of time in a defactoring method which still has some advantages over column Hermite defactoring but was ultimately rejected. This other method is called "sum-and-difference" defactoring, or SAD defactor (it is sad partially because it didn't work out).

SAD defactoring's key advantage over column Hermite defactoring is that its mechanism for removing common factors is more straightforward to see and understand, as we will see in the next section.

SAD defactoring's key reason for rejection is that a number of edge cases were discovered that caused its algorithm to balloon in complexity, both insofar as it could be implemented in code as well as understood by humans.

how it works

Originally Dave was inspired by what Paul Erlich wrote on the article for torsion on the Tonalsoft site. The algorithm simply checks every possible combination of sums and differences of rows. You have to check all [math]\displaystyle{ \frac{3^r - 1}{2} }[/math] sums and differences where [math]\displaystyle{ r }[/math] is the rank of the mapping. For example, for a rank-3 mapping with rows [A B C, you would need to check

  • A
  • B
  • C
  • A+B
  • A-B
  • A+C
  • A-C
  • B+C
  • B-C
  • A+B+C
  • A+B-C
  • A-B+C
  • A-B-C

In other words, for each of A, B, and C, you have to check -1 of it, 0 of it, or 1 of it. You don't need to check any counts less than -1 or greater than 1, because then you'd of course be introducing a common factor to the mapping!

Anyway, the point is, if any of these combinations has a common factor, you simply remove the common factor, then replace a row in the mapping with this combined-and-defactored row.

problem 1. edge case: multiple common factors

Some matrices can have multiple common factors, such as {{vector|17 16 -4} 4 -4 1]]. The SNF of this mapping is [1 0 0] 0 33 0], and that 33 is actually a double common factor because it's not prime, but the product of 3 and 11. SAD defactoring unfortunately only removes one of these factors at a time, and so it therefore needs to be designed to perform recursively until no change occurs in an iteration, at which point all common factors have been removed.

problem 2. edge case: well-hidden common factors

SAD defactoring was found to fail in the case of well-hidden common factors, i.e. ones where there are no common factors to be found in sums or differences of the rows, but are to be found in sums or differences of multiples of these rows. In order to solve this problem, SAD defactoring would need to be reworked to check every possible combination of integer multiples of each row, potentially up to the largest absolute value of integer in the given mapping, which would cause it to become intractably slow to compute.

Fortunately this did not turn out to be necessary. The solution here was to do one pass of HNF before doing the defactoring (and still do the HNF pass at the end too, when going for a canonical form). This pre-pass of HNF doesn't manage to remove the common factor, but it does at least reveal it. For example, in the case of [6 5 -4] 4 -4 1], the HNF is [2 9 -5] 0 22 -11], so that hidden common factor of 11 has now been revealed, put in a form where SAD is capable of removing it.

So this is better than initially thought. But still not great to have to add another HNF pass at the onset.

problem 3. picking the correct row to replace

Initially it was thought that, upon finding a common factor in a combination of rows and removing it, it would be acceptable to replace any row of the mapping with the fixed row, and that we could then simply replace the first row. However this is not the case. When replacing a row with a defactored sum or difference, the replaced row has to be one of those involved in the sum or difference. It can always be the topmost one of those, but it can't always be the topmost row of the matrix. So this increases the complexity of the algorithm.

problem 4. failure to remove rank-deficient rows

The way Smith defactoring works, and column Hermite defactoring works, a step which ensures that the final number of rows of the output is equal to the rank is built into how the core of the implementation works already. However, for SAD defactoring, a special extra pass is required to ensure this.

At this point, SAD defactor was considered "a mess".

Wolfram Language implementation

This is the furthest progress that was made on SAD defactor before efforts were shifted to column Hermite defactor. This implementation still exhibits problems 2, 3, and 4; only problem 1 was solved here.

sadDefactor[m_] := Module[{reduced, linCombs,linCombsDisarmed, maybeDisarmedRow, thing},
    linCombs = linCombsToCheck[m];
    linCombsDisarmed = Map[extractGcd, linCombs];
    maybeDisarmedRow = Complement[linCombsDisarmed, linCombs];
        
    If[Length[maybeDisarmedRow]==0, m, sadDefactor[Join[{m[[1]]},{ maybeDisarmedRow[[1]]}]]]
]

minors'n'back defactoring

Another technique which was experimented with took advantage of the fact that the list of minor determinants (or simply "minors") of a mapping is guaranteed to include any common factor as its entries' GCD. So, if one simply converted a mapping to its list of minors, removed the GCD (at which point you would have what in RTT is called a canonical multimap, or wedgie), and then performed an "anti-minors" operation to get back to a mapping form, any common factors should be removed.

Following Gene Ward Smith's method for computing anti-minors as described here and here, the anti-minors method was developed. Unfortunately it required defactoring to work. So it couldn't be used as part of a defactoring solution itself.

duality in LA and VEA

RTT could be said to be practiced in two major flavors: LA, or Linear Algebra, and VEA, or Varianced Exterior Algebra. The former uses only vectors, covectors, and matrices. The latter uses multivectors and multicovectors instead of matrices, where a key example of a multivector is a "wedgie". Each RTT flavor has a notion of a dual.

LA's dual it is the null-space operation, which takes you back and forth between the two matrix representations of a temperament: its mapping and its comma-basis[29]. VEA's dual, on the other hand, is closely related to the Grassman/orthogonal complement in exterior algebra as well as the complement operation from MLA (multilinear algebra) which is sometimes referred to as the "Hodge dual" or "Hodge star", and it takes you back and forth between the two multi(co)vector representations of a temperament: the multimap and the multicomma.

One of the primary motivations for developing a canonical form for mappings (and comma-bases) was to achieve for the LA flavor of RTT a key thing it was missing that the VEA flavor had: a way to uniquely identify temperaments. In VEA, this was easy, because any enfactoring would be readily identifiable as a GCD>1 in the multimap or multicomma. In fact, the definition of the "wedgie" calls for removing such GCDs when computing it from a mapping.

Something that was observed while developing the canonical form for LA was that the dual operation for LA, null-space, eliminated any enfactoring. On the other hand, the dual operation for VEA preserves it. This might be another strike against VEA.

However, because the VEA wedgie calls for removing GCDs, we can assume that its dual would also build in the removal of any GCD. So it's not really an additional strike.

It could be construed as an extra point for LA, however, because it shows how its dual operation automatically eliminates the pathological aspect of enfactoring. This captures the truth of how an enfactored mapping has no effect on tempered commas, and vice versa.

references

  1. According to the Wikipedia page for canonical form, 'the distinction between "canonical" and "normal" forms varies from subfield to subfield. In most fields, a canonical form specifies a unique representation for every object, while a normal form simply specifies its form, without the requirement of uniqueness.'
  2. This is because dividing rows is not a permitted elementary row operation when computing the HNF. See: https://math.stackexchange.com/a/685922
  3. According to saturation, "...if [an RTT matrix] isn't saturated the supposed temperament it defines may be regarded as pathological..."
  4. As Graham Breed writes here, "Whether temperaments with contorsion should even be thought of as temperaments is a matter of debate."
  5. Many, many other terms were considered before arriving at defactored and enfactored, including but not limited to: repeated, (up/down)sampled, decimated, divided/multiplied, divisive/multiplicative, completed/depleted/repleted/pleated, efficient, brown, dry, spongy/holey, fluffy, corrugated, copied, shredded, tupled, tupletted, enphactored (where the ph stood for possibly hidden)...
  6. See: https://yahootuninggroupsultimatebackup.github.io/tuning-math/topicId_18026.html and https://doc.sagemath.org/html/en/reference/search.html?q=index_in_saturation
  7. See https://math.stackexchange.com/questions/1964814/linear-transformation-of-a-saturated-vector and https://faculty.uml.edu//thu/tcs01-june.pdf
  8. Here is the tuning list post where it was coined by Paul Erlich: https://yahootuninggroupsultimatebackup.github.io/tuning-math/topicId_2033.html#2456
  9. Authors note: to be absolutely clear, I don’t care who said what or how misconceptions arose (except insofar as it helps dispel any further misconceptions, some of which certainly may be my own). I have basically infinite sympathy for anyone who gets confused over this topic. It took my good friend Dave and I months of back and forth theorization, argumentation, and diagramming before we were able to settle on an explanation we both understood and agreed upon. I am not intending to get in the business of slinging blame (or credit) around. As far as I’m concerned, as long as we can have meaningful discussion with each other, and hopefully eventually arrive at conclusions that are more musically and intellectually empowering than we had previously, then we’re doing well together. Would I have make these mistakes myself? Yes! I have literally dozens of recent emails proving that I would have gone for the same duality myself, due to a case of asymmetry-phobia.
  10. See: https://yahootuninggroupsultimatebackup.github.io/tuning-math/topicId_2937 which is also referred to here http://tonalsoft.com/enc/t/torsion.aspx
  11. See: https://yahootuninggroupsultimatebackup.github.io/tuning-math/topicId_2033.html#2405
  12. I might suggest we call it a "shredded periodicity block", due to the way how the paths that the multiple parallel generators take around the block look like shreds of paper, were the periodicity block imagined as a sheet of paper run through a paper shredder.
  13. Furthermore, care should be taken to recognize the difference in behavior between, say

    [math]\displaystyle{ \left[ \begin{array} {r} -8 & -30 \\ 8 & -3 \\ -2 & 15\\ \end{array} \right] }[/math]

    when it is used as a list of 5-limit commas defining a periodicity block versus when it is used as a comma basis for a temperament, namely, that in the first case the fact that the first column has a common factor of 2 and the second column has a common factor of 3 is meaningful, i.e. the 2-enfactorment will affect one dimension of the block and the 3-enfactorment will affect a different dimension of the block, or in other words, we can say that the commas here are individually enfactored rather than the entire list being enfactored, while in the second case there is no such meaning to the individual columns' factors of 2 and 3, respectively, because it would be equivalent of any form where the product of all the column factors was 6, or in other words, all that matters is that the comma-basis as a whole is 6-enfactored here. So perhaps it would be best if, for periodicity blocks, the term "enfactored" was avoided altogether, and instead commas were described as "2-torted".
  14. but the name comes from a different Smith: Henry John Stephen Smith, for whom the Smith normal form is named, which this method uses
  15. named for Charles Hermite, who was French, by the way, and so his name is pronounced more like err-MEET, not like HER-might
  16. Using the following code in Wolfram Language:
    hermiteUnimodular[m_]:=Transpose[First[HermiteDecomposition[Transpose[m]]]]
    columnEchelonDefactor[m_]:=Take[Inverse[hermiteUnimodular[m]],MatrixRank[m]]

    rightReducingMatrix[m_] := Last[SmithDecomposition[m]]
    smithDefactor[m_] := Take[Inverse[rightReducingMatrix[m]], MatrixRank[m]]

    ms = {};
    Do[
        d = RandomInteger[{2,6}];
        r = RandomInteger[{1,d}];
        m = RandomInteger[{-99,99},{r,d}];
        ms = Join[ms, {m}],
        1000
    ]

    AbsoluteTiming[Do[smithDefactor[m],{m,ms}]]

    The first several results for Smith defactoring took (in ms) 3.55919, 3.45199, 3.58493, 3.63464, 3.80917, 3.77151, while the first several results for column Hermite defactoring took 3.30063, 3.39137, 3.33808, 3.21195, 3.16469, 3.20419. So this suggests a slight edge for column Hermite defactoring.
  17. See a discussion of the antitranspose here: https://en.xen.wiki/w/User:Cmloegcmluin/Sandbox#null-space
  18. Any form that enforces pivots all be 1's would fail this criteria.
  19. The name "echelon" is a French word for a military troop formation with a similar triangular shape: https://en.wikipedia.org/wiki/Echelon_formation.
  20. Note that the definition of REF is inconsistent and sometimes it includes some of the constraints of RREF, discussed further below. See: https://www.statisticshowto.com/matrices-and-matrix-algebra/reduced-row-echelon-form-2/
  21. REF also requires that all rows that are entirely zeros should appear at the bottom of the matrix. However this rule is only relevant for rank-deficient matrices. We'll be assuming all matrices here are full-rank, so we don't have to worry about this.
  22. Alternatively, IRREF can be computed by finding the null-space of a mapping, or in other words, the corresponding comma-basis for the temperament represented by the mapping, and then in turn taking the null-space of the comma-basis to get back to an equivalent mapping. The relationship between the process for finding the IRREF from the RREF and this process is not proven, but thousands of automated tests run as an experiment strongly suggest that these two techniques are equivalent.

    rref[m_] := RowReduce[m]
    multByLcd[row_] := Apply[LCM,Denominator[row]]*row
    irref[m_] := Map[multByLcd,rref[m]]

    nullSpaceAndBack[m_]:=Reverse[NullSpace[Reverse[NullSpace[m],2]],2]


    output = "";
    Do[
    d = RandomInteger[{2,6}];
    r = RandomInteger[{1,d-1}];
    m = RandomInteger[{-99,99},{r,d}];

    n = nullSpaceAndBack[m];
    i = irref[m];

    If[n!=i,output = output <> "bad" <> n <> i, output = output <> "ok "],
    10000
    ]

    Print[output]


    There is a difference in that IRREF does not remove rows of zeros in the end for rank-deficient mappings, while this "nullspace'n'back" does, but for most normal cases, they're the same.
  23. Also, it will always still satisfy the second aspect of reduced, i.e. that all other entries in pivot columns besides the pivots are zeroes.
  24. The exact criteria for HNF are not always consistently agreed upon, however.
  25. There is also a rarely mentioned Hermite Canonical Form, or HCF, described here: http://home.iitk.ac.in/~rksr/html/03CANONICALFACTORIZATIONS.htm, which sort of combines the HNF's normalization constraint and the RREF's reduced constraint (all pivots equal 1, all other entries in pivot columns are 0, both above and below the pivot), but we didn't find it useful because due to its constraint that all pivots be 1, it does not preserve periods that are genuinely unit fractions of an octave. It also doesn't qualify as an echelon form, which becomes apparent only when you use it on rank-deficient matrices, because it doesn't require the rows of all zeros to be at the bottom; instead it (bizarrely, as far as I can tell, though maybe it's related to how the SNF requires all pivots exactly along the main diagonal) requires the rows to be sorted so that all the pivots fall on the main diagonal.
  26. We are using "row-style" Hermite Normal Form here, not "column-style"; the latter would involve simply flipping everything 90 degrees so that the echelon requirement was that pivots be strictly below the pivots in the previous column, and that pivot rows are considered for the normalization constraint rather than pivot columns.
  27. Here is a useful resource for computing the Smith Normal Form manually, if you are interested: https://math.stackexchange.com/questions/133076/computing-the-smith-normal-form
  28. AKA 165b⁴c¹⁹&231b⁶c²⁴, which tempers out the 7.753¢ comma [-131 131 -33!
  29. with the stipulation that the anti-null-space operation that gets you from the comma-basis back to the mapping requires an anti-transpose sandwich.