<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.xen.wiki/index.php?action=history&amp;feed=atom&amp;title=User%3AAkselai%2FPrograms</id>
	<title>User:Akselai/Programs - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.xen.wiki/index.php?action=history&amp;feed=atom&amp;title=User%3AAkselai%2FPrograms"/>
	<link rel="alternate" type="text/html" href="https://en.xen.wiki/index.php?title=User:Akselai/Programs&amp;action=history"/>
	<updated>2026-07-11T13:39:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://en.xen.wiki/index.php?title=User:Akselai/Programs&amp;diff=135675&amp;oldid=prev</id>
		<title>Akselai: Created page with &quot;A list of programs that implement technical xenharmonic concepts.   A good algorithm is worth a thousand tables.  == Delta-rational chords == &lt;syntaxhighlight lang=&quot;python...&quot;</title>
		<link rel="alternate" type="text/html" href="https://en.xen.wiki/index.php?title=User:Akselai/Programs&amp;diff=135675&amp;oldid=prev"/>
		<updated>2024-02-14T20:20:53Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;A list of programs that implement technical xenharmonic concepts.   A good algorithm is worth a thousand tables.  == &lt;a href=&quot;/w/Delta-rational_chord&quot; title=&quot;Delta-rational chord&quot;&gt;Delta-rational chords&lt;/a&gt; == &amp;lt;syntaxhighlight lang=&amp;quot;python...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A list of programs that implement technical xenharmonic concepts. &lt;br /&gt;
&lt;br /&gt;
A good algorithm is worth a thousand tables.&lt;br /&gt;
&lt;br /&gt;
== [[Delta-rational chord]]s ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def argmin(list1):&lt;br /&gt;
    return list1.index(min(list1))&lt;br /&gt;
&lt;br /&gt;
def closest_denom(x, n):&lt;br /&gt;
    return round(n/x)&lt;br /&gt;
&lt;br /&gt;
def chord_differential(chord, ji, eps):&lt;br /&gt;
    ji = [x + eps for x in ji]&lt;br /&gt;
    ji_diff = [abs(ji[i]/ji[0] - chord[i]) for i in range(len(ji))]&lt;br /&gt;
    df = max(ji_diff)&lt;br /&gt;
    return df&lt;br /&gt;
&lt;br /&gt;
def find_minimum(f, min, max):&lt;br /&gt;
    return find_minimum_a(f, min, max, 40)&lt;br /&gt;
&lt;br /&gt;
def find_minimum_a(f, min, max, partitions):&lt;br /&gt;
    if max - min &amp;lt; 0.00001:&lt;br /&gt;
        return [(min + max) / 2, f((min + max) / 2)]&lt;br /&gt;
    values = [float(f(min + (max-min) / partitions * i)) for i in range(0, partitions+1)]&lt;br /&gt;
    m = argmin(values)&lt;br /&gt;
    return find_minimum_a(f, min + (max-min) / partitions * (m-1), min + (max-min) / partitions * (m+1), 5)&lt;br /&gt;
&lt;br /&gt;
def delta_rational(chord, limit, offset):&lt;br /&gt;
    chord = [1] + chord&lt;br /&gt;
    smallest = 10&lt;br /&gt;
    result = []&lt;br /&gt;
    for l in range(1, limit+1):&lt;br /&gt;
        ji = [closest_denom(chord[-1]/x, l) for x in chord]&lt;br /&gt;
        df = chord_differential(chord, ji, offset)&lt;br /&gt;
        if df &amp;lt;= smallest:&lt;br /&gt;
            result = [ji, df]&lt;br /&gt;
            smallest = df&lt;br /&gt;
    return result&lt;br /&gt;
&lt;br /&gt;
def as_plus_notation(chord):&lt;br /&gt;
    return &amp;#039; &amp;#039;.join([&amp;#039;+&amp;#039; + str(chord[i+1] - chord[i]) for i in range(len(chord) - 1)])&lt;br /&gt;
&lt;br /&gt;
# PARAMETERS HERE&lt;br /&gt;
edo = 10&lt;br /&gt;
limit = 19&lt;br /&gt;
&lt;br /&gt;
def f_t(i, j, t):&lt;br /&gt;
    return delta_rational([2^(i/edo), 2^(j/edo)], limit, t)[1]&lt;br /&gt;
&lt;br /&gt;
for i in range(1, edo):&lt;br /&gt;
    for j in range(i+1, edo):&lt;br /&gt;
        minim = find_minimum(lambda t: f_t(i, j, t), -0.5, 0.5)&lt;br /&gt;
        if minim[1] &amp;lt;= 0.01:&lt;br /&gt;
            res = delta_rational([2^(i/edo), 2^(j/edo)], limit, minim[0])&lt;br /&gt;
            print(&amp;quot;chord: 0-&amp;quot; + str(i) + &amp;quot;-&amp;quot; + str(j))&lt;br /&gt;
            print(res[0])&lt;br /&gt;
            print(as_plus_notation(res[0]), &amp;#039;offset:&amp;#039;, float(&amp;#039;%.5g&amp;#039; % minim[0]))&lt;br /&gt;
            print(&amp;#039;score: %s&amp;#039; % float(&amp;#039;%.3g&amp;#039; % res[1]))&lt;br /&gt;
            print(&amp;#039;-&amp;#039; * 16)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akselai</name></author>
	</entry>
</feed>