User:2^67-1/Sandbox: Difference between revisions

2^67-1 (talk | contribs)
mNo edit summary
2^67-1 (talk | contribs)
mNo edit summary
 
Line 61: Line 61:
         best = avg(ednerrorlist(tonalitydiamond([3,2],[5,2],[7,4]),i,[3,2]))*i
         best = avg(ednerrorlist(tonalitydiamond([3,2],[5,2],[7,4]),i,[3,2]))*i
         print(i)
         print(i)
</syntaxhighlight>
== More programs ==
<syntaxhighlight lang="python">
import math
def relativeerror(x):
    three = abs(round(x*math.log2(3),0)-x*math.log2(3))
    five = abs(round(x*math.log2(5),0)-x*math.log2(5))
    eleven = abs(round(x*math.log2(11),0)-x*math.log2(11))
    return max(three, five, eleven)
best = 3
for i in range(1,1000000):
    if relativeerror(i) < best:
        print(i)
        best = relativeerror(i)
</syntaxhighlight>
Output:
<syntaxhighlight lang="python">
1
2
4
7
15
22
87
183
270
494
1171
11105
42348
54624
282560
</syntaxhighlight>
</syntaxhighlight>