First, are you sure you want to do this? It makes sense to compensate for some things, such as the microphone’s reaction is not flat, not human perception. People are used to hearing sounds with spectral content that sounds have in the real world, and not from perceptual equal volume curves. If you play a sound that you have changed the way you think it sounds strange. Perhaps some people like music to improve low frequencies, but this is a matter of taste, not psychophysics.
Or maybe you compensate for some other reason, for example, taking into account the lower sensitivity to lower frequencies, it can improve the compression algorithm. Is that an idea?
If you want to normalize by equal volume curves, it should be noted that most of the curves and equations relate to sound pressure level (SPL). SPL is a log of the square of the wave amplitude, so when you work with FFT, it is probably easiest to work with your square (power spectra). (Or, of course, you could compensate in other ways, for example, by multiplying by sqrt (log (i + 1)) in your equation above - assuming that the log was an approximation of the inverse curve of equal loudness.)
tom10 source share