Contribution
Joined 18 April 2020
Contribution (talk | contribs) |
m →When I suggested to switch to JavaScript: fixed block formatting (the code tag is for inline formatting, pre is for blocks) |
||
Line 34: | Line 34: | ||
Below is a piece of Python code doing it (better solutions may be possible): | Below is a piece of Python code doing it (better solutions may be possible): | ||
< | <pre> | ||
primes=[2,3,5,7,11,13,17,19,23,29,31] | |||
# reciprocal of a given monzo | |||
def reciprocal(monzo): | |||
for p in range(0,len(monzo)): | |||
monzo[p]*=-1 | |||
return(monzo) | |||
# ABSCISSA MONZOS LIST | |||
x_axis=[] | |||
for a in range(0,26+1): | |||
# pythagorean interval | |||
monzo=[0]*len(primes) | |||
monzo[1]+=a | |||
# insert it at the end of the list | |||
x_axis.append(monzo) | |||
# insert its reciprocal at the beginning of the list, so that 1/1 is the center of symmetry between reciprocals | |||
x_axis.insert(0,reciprocal(monzo.copy())) | |||
# ORDINATE MONZOS LIST | |||
y_axis=[] | |||
# insert 1/1 | |||
monzo=[0]*len(primes) | |||
y_axis.insert(0,monzo) | |||
# first prime | |||
for a in range(2,len(primes)): | |||
# pure harmonic series | |||
monzo=[0]*len(primes) | |||
monzo[a]+=1 | |||
# insert the pure harmonic at the beginning of the list | |||
y_axis.insert(0,monzo) | |||
# insert its subharmonic version at the end of the list, so that 1/1 is the center of symmetry between reciprocals | |||
y_axis.append(reciprocal(monzo.copy())) | |||
# second prime | |||
for b in range(2,a+1): | |||
# combine the pure harmonic with another prime, both by putting it in the numerator or in the denominator | |||
for c in range(1,-1-1,-2): | |||
monzo=[0]*len(primes) | |||
monzo[a]+=1 | |||
# when c=1, the second prime is put in the numerator ; when c=-1, the second prime is put in the denominator | |||
monzo[b]+=c | |||
# before inserting, eliminate the cases where the first and the second prime are reciprocal | |||
if(monzo!=[0]*len(primes)): | |||
# insert the combination at the beginning | |||
y_axis.insert(0,monzo) | |||
# insert its reciprocal at the end, so that 1/1 is the center of symmetry between reciprocals | |||
y_axis.append(reciprocal(monzo.copy())) | |||
# insert 125/64 exception and its reciprocal | |||
if(monzo==[0,0,2,0,0,0,0,0,0,0,0]): | |||
monzo[2]+=1 | |||
y_axis.insert(0,monzo) | |||
y_axis.append(reciprocal(monzo.copy())) | |||
# CARTESIAN COORDINATE PLANE OF MONZOS | |||
table=[] | |||
for y in range(0,len(y_axis)): | |||
row=[] | |||
for x in range(0,len(x_axis)): | |||
monzo=[] | |||
for a in range(0,len(primes)): | |||
# combine the abscissa monzo and the ordinate monzo | |||
monzo.append(x_axis[x][a]+y_axis[y][a]) | |||
row.append(monzo) | |||
table.append(row) | |||
##### SHOW RESULT ##### | |||
print(table) | |||
</pre> | |||
Would be curious to see your implementation :) | Would be curious to see your implementation :) |