# Converting hertz to cents

I have encountered some unexpected results converting hertz to cents, and would like to know where the issue lies. The formulas are as entered in Excel.

``````Cents = 1200*LOG(Hertz,2)

Hertz = 2^(Cents/1200)
``````

Eg.

``````Perfect Fifth = 3/2 = 1.5

1200*LOG(1.5,2) = 701.955001 cents

2^(701.955001/1200) = 1.5 hz
``````

I also use the ABS function below, which converts negative to positive. This is because I am concerned with the size of variance, not whether it is high or low. Now for my problem:

1:

i)

``````Hertz (A) = 1.117

Hertz (B) = 1.125

= ABS(A-B) = 0.008 hz
``````

ii)

``````Hertz (C) = 1.7904

Herz (D) = 1.8

= ABS(C-D) = 0.0096 hz
``````

We can clearly see that ii is a larger value than i.

Lets do the same in Cents:

2:

i)

``````Cents (A) = 1200*LOG(1.117,2) = 191.555023

Cents (B) = 1200*LOG(1.125,2) = 203.91

=ABS(A-B) = 12.35 cents
``````

ii)

``````Cents (C) = 1200*LOG(1.7904,2) = 1008.3383

Cents (D) = 1200*LOG(1.8,2) =1017.5963

=ABS(C-D) = 9.258 cents
``````

Now we can clearly see that i is a larger value than ii, which is opposite to the results in 1, despite starting with the same hertz values. This should not be the case. Representing the same interval, hertz and cents should rise and fall by the same ratio. Is anyone able to identify where the problem lies? All responses are much appreciated.

• I would write "log₁₀" instead of "LOG" to distinguish from natural log, but that's just me.
– uhoh
Dec 25, 2019 at 4:07
• @uhoh: Note that it's not actually log base 10 here; it's actually log base 2. These are Excel formulas, with the base given after the comma inside the function. Dec 25, 2019 at 4:08
• @Athanasius ha! of course it is. So much for my drive-by comments while jumping SE sites, I was thinking about stellar magnitudes at the same time. Okay log₂ or log()/log(2) or log₁₀()/log₁₀(2) it is then!
– uhoh
Dec 25, 2019 at 4:18

The question has an underlying issue in naming the things it is converting. The formulas given in the question do NOT convert "Hertz to cents" but rather convert interval ratios to cents (and the reverse).

The problem can be seen in a couple different ways:

• The "Hertz numbers" used in the question are not simply numbers, but ratios, like 3/2 = 1.5 being a perfect fifth, 9/8 = 1.125 = a whole tone, etc. These are not Hertz per se, but ratios of frequencies (perhaps measured in Hertz, but one could measure them in any unit). In other words, they are dimensionless ratios, not "Hertz." [See NOTE below] One cannot simply add and subtract ratios to find the interval between those ratios. Instead one multiplies or divides them. For example, to "add" a perfect fifth and a perfect fourth, one multiplies `(3/2) * (4/3) = 12/6 = 2/1` (an octave). Adding the fractions `3/2+4/3 = 17/6` wouldn't give you anything having to do with the musical interval. Similarly, the subtractions you perform with the "Hertz numbers" (e.g., ABS(1.117-1.125)) have no musical interval meaning, nor do they have a direct relationship to frequencies measured in Hertz or otherwise.
• Logarithms have basic properties. When you perform a logarithm on two numbers you multiply, it is equivalent to adding the logarithms of the two individual numbers, i.e., LOG(A*B)=LOG(A)+LOG(B). Similarly, when you take a logarithm of two numbers you divide, it is equivalent to subtracting the logarithms, i.e., LOG(A/B)=LOG(A)-LOG(B). Thus, when you apply your "cents" function and take the logarithms, you can add or subtract the resulting amount of cents to find a larger or smaller musical interval. To take my previous example, 1200*LOG(3/2,2)=701.955 cents (as you note). For a perfect fourth, 1200*LOG(4/3,2)=498.045 cents. Adding these two values gives 1200 cents, which using your other formula 2^(1200/1200) gives 2 or the ratio 2/1, i.e., an octave, as we expect.

So, to fix your examples, note that it is meaningless to add or subtract the ratios A and B you call "Hertz" (but again, which are actually dimensionless ratios). If you wanted to find the difference between the size of intervals A and B, you would divide the ratios.

Thus:

1:

i)

Frequency Ratio (A) = 1.117

Frequency Ratio (B) = 1.125

Difference in Size = B/A = 1.007162 (Note this number is NOT measured in Hertz, it is also a frequency ratio.)

ii)

Frequency Ratio (C) = 1.7904

