Hacker News new | ask | show | jobs
by badlibrarian 9 hours ago
The first section is the good part.

The later reuse of “log” across valuations, dimension, vector fields, orders of vanishing is not so good. Those may be related ideas, but each needs a type signature: from what, to what, and preserving which operation?

1 comments

Or, to say a little more explicitly what you're getting at: when you take a logarithm of some quantity, log x, x absolutely must be unitless. There's no way whatsoever to take a logarithm of something with a unit attached. (This is an important and useful dimensional analysis check in formulas and long calculations!)

So what do you do in practice? You have to normalize: you don't calculate log x, but instead log x/U for some scaling unit U. It's typical for U to be something like 1 mV or 1 W in electrical engineering, for example. This is completely legitimate, but it does mean that the thing that comes out needs a corresponding unit attached to it: dBmV, dBW, et cetera.

And it's really kind of important to be careful about that.