MOS scale

From Xenharmonic Wiki
Revision as of 14:25, 18 April 2012 by Wikispaces>genewardsmith (**Imported revision 322232132 - Original comment: **)
Jump to navigation Jump to search

IMPORTED REVISION FROM WIKISPACES

This is an imported revision from Wikispaces. The revision metadata is included below for reference:

This revision was by author genewardsmith and made on 2012-04-18 14:25:07 UTC.
The original revision id was 322232132.
The revision comment was:

The revision contents are below, presented both in the original Wikispaces Wikitext format, and in HTML exactly as Wikispaces rendered it.

Original Wikitext content:

[[toc|flat]]
----

=Definition= 
An **MOS** or **Moment Of Symmetry** is a scale in which every interval except for the period comes in two sizes. The term "MOS," and the method of scale construction it entails, were invented by Erv Wilson in 1975. His original paper can be found at [[http://anaphoria.com/mos.PDF]]. There is also an introduction at [[http://anaphoria.com/wilsonintroMOS.html]].

Sometimes, scales are defined with respect to a period and an additional "equivalence interval," considered to be the interval at which pitch classes repeat. MOS's in which the equivalence interval is a multiple of the period, and in which there is more than one period per equivalence interval, are sometimes called **Multi-MOS**'s. MOS's in which the equivalence interval is equal the period are sometimes called **Strict MOS**'s. MOS's in which the equivalence interval and period are simply disjunct, with no rational relationship between them, are simply MOS and have no additional distinguishing label.

With a few notable exceptions, Wilson generally focused his attention on MOS with period equal to the equivalence interval. Hence, some people prefer to use the term [[Distributional Evenness|distributionally even scale]], with acronym DE, for the more general class of scales which are MOS with respect to other intervals. MOS/DE scales are also sometimes known as //well-formed scales//, the term used in the 1989 paper by Norman Carey and David Clampitt. A great deal of interesting work has been done on scales in academic circles extending these ideas.

See [[Mathematics of MOS]] for a more formal definition and a discussion of their mathematical properties.

===Names for MOS=== 
Since numbers tend to be dry, Graham Breed has proposed a [[MOSNamingScheme|naming scheme for MOS scales]].

===MOS in equal temperaments=== 
In an equal temperament, all intervals are integer multiples of a smallest unit. If the equal temperament is N-EDO and the period is an octave, the sizes of the large and small steps will be p/N and q/N, with p > q. We then have L(p/N) + s(q/N) = 1, which on multiplying through by N gives us

Lp + sq = N.

which is a linear diophantine equation. Solving this by standard methods, and requiring L and s to be positive, gives us the [L, s] pair for the MOS. If some other quantity of equal steps gives the period, we may make the appropriate adjustment.

===Blackwood R constant=== 
In the context of the "recognizable diatonic" scales deriving from the Farey pair [1/2, 3/5] [[http://en.wikipedia.org/wiki/Easley_Blackwood,_Jr.|Easley Blackwood Jr.]] defined a characterizing constant R which we may generalize to any MOS as follows. If a/b < g < c/d is a generator with the given Farey pair, take the ratio of relative errors R = (bg - a)/(c - dg). Since this is a ratio of positive numbers, it is positive. As g tends towards a/b it tends to zero, and as g goes to c/d R goes to infinity. When g equals (a + c)/(b + d) it takes the value 1, and the range of propriety is 1/2 <= R <= 2.

When R is less than 1, it represents the ratio in (logarithmic) size between the smaller and the larger step. When it is greater than 1, it is larger/smaller. By replacing g with 1 - g if necessary, we can reduce always to the case where R>1 (or R<1 if we prefer.)

=Catalog of MOS=
This is a [[Catalog of MOS|catalog]] of the various MOS, in the Ls notation.

=Variations on MOS Scales= 
# [[MODMOS Scales]] are derived from chromatic alterations of one or more tones of an MOS scale, typically by the interval of L-s, the "chroma".
# [[Muddle|Muddles]] are subsets of MOS parent scales with the general shape of a smaller (and possibly unrelated) MOS scale.
# [[MOS Cradle]] is a technique of embedding MOS-like structures inside MOS scales and may or may not produce subsets of MOS scales.

=MOS As Applied To Rhythms= 
David Canright was the first to suggest Fibonacci Rhythms in 1/1. This lead to Kraig Grady to be the first to apply MOS patterns to rhythms. Two papers on the subject can be found here [[http://anaphoria.com/hora.PDF]] and [[http://anaphoria.com/horo2.PDF]]
MOS structures and thinking can be applied to the design of rhythms as well. See [[MOS Rhythm Tutorial]]

=Algorithms= 
Below is some Maple code for various mathematical routines having to do with MOS. If you have access to Maple, you can of course copy and run these programs. Even if you do not, since Maple code makes better pseudocode than most languages or computer algebra packages afford, it can be used as pseudocode. For that purpose, it will be helpful to know that "modp(x, n)" means reducing x mod the integer n to 0, 1, ..., n-1 not only when x is an integer, but also when it is a rational number with denominator prime to n. In that case, p/q mod n = r means p = qr mod n.

log2 := proc(x)
# logarithm base 2
evalf(ln(x)/ln(2)) end:

nextfarey := proc(q, n)
# next in row n of Farey sequence from q, 0 <= q <= 1
local a, b, r, s;
if q >= (n-1)/n then RETURN(1) fi;
a := numer(q);
b := denom(q);
s := n - modp(n + 1/a, b);
r := modp(1/b, s);
r/s end:

prevfarey := proc(q, n)
# previous in row n of Farey sequence from q, 0 <= q <= 1
local a, b, r, s;
if q=0 then RETURN(0) fi;
if n=0 then RETURN(0) fi;
a := numer(q);
b := denom(q);
s := n - modp(n - 1/a, b);
r := modp(-1/b, s);
r/s end:

fareypair := proc(q)
# Farey pair with q as its mediant
local n;
n := denom(q);
[prevfarey(q, n), nextfarey(q, n)] end:

mediant := proc(u, v)
# mediant of two rational numbers u and v
(numer(u) + numer(v))/(denom(u) + denom(v)) end:

convergents := proc(z)
# convergent list for z
local q;
convert(z,confrac,'q');
q end:

exlist := proc(l)
# expansion of a convergent list to semiconvergents
local i, j, s, d;
if nops(l)<3 then RETURN(l) fi;
d[1] := l[1];
d[2] := l[2];
s := 3;
for i from 3 to nops(l)-1 do
for j from 1 to (numer(l[i])-numer(l[i-2]))/numer(l[i-1]) do
d[s] :=
(j*numer(l[i-1])+numer(l[i-2]))/(j*denom(l[i-1])+denom(l[i-2]));
s := s+1 od od;
convert(convert(d, array), list) end:

semiconvergents := proc(z)
# semiconvergent list for z
exlist(convergents(z)) end:

penult := proc(q)
# penultimate convergent to q
local i, u;
u := convergents(q);
if nops(u)=1 then RETURN(u[1]) fi;
for i from 1 to nops(u) do
if u[i]=q then RETURN(u[i-1]) fi od;
end:

Ls := proc(q)
# large-small steps from mediant q
local u;
u := fareypair(q);
[denom(u[2]), denom(u[1])] end:

medi := proc(u)
# mediant from Large-small steps
local q, r;
if u[2]=1 then RETURN(1/(u[1]+1)) fi;
r := igcd(u[1], u[2]);
if r>1 then RETURN(medi([u[1]/r, u[2]/r])) fi;
q := penult(u[1]/u[2]);
if q > u[1]/u[2] then RETURN((numer(q)+denom(q))/(u[1]+u[2])) fi;
(u[1]+u[2]-numer(q)-denom(q))/(u[1]+u[2]) end:

Lsgen := proc(g, n)
# given generator g and scale size n determines large-small steps
local q, u, w;
q := round(n*g)/n;
w := n/denom(q);
u := fareypair(q);
if g<u[1] or g>u[2] or g=q then RETURN('false') fi;
if g<q then RETURN([w*denom(u[1]), w*denom(u[2])]) fi;
[w*denom(u[2]), w*denom(u[1])] 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:

invcon := proc(l)
# inverse continued fraction
local d, i, h, k;
h[-2] := 0;
h[-1] := 1;
k[-2] := 1;
k[-1] := 0;
for i from 0 to nops(l)-1 do
h[i] := l[i+1]*h[i-1] + h[i-2];
k[i] := l[i+1]*k[i-1] + k[i-2];
d[i+1] := h[i]/k[i] od;
convert(convert(d, array), list) end:

quest := proc(x)
# Minkowski ? function
local i, j, d, l, s, t;
l := convert(x, confrac);
d := nops(l);
s := l[1];
for i from 2 to d do
t := 1;
for j from 2 to i do
t := t - l[j] od;
s := s + (-1)^i * 2^t od;
if type(x, float) then s := evalf(s) fi;
s end:

Box := proc(x)
# inverse ? function
local d, e, i, n, w, y;
if type(x, integer) then RETURN(x) fi;
y := x-floor(x);
if y = 1/8 then RETURN(floor(x)+1/4) fi;
w := round(log2(10)*Digits)-5;
n := round(2^w * y);
i :=0;
while n>0 do
i := i+1;
if modp(n,2)=0 then
d[i] := padic[ordp](n, 2);
n := n/2^d[i];
else
d[i] := padic[ordp](n+1, 2);
n := (n-2^d[i]+1)/2^d[i] fi od;
e := convert(convert(d, array), list);
e := subsop(1=NULL,e);
w := ceil(-log2(y));
e := [op(e), w];
e := [op(e), floor(x)];
e := revlist(e);
n := invcon(e);
w := n[nops(n)];
if type(x, rational) and modp(denom(x), 2)=0 then RETURN(w) fi;
evalf(w) end:

==[[MOSDiagrams]]== 

Original HTML content:

<html><head><title>MOSScales</title></head><body><!-- ws:start:WikiTextTocRule:18:&lt;img id=&quot;wikitext@@toc@@flat&quot; class=&quot;WikiMedia WikiMediaTocFlat&quot; title=&quot;Table of Contents&quot; src=&quot;/site/embedthumbnail/toc/flat?w=100&amp;h=16&quot;/&gt; --><!-- ws:end:WikiTextTocRule:18 --><!-- ws:start:WikiTextTocRule:19: --><a href="#Definition">Definition</a><!-- ws:end:WikiTextTocRule:19 --><!-- ws:start:WikiTextTocRule:20: --><!-- ws:end:WikiTextTocRule:20 --><!-- ws:start:WikiTextTocRule:21: --><!-- ws:end:WikiTextTocRule:21 --><!-- ws:start:WikiTextTocRule:22: --><!-- ws:end:WikiTextTocRule:22 --><!-- ws:start:WikiTextTocRule:23: --> | <a href="#Catalog of MOS">Catalog of MOS</a><!-- ws:end:WikiTextTocRule:23 --><!-- ws:start:WikiTextTocRule:24: --> | <a href="#Variations on MOS Scales">Variations on MOS Scales</a><!-- ws:end:WikiTextTocRule:24 --><!-- ws:start:WikiTextTocRule:25: --> | <a href="#MOS As Applied To Rhythms">MOS As Applied To Rhythms</a><!-- ws:end:WikiTextTocRule:25 --><!-- ws:start:WikiTextTocRule:26: --> | <a href="#Algorithms">Algorithms</a><!-- ws:end:WikiTextTocRule:26 --><!-- ws:start:WikiTextTocRule:27: --><!-- ws:end:WikiTextTocRule:27 --><!-- ws:start:WikiTextTocRule:28: -->
<!-- ws:end:WikiTextTocRule:28 --><hr />
<br />
<!-- ws:start:WikiTextHeadingRule:0:&lt;h1&gt; --><h1 id="toc0"><a name="Definition"></a><!-- ws:end:WikiTextHeadingRule:0 -->Definition</h1>
 An <strong>MOS</strong> or <strong>Moment Of Symmetry</strong> is a scale in which every interval except for the period comes in two sizes. The term &quot;MOS,&quot; and the method of scale construction it entails, were invented by Erv Wilson in 1975. His original paper can be found at <a class="wiki_link_ext" href="http://anaphoria.com/mos.PDF" rel="nofollow">http://anaphoria.com/mos.PDF</a>. There is also an introduction at <a class="wiki_link_ext" href="http://anaphoria.com/wilsonintroMOS.html" rel="nofollow">http://anaphoria.com/wilsonintroMOS.html</a>.<br />
<br />
Sometimes, scales are defined with respect to a period and an additional &quot;equivalence interval,&quot; considered to be the interval at which pitch classes repeat. MOS's in which the equivalence interval is a multiple of the period, and in which there is more than one period per equivalence interval, are sometimes called <strong>Multi-MOS</strong>'s. MOS's in which the equivalence interval is equal the period are sometimes called <strong>Strict MOS</strong>'s. MOS's in which the equivalence interval and period are simply disjunct, with no rational relationship between them, are simply MOS and have no additional distinguishing label.<br />
<br />
With a few notable exceptions, Wilson generally focused his attention on MOS with period equal to the equivalence interval. Hence, some people prefer to use the term <a class="wiki_link" href="/Distributional%20Evenness">distributionally even scale</a>, with acronym DE, for the more general class of scales which are MOS with respect to other intervals. MOS/DE scales are also sometimes known as <em>well-formed scales</em>, the term used in the 1989 paper by Norman Carey and David Clampitt. A great deal of interesting work has been done on scales in academic circles extending these ideas.<br />
<br />
See <a class="wiki_link" href="/Mathematics%20of%20MOS">Mathematics of MOS</a> for a more formal definition and a discussion of their mathematical properties.<br />
<br />
<!-- ws:start:WikiTextHeadingRule:2:&lt;h3&gt; --><h3 id="toc1"><a name="Definition--Names for MOS"></a><!-- ws:end:WikiTextHeadingRule:2 -->Names for MOS</h3>
 Since numbers tend to be dry, Graham Breed has proposed a <a class="wiki_link" href="/MOSNamingScheme">naming scheme for MOS scales</a>.<br />
<br />
<!-- ws:start:WikiTextHeadingRule:4:&lt;h3&gt; --><h3 id="toc2"><a name="Definition--MOS in equal temperaments"></a><!-- ws:end:WikiTextHeadingRule:4 -->MOS in equal temperaments</h3>
 In an equal temperament, all intervals are integer multiples of a smallest unit. If the equal temperament is N-EDO and the period is an octave, the sizes of the large and small steps will be p/N and q/N, with p &gt; q. We then have L(p/N) + s(q/N) = 1, which on multiplying through by N gives us<br />
<br />
Lp + sq = N.<br />
<br />
which is a linear diophantine equation. Solving this by standard methods, and requiring L and s to be positive, gives us the [L, s] pair for the MOS. If some other quantity of equal steps gives the period, we may make the appropriate adjustment.<br />
<br />
<!-- ws:start:WikiTextHeadingRule:6:&lt;h3&gt; --><h3 id="toc3"><a name="Definition--Blackwood R constant"></a><!-- ws:end:WikiTextHeadingRule:6 -->Blackwood R constant</h3>
 In the context of the &quot;recognizable diatonic&quot; scales deriving from the Farey pair [1/2, 3/5] <a class="wiki_link_ext" href="http://en.wikipedia.org/wiki/Easley_Blackwood,_Jr." rel="nofollow">Easley Blackwood Jr.</a> defined a characterizing constant R which we may generalize to any MOS as follows. If a/b &lt; g &lt; c/d is a generator with the given Farey pair, take the ratio of relative errors R = (bg - a)/(c - dg). Since this is a ratio of positive numbers, it is positive. As g tends towards a/b it tends to zero, and as g goes to c/d R goes to infinity. When g equals (a + c)/(b + d) it takes the value 1, and the range of propriety is 1/2 &lt;= R &lt;= 2.<br />
<br />
When R is less than 1, it represents the ratio in (logarithmic) size between the smaller and the larger step. When it is greater than 1, it is larger/smaller. By replacing g with 1 - g if necessary, we can reduce always to the case where R&gt;1 (or R&lt;1 if we prefer.)<br />
<br />
<!-- ws:start:WikiTextHeadingRule:8:&lt;h1&gt; --><h1 id="toc4"><a name="Catalog of MOS"></a><!-- ws:end:WikiTextHeadingRule:8 -->Catalog of MOS</h1>
This is a <a class="wiki_link" href="/Catalog%20of%20MOS">catalog</a> of the various MOS, in the Ls notation.<br />
<br />
<!-- ws:start:WikiTextHeadingRule:10:&lt;h1&gt; --><h1 id="toc5"><a name="Variations on MOS Scales"></a><!-- ws:end:WikiTextHeadingRule:10 -->Variations on MOS Scales</h1>
 <ol><li><a class="wiki_link" href="/MODMOS%20Scales">MODMOS Scales</a> are derived from chromatic alterations of one or more tones of an MOS scale, typically by the interval of L-s, the &quot;chroma&quot;.</li><li><a class="wiki_link" href="/Muddle">Muddles</a> are subsets of MOS parent scales with the general shape of a smaller (and possibly unrelated) MOS scale.</li><li><a class="wiki_link" href="/MOS%20Cradle">MOS Cradle</a> is a technique of embedding MOS-like structures inside MOS scales and may or may not produce subsets of MOS scales.</li></ol><br />
<!-- ws:start:WikiTextHeadingRule:12:&lt;h1&gt; --><h1 id="toc6"><a name="MOS As Applied To Rhythms"></a><!-- ws:end:WikiTextHeadingRule:12 -->MOS As Applied To Rhythms</h1>
 David Canright was the first to suggest Fibonacci Rhythms in 1/1. This lead to Kraig Grady to be the first to apply MOS patterns to rhythms. Two papers on the subject can be found here <a class="wiki_link_ext" href="http://anaphoria.com/hora.PDF" rel="nofollow">http://anaphoria.com/hora.PDF</a> and <a class="wiki_link_ext" href="http://anaphoria.com/horo2.PDF" rel="nofollow">http://anaphoria.com/horo2.PDF</a><br />
MOS structures and thinking can be applied to the design of rhythms as well. See <a class="wiki_link" href="/MOS%20Rhythm%20Tutorial">MOS Rhythm Tutorial</a><br />
<br />
<!-- ws:start:WikiTextHeadingRule:14:&lt;h1&gt; --><h1 id="toc7"><a name="Algorithms"></a><!-- ws:end:WikiTextHeadingRule:14 -->Algorithms</h1>
 Below is some Maple code for various mathematical routines having to do with MOS. If you have access to Maple, you can of course copy and run these programs. Even if you do not, since Maple code makes better pseudocode than most languages or computer algebra packages afford, it can be used as pseudocode. For that purpose, it will be helpful to know that &quot;modp(x, n)&quot; means reducing x mod the integer n to 0, 1, ..., n-1 not only when x is an integer, but also when it is a rational number with denominator prime to n. In that case, p/q mod n = r means p = qr mod n.<br />
<br />
log2 := proc(x)<br />
<ol><li>logarithm base 2</li></ol>evalf(ln(x)/ln(2)) end:<br />
<br />
nextfarey := proc(q, n)<br />
<ol><li>next in row n of Farey sequence from q, 0 &lt;= q &lt;= 1</li></ol>local a, b, r, s;<br />
if q &gt;= (n-1)/n then RETURN(1) fi;<br />
a := numer(q);<br />
b := denom(q);<br />
s := n - modp(n + 1/a, b);<br />
r := modp(1/b, s);<br />
r/s end:<br />
<br />
prevfarey := proc(q, n)<br />
<ol><li>previous in row n of Farey sequence from q, 0 &lt;= q &lt;= 1</li></ol>local a, b, r, s;<br />
if q=0 then RETURN(0) fi;<br />
if n=0 then RETURN(0) fi;<br />
a := numer(q);<br />
b := denom(q);<br />
s := n - modp(n - 1/a, b);<br />
r := modp(-1/b, s);<br />
r/s end:<br />
<br />
fareypair := proc(q)<br />
<ol><li>Farey pair with q as its mediant</li></ol>local n;<br />
n := denom(q);<br />
[prevfarey(q, n), nextfarey(q, n)] end:<br />
<br />
mediant := proc(u, v)<br />
<ol><li>mediant of two rational numbers u and v</li></ol>(numer(u) + numer(v))/(denom(u) + denom(v)) end:<br />
<br />
convergents := proc(z)<br />
<ol><li>convergent list for z</li></ol>local q;<br />
convert(z,confrac,'q');<br />
q end:<br />
<br />
exlist := proc(l)<br />
<ol><li>expansion of a convergent list to semiconvergents</li></ol>local i, j, s, d;<br />
if nops(l)&lt;3 then RETURN(l) fi;<br />
d[1] := l[1];<br />
d[2] := l[2];<br />
s := 3;<br />
for i from 3 to nops(l)-1 do<br />
for j from 1 to (numer(l[i])-numer(l[i-2]))/numer(l[i-1]) do<br />
d[s] :=<br />
(j*numer(l[i-1])+numer(l[i-2]))/(j*denom(l[i-1])+denom(l[i-2]));<br />
s := s+1 od od;<br />
convert(convert(d, array), list) end:<br />
<br />
semiconvergents := proc(z)<br />
<ol><li>semiconvergent list for z</li></ol>exlist(convergents(z)) end:<br />
<br />
penult := proc(q)<br />
<ol><li>penultimate convergent to q</li></ol>local i, u;<br />
u := convergents(q);<br />
if nops(u)=1 then RETURN(u[1]) fi;<br />
for i from 1 to nops(u) do<br />
if u[i]=q then RETURN(u[i-1]) fi od;<br />
end:<br />
<br />
Ls := proc(q)<br />
<ol><li>large-small steps from mediant q</li></ol>local u;<br />
u := fareypair(q);<br />
[denom(u[2]), denom(u[1])] end:<br />
<br />
medi := proc(u)<br />
<ol><li>mediant from Large-small steps</li></ol>local q, r;<br />
if u[2]=1 then RETURN(1/(u[1]+1)) fi;<br />
r := igcd(u[1], u[2]);<br />
if r&gt;1 then RETURN(medi([u[1]/r, u[2]/r])) fi;<br />
q := penult(u[1]/u[2]);<br />
if q &gt; u[1]/u[2] then RETURN((numer(q)+denom(q))/(u[1]+u[2])) fi;<br />
(u[1]+u[2]-numer(q)-denom(q))/(u[1]+u[2]) end:<br />
<br />
Lsgen := proc(g, n)<br />
<ol><li>given generator g and scale size n determines large-small steps</li></ol>local q, u, w;<br />
q := round(n*g)/n;<br />
w := n/denom(q);<br />
u := fareypair(q);<br />
if g&lt;u[1] or g&gt;u[2] or g=q then RETURN('false') fi;<br />
if g&lt;q then RETURN([w*denom(u[1]), w*denom(u[2])]) fi;<br />
[w*denom(u[2]), w*denom(u[1])] end:<br />
<br />
revlist := proc(l)<br />
<ol><li>reverse of list</li></ol>local i, v, e;<br />
e := nops(l);<br />
for i from 1 to e do<br />
v[i] := l[e-i+1] od;<br />
convert(convert(v,array),list) end:<br />
<br />
invcon := proc(l)<br />
<ol><li>inverse continued fraction</li></ol>local d, i, h, k;<br />
h[-2] := 0;<br />
h[-1] := 1;<br />
k[-2] := 1;<br />
k[-1] := 0;<br />
for i from 0 to nops(l)-1 do<br />
h[i] := l[i+1]*h[i-1] + h[i-2];<br />
k[i] := l[i+1]*k[i-1] + k[i-2];<br />
d[i+1] := h[i]/k[i] od;<br />
convert(convert(d, array), list) end:<br />
<br />
quest := proc(x)<br />
<ol><li>Minkowski ? function</li></ol>local i, j, d, l, s, t;<br />
l := convert(x, confrac);<br />
d := nops(l);<br />
s := l[1];<br />
for i from 2 to d do<br />
t := 1;<br />
for j from 2 to i do<br />
t := t - l[j] od;<br />
s := s + (-1)^i * 2^t od;<br />
if type(x, float) then s := evalf(s) fi;<br />
s end:<br />
<br />
Box := proc(x)<br />
<ol><li>inverse ? function</li></ol>local d, e, i, n, w, y;<br />
if type(x, integer) then RETURN(x) fi;<br />
y := x-floor(x);<br />
if y = 1/8 then RETURN(floor(x)+1/4) fi;<br />
w := round(log2(10)*Digits)-5;<br />
n := round(2^w * y);<br />
i :=0;<br />
while n&gt;0 do<br />
i := i+1;<br />
if modp(n,2)=0 then<br />
d[i] := padic[ordp](n, 2);<br />
n := n/2^d[i];<br />
else<br />
d[i] := padic[ordp](n+1, 2);<br />
n := (n-2^d[i]+1)/2^d[i] fi od;<br />
e := convert(convert(d, array), list);<br />
e := subsop(1=NULL,e);<br />
w := ceil(-log2(y));<br />
e := [op(e), w];<br />
e := [op(e), floor(x)];<br />
e := revlist(e);<br />
n := invcon(e);<br />
w := n[nops(n)];<br />
if type(x, rational) and modp(denom(x), 2)=0 then RETURN(w) fi;<br />
evalf(w) end:<br />
<br />
<!-- ws:start:WikiTextHeadingRule:16:&lt;h2&gt; --><h2 id="toc8"><a name="Algorithms-MOSDiagrams"></a><!-- ws:end:WikiTextHeadingRule:16 --><a class="wiki_link" href="/MOSDiagrams">MOSDiagrams</a></h2>
</body></html>