Frequency Ratio (D) = 1.8

Difference in Size = D/C = 1.00536

Now, if you convert these results to cents:

For B/A = 1200*LOG(1.007162,2) = 12.35 cents

For D/C = 1200*LOG(1.00536,2) = 9.258 cents

These calculations now agree with your results of subtracting the intervals as measured in cents.

NOTE: The ratios are potentially related to Hertz. For example, a 3/2 ratio is a perfect fifth. Any two frequencies in that ratio would create a perfect fifth, e.g., 300 Hertz to 200 Hertz = 300/200 = 3/2. Or 660 Hertz to 440 Hertz = 660/440 = 3/2. However, the 3/2 ratio is not measured in Hertz, as the units cancel out when you divide the two frequencies. Also, note that there is no direct mathematical way to convert a subtracted difference in Hertz to a difference in cents, as the same musical interval in cents will have difference sizes in its frequency difference in Hertz, depending on its location in the scale. (For details on the latter, see other answers here.)

• Thanks to all who commented. For reference, I am comparing 2/7 Comma Meantone to Just Intonation. (A) is Maj2 in 2/7 commma. (B) is Maj2 in Just. (C) is Min7 in 2/7 comma. (D) is Min7 in Just. So in subtracting A and B, I am trying to find the interval size difference between 2/7 comma and Just. It appears my mistake was using subtraction instead of division. Perhaps using the term hertz was also technically incorrect, but mathematically it is equivalent. Dec 26, 2019 at 0:43
• @ItHertz: Also, if you want to add the info you just posted in your comment to the end of your question by editing it, that would be the appropriate place to explain what you were doing (comparing particular intervals). It might be a helpful clarification in case anyone else comes along who wants to try to answer your question. Dec 26, 2019 at 1:16
• @ItHertz there are two major seconds in just intonation. One is 9/8 and the other is 10/9. Multiply them to get 5/4, the just major third. Dec 26, 2019 at 4:58

We interpret frequency on a logarithmic/exponential, not a linear, scale. As pitch goes up, the spacing between semitones increases, but we don't perceive the difference. Therefore, as pitch increases, the amount of Hz between adjacent pitches will increase while the amount of cents between them will stay fixed at 100.

This result is to be expected. The frequencies (Hertz) between two notes are mapped to the actual scales with the logarithm. It is explained here fairly well: https://en.wikipedia.org/wiki/Octave#Explanation_and_definition

From a low to a high octave, the frequency doubles. But it is always 12 semitones higher. (Or 1200 cents).

• So from one A at 440Hz to a higher of 880Hz, you go 1200 cents.

1200 * log2(880/440) = 1200 * log2(2) = 1200 * 1 = 1200

• And the same way from 220Hz to 440Hz there are also 1200 cents.

1200 * log2(440/220) = 1200 * log2(2) = 1200 * 1 = 1200

There is nothing wrong with the math.

Suppose you have three tones at 100, 200, and 300 Hz. The difference in frequency from 100 to 200, and 200 to 300, are equal.

But you don't hear "equal intervals". The interval between 100 and 200 Hz is an octave, but between 200 and 300 is a perfect fifth. An octave above 200 is 400, not 300.

"Cents" measure the size of intervals in (approximately) the same way that we hear them. Every octave is the same number of cents (1200), whether it is between 50 and 100 Hz or 5000 and 10000 Hz.

EDIT: To the commenter (and those who agree with him/her) that "the OP is not subtracting frequencies", what exactly are these expressions doing, except subtracting frequencies?

Hertz (A) = 1.117

Hertz (B) = 1.125

= ABS(A-B) = 0.008 hz

ii)

Hertz (C) = 1.7904

Herz (D) = 1.8

= ABS(C-D) = 0.0096 hz

• True, except OP is not subtracting frequencies, so there is something wrong with the math. Dec 24, 2019 at 13:56
• The OP's question is confused. OP says "Hertz" but doesn't mean Hertz. Re-read the first few paragraphs of the question, and it's clear that when OP says "1.5 Hertz" it actually means "perfect fifth ratio of 3/2," which is NOT Hertz. The rest of the question becomes clear once you realize that all of the numbers you cite in the edit are meant to be thought of like that "1.5." See my answer for details. (Sometimes to understand what a question is asking, one needs to realize that sometimes a literal reading is not what is meant, because the questioner is confused about a fundamental concept.) Dec 25, 2019 at 4:01
• "what exactly are these expressions doing, except subtracting frequencies": subtracting frequency ratios, which is not a meaningful operation. One clue there is that none of the so-called frequencies is anything close to audible as a pitch. Dec 26, 2019 at 5:02