Normal forms: Difference between revisions

Wikispaces>genewardsmith
**Imported revision 142172981 - Original comment: **
Wikispaces>genewardsmith
**Imported revision 143888077 - Original comment: **
Line 1: Line 1:
<h2>IMPORTED REVISION FROM WIKISPACES</h2>
<h2>IMPORTED REVISION FROM WIKISPACES</h2>
This is an imported revision from Wikispaces. The revision metadata is included below for reference:<br>
This is an imported revision from Wikispaces. The revision metadata is included below for reference:<br>
: This revision was by author [[User:genewardsmith|genewardsmith]] and made on <tt>2010-05-15 02:14:23 UTC</tt>.<br>
: This revision was by author [[User:genewardsmith|genewardsmith]] and made on <tt>2010-05-22 03:16:05 UTC</tt>.<br>
: The original revision id was <tt>142172981</tt>.<br>
: The original revision id was <tt>143888077</tt>.<br>
: The revision comment was: <tt></tt><br>
: The revision comment was: <tt></tt><br>
The revision contents are below, presented both in the original Wikispaces Wikitext format, and in HTML exactly as Wikispaces rendered it.<br>
The revision contents are below, presented both in the original Wikispaces Wikitext format, and in HTML exactly as Wikispaces rendered it.<br>
Line 67: Line 67:


The point of steps three and four is that now the vals on the list correspond to a list of generators which are all positive (written additively) or equivalently greater than 1 (written multiplicatively.) Just as a normal comma list can be used to classify an abstract regular temperament, so can a normal val list. The val list is what on [[Graham Breed]]'s [[http://x31eq.com/temper/|web site]]  is called a "mapping", put into a canonical form.
The point of steps three and four is that now the vals on the list correspond to a list of generators which are all positive (written additively) or equivalently greater than 1 (written multiplicatively.) Just as a normal comma list can be used to classify an abstract regular temperament, so can a normal val list. The val list is what on [[Graham Breed]]'s [[http://x31eq.com/temper/|web site]]  is called a "mapping", put into a canonical form.
==Maple code==
Below is Maple code for finding the normal interval and val list, given an interval list or a val list.
with(padic, ordp):
with(LinearAlgebra):
log2 := proc(x) evalf(ln(x)/ln(2)) end:
pril := proc(n)
# log2 of first n primes
local i, u;
u := NULL;
for i from 1 to n do
u := u,log2(ithprime(i)) od;
[u] end:
revlist := proc(l)
# reverse of list
local i, v, e;
e := nops(l);
for i from 1 to e do
v[i] := l[e-i+1] od;
convert(convert(v,array),list) end:
plim := proc(q)
# prime limit of rational number q
local r, i, p;
r := 1;
i := 0;
while not (r=q) do
i := i+1;
p := ithprime(i);
r := r*p^ordp(q, p) od;
i end:
rat2monz := proc(q, n)
# converts rational number q to monzo of length n
local v, i;
for i from 1 to n do
v[i] := ordp(q, ithprime(i)) od;
convert(convert(v, array), list) end:
monz2rat := proc(m)
# converts monzo to rational number
local i, t;
t := 1;
for i from 1 to nops(m) do
t := t * ithprime(i)^m[i] od;
t end:
herm := proc(l)
# hermite normal form of listlist l
local M;
M := Matrix(l);
convert(convert(HermiteForm[Z](M), array), listlist) end:
nori := proc(l)
# normal interval list from list of intervals l
local i, p, u, v, w;
p := 1;
for i from 1 to nops(l) do
p := max(p, plim(l[i])) od;
u := [];
for i from 1 to nops(l) do
u := [op(u), revlist(rat2monz(l[i], p))] od;
v := herm(u);
for i from 1 to nops(l) do
u := revlist(v[i]);
u := monz2rat(u);
w[i] := u od;
u := [];
for i from 1 to nops(l) do
v := w[i];
if v&lt;1 then v:=1/v fi;
if not v=1 then u := [op(u), v] fi od;
revlist(u) end:
norv := proc(l)
# normal val list from list of vals l
local M, N, u, v, i, j, a;
u := herm(l);
j := Rank(Matrix(u));
v := NULL:
for i from 1 to j do
v := v,u[i] od;
v := [v];
M := Matrix(v);
N := SubMatrix(M, 1..j, 1..j);
N := N^(-1);
a := Vector[row](pril(j));
a := a.N;
u := NULL;
for i from 1 to j do
if a[i] &lt; 0 then u := u,-v[i] fi;
if a[i] &gt;= 0 then u := u,v[i] fi od;
[u] end:
</pre></div>
</pre></div>
<h4>Original HTML content:</h4>
<h4>Original HTML content:</h4>
Line 129: Line 227:
[1 log2(3) log2(5) ... log2(p)]. If the ith entry in the result is negative, multiply the corresponding val by -1. Return the result as the normalized val list.&lt;br /&gt;
[1 log2(3) log2(5) ... log2(p)]. If the ith entry in the result is negative, multiply the corresponding val by -1. Return the result as the normalized val list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The point of steps three and four is that now the vals on the list correspond to a list of generators which are all positive (written additively) or equivalently greater than 1 (written multiplicatively.) Just as a normal comma list can be used to classify an abstract regular temperament, so can a normal val list. The val list is what on &lt;a class="wiki_link" href="/Graham%20Breed"&gt;Graham Breed&lt;/a&gt;'s &lt;a class="wiki_link_ext" href="http://x31eq.com/temper/" rel="nofollow"&gt;web site&lt;/a&gt;  is called a &amp;quot;mapping&amp;quot;, put into a canonical form.&lt;/body&gt;&lt;/html&gt;</pre></div>
The point of steps three and four is that now the vals on the list correspond to a list of generators which are all positive (written additively) or equivalently greater than 1 (written multiplicatively.) Just as a normal comma list can be used to classify an abstract regular temperament, so can a normal val list. The val list is what on &lt;a class="wiki_link" href="/Graham%20Breed"&gt;Graham Breed&lt;/a&gt;'s &lt;a class="wiki_link_ext" href="http://x31eq.com/temper/" rel="nofollow"&gt;web site&lt;/a&gt;  is called a &amp;quot;mapping&amp;quot;, put into a canonical form.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- ws:start:WikiTextHeadingRule:4:&amp;lt;h2&amp;gt; --&gt;&lt;h2 id="toc2"&gt;&lt;a name="x-Maple code"&gt;&lt;/a&gt;&lt;!-- ws:end:WikiTextHeadingRule:4 --&gt;Maple code&lt;/h2&gt;
Below is Maple code for finding the normal interval and val list, given an interval list or a val list.&lt;br /&gt;
&lt;br /&gt;
with(padic, ordp):&lt;br /&gt;
with(LinearAlgebra):&lt;br /&gt;
&lt;br /&gt;
log2 := proc(x) evalf(ln(x)/ln(2)) end:&lt;br /&gt;
&lt;br /&gt;
pril := proc(n)&lt;br /&gt;
# log2 of first n primes&lt;br /&gt;
local i, u;&lt;br /&gt;
u := NULL;&lt;br /&gt;
for i from 1 to n do&lt;br /&gt;
u := u,log2(ithprime(i)) od;&lt;br /&gt;
[u] end:&lt;br /&gt;
&lt;br /&gt;
revlist := proc(l)&lt;br /&gt;
# reverse of list&lt;br /&gt;
local i, v, e;&lt;br /&gt;
e := nops(l);&lt;br /&gt;
for i from 1 to e do&lt;br /&gt;
v[i] := l[e-i+1] od;&lt;br /&gt;
convert(convert(v,array),list) end:&lt;br /&gt;
&lt;br /&gt;
plim := proc(q)&lt;br /&gt;
# prime limit of rational number q&lt;br /&gt;
local r, i, p;&lt;br /&gt;
r := 1;&lt;br /&gt;
i := 0;&lt;br /&gt;
while not (r=q) do&lt;br /&gt;
i := i+1;&lt;br /&gt;
p := ithprime(i);&lt;br /&gt;
r := r*p^ordp(q, p) od;&lt;br /&gt;
i end:&lt;br /&gt;
&lt;br /&gt;
rat2monz := proc(q, n)&lt;br /&gt;
# converts rational number q to monzo of length n&lt;br /&gt;
local v, i;&lt;br /&gt;
for i from 1 to n do&lt;br /&gt;
v[i] := ordp(q, ithprime(i)) od;&lt;br /&gt;
convert(convert(v, array), list) end:&lt;br /&gt;
&lt;br /&gt;
monz2rat := proc(m)&lt;br /&gt;
# converts monzo to rational number&lt;br /&gt;
local i, t;&lt;br /&gt;
t := 1;&lt;br /&gt;
for i from 1 to nops(m) do&lt;br /&gt;
t := t * ithprime(i)^m[i] od;&lt;br /&gt;
t end:&lt;br /&gt;
&lt;br /&gt;
herm := proc(l)&lt;br /&gt;
# hermite normal form of listlist l&lt;br /&gt;
local M;&lt;br /&gt;
M := Matrix(l);&lt;br /&gt;
convert(convert(HermiteForm[Z](M), array), listlist) end:&lt;br /&gt;
&lt;br /&gt;
nori := proc(l)&lt;br /&gt;
# normal interval list from list of intervals l&lt;br /&gt;
local i, p, u, v, w;&lt;br /&gt;
p := 1;&lt;br /&gt;
for i from 1 to nops(l) do&lt;br /&gt;
p := max(p, plim(l[i])) od;&lt;br /&gt;
u := [];&lt;br /&gt;
for i from 1 to nops(l) do&lt;br /&gt;
u := [op(u), revlist(rat2monz(l[i], p))] od;&lt;br /&gt;
v := herm(u);&lt;br /&gt;
for i from 1 to nops(l) do&lt;br /&gt;
u := revlist(v[i]);&lt;br /&gt;
u := monz2rat(u);&lt;br /&gt;
w[i] := u od;&lt;br /&gt;
u := [];&lt;br /&gt;
for i from 1 to nops(l) do&lt;br /&gt;
v := w[i];&lt;br /&gt;
if v&amp;lt;1 then v:=1/v fi;&lt;br /&gt;
if not v=1 then u := [op(u), v] fi od;&lt;br /&gt;
revlist(u) end:&lt;br /&gt;
&lt;br /&gt;
norv := proc(l)&lt;br /&gt;
# normal val list from list of vals l&lt;br /&gt;
local M, N, u, v, i, j, a;&lt;br /&gt;
u := herm(l);&lt;br /&gt;
j := Rank(Matrix(u));&lt;br /&gt;
v := NULL:&lt;br /&gt;
for i from 1 to j do&lt;br /&gt;
v := v,u[i] od;&lt;br /&gt;
v := [v];&lt;br /&gt;
M := Matrix(v);&lt;br /&gt;
N := SubMatrix(M, 1..j, 1..j);&lt;br /&gt;
N := N^(-1);&lt;br /&gt;
a := Vector[row](pril(j));&lt;br /&gt;
a := a.N;&lt;br /&gt;
u := NULL;&lt;br /&gt;
for i from 1 to j do&lt;br /&gt;
if a[i] &amp;lt; 0 then u := u,-v[i] fi;&lt;br /&gt;
if a[i] &amp;gt;= 0 then u := u,v[i] fi od;&lt;br /&gt;
[u] end:&lt;/body&gt;&lt;/html&gt;</pre></div>