For one octave, we double the frequency, so 400Hz to 800Hz is one octave higher. To get the tone that is perceived to be in the middle of those two frequencies is however not 600Hz but 400*1.059463⁶=~565Hz. However if I have arbitrary frequencies like 400 and 760Hz, how do I get the percived "middle" tone?
It depends on what precisely you mean by "middle tone," but from your example, it seems you mean to divide an octave in half to get the tritone in the center.
Mathematically, the quickest way to do this for any two frequencies is the geometric mean, rather than the arithmetic mean. The mathematical reason you need to do this (rather than use the arithmetic mean, i.e., simply adding and dividing by 2) is because frequencies map to pitches on a logarithmic scale, rather than a linear scale.
In any case, to find the geometric mean between two numbers, simply multiply them together and then take the square root. For your examples:
- For 400 and 800 Hz: square root of (400*800) = square root of 320000 = ~566 Hz
- For 400 and 760 Hz: square root of (400*760) = square root of 304000 = ~551 Hz
Note that for arbitrary frequencies, the result of this calculation will not necessarily fall on a "standard" musical pitch or make "normal" musical intervals within the 12-semitone per octave chromatic scale. But it will give you the frequency that is acoustically sort of the "middle" between any two frequencies.