function intervalcalc()
{

var frequencytop = 0;
var frequencybottom = 0;
var decimaltop = 0;
var decimalbottom = 0;
var frequencyalone = 0;
var frequencyfundamental = 0;
var decimalfundamental = 0;
var harmonic = 0;
var frequencyharmonic = 0;

var frequencytempered = 0;
var decimaltempered = 0;

var decimalalone = 0;
var cents = 0;
var decimalcents = 0;
var frequencyratio = 0;

var up=0;
var down=0;
var log10of2 = 0.30102999566398119521373889472449;
var logeof10 = 2.3025850929940456840179914546844;
var intervalincents = 0;
var multiplier = 0;
var newmultiplier = 0;

multiplier = 1731.23404906677;

var newfrequency = 0;
var harmonicintervalincents = 0;
var normalizedintervalincents = 0;
var normalizedfrequency = 0;

var notecharacter = "&nbsp;";

var noterow = "CnC#DnD#EnFnF#GnG#AnA#BnCnC#DnD#EnFnF#GnG#AnA#BnCnC#DnD#EnFnF#GnG#AnA#Bn";

var fifthrow = "FbCbGbDbAbEbBbFnCnGnDnAnEnBnF#C#G#D#A#E#B#";

var fifthcharacter = "&nbsp;";

var noteinflection = "&nbsp;";
var notenameshift = 0;
var newnotename = 0;
var newnotecharacter = "&nbsp;";
var newnoteinflection = "&nbsp;";
var frequencynearestnote = 0;

var basenoteinflection = "&nbsp;";

var upperfifthcharacter = "&nbsp;";
var upperfifthinflection = "&nbsp;";

var lowerfifthcharacter = "&nbsp;";
var lowerfifthinflection = "&nbsp;";

var fifthabove = 0;
var fifthbelow = 0;

var syntoniccomma = 1.0125;
var ditoniccomma = 1.0136432647705078125;

var temperingfifthupcomma = "&nbsp;";
var temperingfifthupdirection = "&nbsp;";

var temperinga = 0;

var upperfactora = 0;
var lowerfactora = 0;

var temperingfifthupfactor = 0;

var widtha = "&nbsp;"

var temperingfifthdowncomma = "&nbsp;";
var temperingfifthdowndirection = "&nbsp;";

var temperingb = 0;

var upperfactorb = 0;
var lowerfactorb = 0;

var temperingfifthdownfactor = 0;

var widtha = "&nbsp;"

var hundredthousandtop = document.getElementById('hundredthousandtop');
var tenthousandtop = document.getElementById('tenthousandtop'); 
var thousandtop = document.getElementById('thousandtop');
var hundredtop = document.getElementById('hundredtop');
var tentop = document.getElementById('tentop');
var unittop = document.getElementById('unittop');
var tenthtop = document.getElementById('tenthtop');
var hundredthtop = document.getElementById('hundredthtop');
var thousandthtop = document.getElementById('thousandthtop');
var tenthousandthtop = document.getElementById('tenthousandthtop');

frequencytop = hundredthousandtop.value + tenthousandtop.value + thousandtop.value + hundredtop.value + tentop.value + unittop.value;

decimaltop = tenthtop.value + hundredthtop.value + thousandthtop.value + tenthousandthtop.value;

t0100.innerHTML = "<font color=blue><b>higher frequency: " + parseFloat(frequencytop + "." + decimaltop) + "</b></font>";


var hundredthousandbottom = document.getElementById('hundredthousandbottom');
var tenthousandbottom = document.getElementById('tenthousandbottom'); 
var thousandbottom = document.getElementById('thousandbottom');
var hundredbottom = document.getElementById('hundredbottom');
var tenbottom = document.getElementById('tenbottom');
var unitbottom = document.getElementById('unitbottom');
var tenthbottom = document.getElementById('tenthbottom');
var hundredthbottom = document.getElementById('hundredthbottom');
var thousandthbottom = document.getElementById('thousandthbottom');
var tenthousandthbottom = document.getElementById('tenthousandthbottom');

frequencybottom = hundredthousandbottom.value + tenthousandbottom.value + thousandbottom.value + hundredbottom.value + tenbottom.value + unitbottom.value;

decimalbottom = tenthbottom.value + hundredthbottom.value + thousandthbottom.value + tenthousandthbottom.value;

t0101.innerHTML = "<font color=blue><b>lower frequency: " + parseFloat(frequencybottom + "." + decimalbottom) + "</b></font>";

frequencyratio = ((parseFloat(frequencytop + "." + decimaltop))/(parseFloat(frequencybottom + "." + decimalbottom)));

intervalincents = (Math.log(frequencyratio)*multiplier).toFixed(3);


if ((parseFloat(frequencytop + "." + decimaltop) == 0 ) && (parseFloat(frequencybottom + "." + decimalbottom) == 0))
{
t0102.innerHTML = "&nbsp;<br>&nbsp;";
t0103.innerHTML = "<font color=red>please enter larger frequency or ratio number in top row<br>and smaller frequency or ratio number in second row</font>"
}
else
{
if ((parseFloat(frequencytop + "." + decimaltop) > 0 ) && (parseFloat(frequencybottom + "." + decimalbottom) == 0) )
{
t0102.innerHTML = "&nbsp;<br>&nbsp;";
t0103.innerHTML = "<font color=red>please enter smaller frequency or ratio number in second row<br>&nbsp;</font>"
}
else
{

if ( (parseFloat(frequencybottom + "." + decimalbottom))  >  (parseFloat(frequencytop + "." + decimaltop))  && (parseFloat(frequencybottom + "." + decimalbottom) > 0) )
{
t0102.innerHTML = "&nbsp;<br>&nbsp;";
t0103.innerHTML = "<font color=red>lower frequency (ratio number) > higher frequency (ratio number)<br>please enter larger frequency (ratio number) in top row</font>"
}

else

{
up = parseFloat(frequencytop + "." + decimaltop)
down = parseFloat(frequencybottom + "." + decimalbottom)



t0102.innerHTML = "<font color=blue><b>interval as ratio: (" + up + ":" + down + ")<br>ratio as number: " + (up/down) + "</b></font>";
t0103.innerHTML = "<font color=blue><b> interval in cents: " + intervalincents + "</b></font><br>&nbsp;"
}
}
}

var hundredthousandalone = document.getElementById('hundredthousandalone');
var tenthousandalone = document.getElementById('tenthousandalone'); 
var thousandalone = document.getElementById('thousandalone');
var hundredalone = document.getElementById('hundredalone');
var tenalone = document.getElementById('tenalone');
var unitalone = document.getElementById('unitalone');
var tenthalone = document.getElementById('tenthalone');
var hundredthalone = document.getElementById('hundredthalone');
var thousandthalone = document.getElementById('thousandthalone');
var tenthousandthalone = document.getElementById('tenthousandthalone');

var upordown = document.getElementById('upordown'); 

var tenthousandcents = document.getElementById('tenthousandcents'); 
var thousandcents = document.getElementById('thousandcents');
var hundredcents = document.getElementById('hundredcents');
var tencents = document.getElementById('tencents');
var unitcents = document.getElementById('unitcents');
var tenthcents = document.getElementById('tenthcents');
var hundredthcents = document.getElementById('hundredthcents');
var thousandthcents = document.getElementById('thousandthcents');


frequencyalone = hundredthousandalone.value + tenthousandalone.value + thousandalone.value + hundredalone.value + tenalone.value + unitalone.value;

decimalalone = tenthalone.value + hundredthalone.value + thousandthalone.value + tenthousandthalone.value;

t0110.innerHTML = "<font color=blue><b>original frequency: " + parseFloat(frequencyalone + "." + decimalalone) + "</b></font>";

cents = tenthousandcents.value + thousandcents.value + hundredcents.value + tencents.value + unitcents.value;

decimalcents = tenthcents.value + hundredthcents.value + thousandthcents.value;

newmultiplier = Math.pow(2,parseFloat(cents + "." + decimalcents)/1200);

if (upordown.value == 1)
{
t0111.innerHTML = "<font color=blue><b>pitch shift in cents: " + "+" + parseFloat(cents + "." + decimalcents) + " </b></font>";
}
else
{
t0111.innerHTML = "<font color=blue><b>pitch shift in cents: " + "-" + parseFloat(cents + "." + decimalcents) + " </b></font>";
}


if (parseFloat(frequencyalone + "." + decimalalone) == 0 )
{
t0112.innerHTML = "&nbsp;<br>&nbsp;";
t0113.innerHTML = "<font color=red>please enter frequency in top row</font>"
}
else
{



if (upordown.value == 1)
{
newfrequency = parseFloat(frequencyalone + "." + decimalalone) * newmultiplier

t0112.innerHTML = "&nbsp;<br>&nbsp;";
t0113.innerHTML = "<font color=blue><b>new frequency: " + newfrequency.toFixed(4) + " </b></font>";

}
else
{
newfrequency = parseFloat(frequencyalone + "." + decimalalone) / newmultiplier;

t0112.innerHTML = "&nbsp;<br>&nbsp;";
t0113.innerHTML = "<font color=blue><b>new frequency: " + newfrequency.toFixed(4) + " </b></font>";

}

}

// harmonic calculator input

var notename = document.getElementById('notename');
var hundredthousandfundamental = document.getElementById('hundredthousandfundamental');
var tenthousandfundamental = document.getElementById('tenthousandfundamental'); 
var thousandfundamental = document.getElementById('thousandfundamental');
var hundredfundamental = document.getElementById('hundredfundamental');
var tenfundamental = document.getElementById('tenfundamental');
var unitfundamental = document.getElementById('unitfundamental');
var tenthfundamental = document.getElementById('tenthfundamental');
var hundredthfundamental = document.getElementById('hundredthfundamental');
var thousandthfundamental = document.getElementById('thousandthfundamental');
var tenthousandthfundamental = document.getElementById('tenthousandthfundamental');

frequencyfundamental = hundredthousandfundamental.value + tenthousandfundamental.value + thousandfundamental.value + hundredfundamental.value + tenfundamental.value + unitfundamental.value;

decimalfundamental = tenthfundamental.value + hundredthfundamental.value + thousandthfundamental.value + tenthousandthfundamental.value;

t0120.innerHTML = "<font color=blue><b>fundamental frequency: " + parseFloat(frequencyfundamental + "." + decimalfundamental) + "</b></font>";

notecharacter = noterow.charAt(notename.value*2);

if (noterow.charAt((notename.value*2)+ 1) == "n")
{noteinflection = " natural"}
else
{noteinflection = "# (enharmonic shown above)"}

t0120a.innerHTML = "<font color=blue><b>note name: " + notecharacter + noteinflection + "</b></font>";

var thousandharmonic = document.getElementById('thousandharmonic');
var hundredharmonic = document.getElementById('hundredharmonic');
var tenharmonic = document.getElementById('tenharmonic');
var unitharmonic = document.getElementById('unitharmonic');

harmonic = thousandharmonic.value + hundredharmonic.value + tenharmonic.value + unitharmonic.value;

if (parseFloat(harmonic) == 0)
{
t0121.innerHTML = "<font color=blue><b>harmonic: " + parseFloat(harmonic) + " </b></font>";
}
else
{
t0121.innerHTML = "<font color=blue><b>harmonic: " + parseFloat(harmonic) + " :  overtone: " + (parseFloat(harmonic) - 1) + " </b></font>";
}

if (harmonic == 0)
{
t0122.innerHTML = "<font color=red>harmonic must be an integer > 0</font>";
t0123.innerHTML = "&nbsp;";
t0124.innerHTML = "&nbsp;";
t0125.innerHTML = "&nbsp;";
t0126.innerHTML = "&nbsp;";
}

else
{
harmonicintervalincents = (Math.log(harmonic)*multiplier);

normalizedintervalincents = ( ( (harmonicintervalincents/1200) - Math.floor(harmonicintervalincents/1200) )*1200);

t0122.innerHTML = "<font color=blue><b>normalized interval in cents: " + normalizedintervalincents.toFixed(3) + "</b></font>";

normalizedfrequency = parseFloat(frequencyfundamental + "." + decimalfundamental) * Math.pow(2,parseFloat(normalizedintervalincents)/1200);

if (frequencyfundamental == 0)
{
t0123.innerHTML = "<font color=red>please enter frequency of fundamental</font>";

t0124.innerHTML = "&nbsp;";
t0125.innerHTML = "&nbsp;";
t0126.innerHTML = "&nbsp;";
}
else
{
t0123.innerHTML = "<font color=blue><b>normalized frequency of harmonic: " + normalizedfrequency.toFixed(4) + "</b></font>";

notenameshift = Math.round(parseFloat(normalizedintervalincents) / 100);

newnotename = parseFloat(notename.value) + notenameshift;

newnotecharacter = noterow.charAt((newnotename * 2));

if ( noterow.charAt((newnotename * 2)+ 1) == "n")
{
newnoteinflection = " (or enharmonic equivalent)"
}
else
{
newnoteinflection = "# (or " + (noterow.charAt((newnotename + 1) * 2)) + "b)"
}

t0124.innerHTML = "<font color=blue><b>closest note (in ET): " + newnotecharacter + newnoteinflection + "</b></font>";

frequencynearestnote = frequencyfundamental * ( Math.pow(2, (notenameshift/12)));

t0125.innerHTML = "<font color=blue><b>frequency of " + newnotecharacter + newnoteinflection + " (in ET): " + frequencynearestnote.toFixed(4) + "</b></font>"; 

t0126.innerHTML = "<font color=blue><b>closeness as percent (in ET): " + (((normalizedfrequency / frequencynearestnote )) * 100).toFixed(1) + "%</b></font>"; 
}
}

// fractional comma calculator

var hundredthousandtempered = document.getElementById('hundredthousandtempered');
var tenthousandtempered = document.getElementById('tenthousandtempered'); 
var thousandtempered = document.getElementById('thousandtempered');
var hundredtempered = document.getElementById('hundredtempered');
var tentempered = document.getElementById('tentempered');
var unittempered = document.getElementById('unittempered');
var tenthtempered = document.getElementById('tenthtempered');
var hundredthtempered = document.getElementById('hundredthtempered');
var thousandthtempered = document.getElementById('thousandthtempered');
var tenthousandthtempered = document.getElementById('tenthousandthtempered');

var basenotename = document.getElementById('basenotename');

frequencytempered = hundredthousandtempered.value + tenthousandtempered.value + thousandtempered.value + hundredtempered.value + tentempered.value + unittempered.value;

decimaltempered = tenthtempered.value + hundredthtempered.value + thousandthtempered.value + tenthousandthtempered.value;

if (parseFloat(frequencytempered + "." + decimaltempered) == 0)
{
t0130a.innerHTML = "<font color=red>&nbsp;</font>";
t0131.innerHTML = "<font color=red>please enter starting frequency</font>";
t0132.innerHTML = "<font color=red>&nbsp;</font>";
t0133.innerHTML = "<font color=red>&nbsp;</font>";
t0134.innerHTML = "<font color=red>&nbsp;</font>";
t0135.innerHTML = "<font color=red>&nbsp;</font>";
t0136.innerHTML = "<font color=red>&nbsp;</font>";
t0137.innerHTML = "<font color=red>&nbsp;</font>";

}
else
{

t0131.innerHTML = "<font color=blue><b>fundamental frequency: " + parseFloat(frequencytempered + "." + decimaltempered) + "</b></font>";

if((basenotename.value).substring(1,2) == 'n')
{basenoteinflection = " natural";}

if((basenotename.value).substring(1,2) == 's')
{basenoteinflection = " sharp";}

if((basenotename.value).substring(1,2) == 'b')
{basenoteinflection = " flat";}

t0130a.innerHTML = "<font color=blue><b>base note name: " + (basenotename.value).substring(0,1) + basenoteinflection + "</b></font>";

fifthcharacter = fifthrow.indexOf(basenotename.value);

// calculate note names of fifth above and fifth below

upperfifthcharacter = fifthrow.substring(fifthrow.indexOf(basenotename.value) + 2,fifthrow.indexOf(basenotename.value) + 4);

if((upperfifthcharacter).substring(1,2) == 'n')
{upperfifthinflection = " natural";}

if((upperfifthcharacter).substring(1,2) == '#')
{upperfifthinflection = " sharp";}

if((upperfifthcharacter).substring(1,2) == 'b')
{upperfifthinflection = " flat";}

lowerfifthcharacter = fifthrow.substring(fifthrow.indexOf(basenotename.value) - 2,fifthrow.indexOf(basenotename.value));

if((lowerfifthcharacter).substring(1,2) == 'n')
{lowerfifthinflection = " natural";}

if((lowerfifthcharacter).substring(1,2) == '#')
{lowerfifthinflection = " sharp";}

if((lowerfifthcharacter).substring(1,2) == 'b')
{lowerfifthinflection = " flat";}


// calculate pure and tempered fifth above

fifthabove = parseFloat(frequencytempered + "." + decimaltempered) * 3/2



t0132.innerHTML = "<font color=green><b>just 5th above (" + upperfifthcharacter.substring(0,1) + upperfifthinflection + "): " + fifthabove.toFixed(4) + "</b></font>";

var temperingfifthup = document.getElementById('temperingfifthup');

temperingfifthupcomma = (temperingfifthup.value).substring(0,1);

if (temperingfifthupcomma == "s")
{temperinga = syntoniccomma}
else
{temperinga = ditoniccomma}

temperingfifthupdirection = (temperingfifthup.value).substring(1,2);

upperfactora = (temperingfifthup.value).substring(3,5);

lowerfactora = (temperingfifthup.value).substring(6,8);

temperingfifthupfactor = parseFloat(upperfactora)/parseFloat(lowerfactora);

temperinga = Math.pow(temperinga,temperingfifthupfactor);

if (temperingfifthupdirection == "p")
{
temperinga = temperinga;

if (parseFloat(upperfactora) == 0)
{
widtha = "just ";
}
else
{
widtha = "tempered (widened) ";
}

}
else
{
temperinga = (1/temperinga);

if (parseFloat(upperfactora) == 0)
{
widtha = "just ";
}
else
{
widtha = "tempered (narrowed) ";
}

}

temperinga = fifthabove * temperinga;

t0134.innerHTML = "<font color=green><b>" + widtha + " 5th above: " + temperinga.toFixed(4) + "</b></font>";

t0136.innerHTML = "<font color=green><b>one octave lower: " + (temperinga/2).toFixed(4) + "</b></font>";

// calculate pure and tempered fifth below

fifthbelow = parseFloat(frequencytempered + "." + decimaltempered) * 2/3

t0133.innerHTML = "<font color=purple><b>just 5th below: (" + lowerfifthcharacter.substring(0,1) + lowerfifthinflection + "): " + fifthbelow.toFixed(4) + "</b></font>";

var temperingfifthdown = document.getElementById('temperingfifthdown');

temperingfifthdowncomma = (temperingfifthdown.value).substring(0,1);

if (temperingfifthdowncomma == "s")
{temperingb = syntoniccomma}
else
{temperingb = ditoniccomma}

temperingfifthdowndirection = (temperingfifthdown.value).substring(1,2);

upperfactorb = (temperingfifthdown.value).substring(3,5);

lowerfactorb = (temperingfifthdown.value).substring(6,8);

temperingfifthdownfactor = parseFloat(upperfactorb)/parseFloat(lowerfactorb);

temperingb = Math.pow(temperingb,temperingfifthdownfactor);


if (temperingfifthdowndirection == "p")
{
temperingb = temperingb;

if (parseFloat(upperfactorb) == 0)
{
widthb = "just ";
}
else
{
widthb = "tempered (widened) ";
}
}
else
{
temperingb = (1/temperingb);

if (parseFloat(upperfactorb) == 0)
{
widthb = "just ";
}
else
{
widthb = "tempered (narrowed) ";
}

}



temperingb = fifthbelow / temperingb;

t0135.innerHTML = "<font color=purple><b>" + widthb + "5th below: " + temperingb.toFixed(4) + "</b></font>";

t0137.innerHTML = "<font color=purple><b>one octave higher: " + (temperingb*2).toFixed(4) + "</b></font>";

}

}
