# Talk:Just Intonation -- EDO calculator

`data:text/html,<html><head><title>Just Intonation -> EDO calculator</title></head><body><!-- ws:start:WikiTextMediaRule:0:<img src="http://www.wikispaces.com/site/embedthumbnail/custom/12263302?h=0&w=0" class="WikiMedia WikiMediaCustom" id="wikitext@@media@@type=&quot;custom&quot; key=&quot;12263302&quot;" title="Custom Media"/> --><script type="text/javascript"> //<![CDATA[ function continued_fraction(x) { var expansion = []; for (t=0; t < 11; t++) { my_int = Math.floor(x); expansion.push(my_int); my_frac = x - my_int; x = 1/my_frac; } return expansion; } function rational(fp_number) // floating point... { var expansion = continued_fraction(fp_number); var numerators = [0,1]; var denominators = [1,0]; var out_string = new String(""); for (t=0; t < expansion.length; t++) { numerators.push(expansion[t]*numerators[t+1]+numerators[t]); denominators.push(expansion[t]*denominators[t+1]+denominators[t]); } for (u=2; u < (numerators.length-1); u++) { out_string = out_string + "<b>" + numerators[u] + "\\" + denominators[u] + "<\/b>" + " "; n = numerators[u] + numerators[u-1]; d = denominators[u] + denominators[u-1]; while (n < numerators[u+1]) { out_string = out_string + n + "\\" + d + " "; n += numerators[u]; d += denominators[u]; } out_string = out_string + "<br>"; } return out_string; } function convert() { N=document.getElementById("n").value / document.getElementById("d").value ; octaves = Math.log(N) / Math.log(2); cents = octaves * 1200; my_string1 = octaves + " octaves"; my_string2 = cents + " cents"; my_string3 = rational(octaves); document.getElementById("octaves").innerHTML = my_string1; document.getElementById("cents").innerHTML = my_string2; document.getElementById("edos").innerHTML =my_string3; } //]]> </script> <p>This script takes a numerator and denominator (both can be floating point numbers), which are intended to express some ratio of pitches, and returns the size of that ratio in logarithmic octaves (i.e., log2(n/d)), its size in cents (octaves *1200), and also the rational approximation expansion of the ratio in octaves, which tells us what the increasingly good estimates for that ratio are in terms of degrees of an equal division of the octave, or 'edo'...</p> <b>Insert a numerator and denominator of a Just Intonation ratio below:</b> <p><input id="n" name="n" onkeyup="convert()" /> / <input id="d" name="d" onkeyup="convert()" /></p> <br /> <div id="octaves"></div> <div id="cents"></div> <br /> EDO Approximations (written as DEGREE\EDO; where convergents are in <b>bold</b>, and semi-convergents are in normal typeface):<br /> <div id="edos"></div><!-- ws:end:WikiTextMediaRule:0 --></body></html>`