Units and Logarithms

Part 0: Quantities, Dimensions, and Units

Units aren’t the primary focus of this post, but to make this accessible to a wider audience, I’ll try to explain them a bit here.

Measurements

Wikipedia defines a measurement as “the quantification of attributes of an object or event, which can be used to compare with other objects or events” and a quantity as “a property of a material or system that can be quantified by measurement.”

Quantifying basically means assigning a number, but what is that number supposed to mean?

That’s where units come in. Often times, there’s no good way to interpret a simple number as the outcome of a measurement, so a unit, in the broadest sense, is any well-defined way of converting any measurement of a given quantity into a number.

This is all a bit abstract, so let me give you some examples:

The last two examples gave us another important concept: Unit conversions.

Dimensions

If a unit can be given in terms of another unit (and vice versa), they are said to have the same dimension. This is not the kind of “dimension” you might be familiar with (the one in “2D” and “3D“), but something different and more abstract.
To go back to our examples:

A value like 10m10\,\mathrm{m} is called a dimensioned value. It always consists of a number and a unit which gives meaning to that number.

Note that two different quantities can have the same dimension, for example “length” and “width” both have the dimension of distance. Now, you might argue that “length” and “width” are really the same quantity, in which case I will add that “torque” and “energy” both have the same dimension as well and that most physicists will be able to tell you that those two are really distinct quantities.

This perfectly leads me to my next point: What quantities and what dimensions there are is subjective. A system of quantities (which is a bit of a misnomer) defines a set of dimensions to work with, but note that it is a definition. Similarly, you can define length and width to be the same. You can even define all quantities with the same dimension to be the same, in which case the two concepts “quantity” and “dimension” collapse into one.

A notorious example of this are several systems of quantities, used in physics, that are all grouped under the term natural units (which is also a misnomer since it’s also about dimensions and not just units).
One possible part of natural units is letting “distance” and “span of time” be the same dimension, in which case you can define cc (the speed of light in a vacuum) to be the plain number 11. Then, a second can be a measure of distance (the distance travelled by light in a vacuum in a second) and a meter can be a measure of time (the time it takes for light to travel a meter in a vacuum).

Another example, taken from the International System of Quantities (ISQ), which is the system of quantities used by most if not all scientists today, is the dimension amount of substance.
This could just be a number. In fact, its unit, the mole (mol), is defined such that 1 mol1\,\text{ mol} of a substance is equivalent to exactly 6.02214076×10236.02214076 \times 10^{23} molecules of that substance. However, the ISQ insists that these two things (amount of substance and number of molecules) have different dimensions. In my opinion, this is a bit weird, but there are two ways to think about this to make it less so:

  1. Try to separate “substance” from “molecules contained in it”. Essentially, this represents the approximation we all make at large scales, that matter isn’t made of individual particles but rather a single contiguous thing. The distinction between “amount of substance” and “number of molecules” then just reflects that distinction between the macroscopic and the microscopic world.

  2. If you’re willing to relax the interpretation of “amount of substance” a bit, you can also just define a unit “molecule” as 1/(6.02214076×1023) mol1/\left( 6.02214076 \times 10^{23} \right)\,\text{ mol} and treat that as the base unit instead. The dimension “amount of substance” could then be renamed “molecules” and it’d suddenly make a lot more sense.
    Note that the number of molecules could be a dimensionless quantity, but giving it a separate dimension is useful for dimensional analysis (which I’ll get to later).

Another example in the same vein is that of electrical charge. The commonly used unit for it is the Coulomb (C), but that was originally defined before we knew about electrons. Modern physics states that there is an elementary charge and that all electrical charges that can occur in the world are whole number multiples of that (ignoring quarks, but those are still charged a whole number of thirds of that and also never occur on their own).
So why don’t we use plain numbers to measure charge when there’s a clear and unambiguous way to do so? Because keeping the distinction is useful.

Finally, I’d like to convince you of another opinion of mine, which is that angles are not dimensionless either.
With how there are two commonly used units of angles, it should seem intuitive to give them their own dimension as well. In fact, angles can be thought about as measures of rotation, which should seem like enough of a distinct thing to be given its own dimension at this point.

Proportional Units

As I said before, two units of the same dimension can be used interchangably, by converting a value from one to the other. The procedure of conversion depends on both of the units, but let me give some examples again:

As you can see, there are many possible conversion procedures. In fact, you can define a unit using any such procedure you could ever come up with (given that it’s reversible).

Let’s look more closely at the first example for now.
You can think of the meter as a measuring stick (which it was for some time in the past) and the value xmx\,\mathrm{m} just says you how often that measuring stick fits inside your given distance (at least if it is a straight line). Of course, xx doesn’t have to be a whole number, but it should be clear how that works too.
Importantly, the expression xmx\,\mathrm{m} can be thought of as a multiplication, xmx \cdot \mathrm{m}. In this way, we can interpret “km” as a variable with the value 1000m1000 \cdot \mathrm{m}, or, alternatively, “m” as a variable with the value 0.001 km0.001 \cdot \text{ km} (It’s important to note that you can choose either one as the “basic” one and that this choice is arbitrary).

For this reason, I will call the units “m” and “km” proportional. The general definition would be “any two units of the same dimension whose conversion is a simple multiplication with a non-zero constant”.
(Note that this is true for one direction of conversion if and only if it is true for the other one.)

Note that the conversion equation naturally emerges from the proportionality of the two units: x km =x km =x(1000m)=(x1000)m=(1000x)m.x\,\text{ km } = x \cdot \text{ km } = x \cdot \left( 1000 \cdot \mathrm{m} \right) = (x \cdot 1000) \cdot \mathrm{m} = (1000 \cdot x)\,\mathrm{m}.

Can we think of all dimensioned values as products of number and unit? Not exactly.
Consider the second example and assume we could write both sides as products of number and unit: xK=(x273.15).x \cdot \mathrm{K} = (x - 273.15) \cdot ℃. First set x=1x = 1 to obtain K=272.15\mathrm{K} = - 272.15 \cdot ℃, then multiply by xx again to get xK=(272.15x),x \cdot \mathrm{K} = ( - 272.15 \cdot x) \cdot ℃, which is not at all what we had before.
The problem can already be seen in the previous equation, since not all terms on the right hand side are proportional to xx.

So how do we save this? Simple, really: Just limit with what units a dimensioned value can be thought of as a product. The procedure is quite trivial and works one dimension at a time:
Pick any unit you like from a given dimension and decree that dimensioned values with this unit can be seen as products. Then, all units (of the same dimension) that convert to/from that unit with a simple multiplication can have the same property, but no others.

In the case of temperature, it was decided that Kelvin would be the unit with this “product property”, so (in this system) you cannot write x=xx\, ℃ = x \cdot ℃.
The reason for this has to do with the concept of absolute temperature: There is a lowest possible temperature in the universe and it is, by definition, 0K0\,\mathrm{K}.
I could talk about this for a bit longer and try to justify it more, but the extent to which I’ve discussed it here should be enough for my purposes.

A quick aside about prefixes

There’s a standard way of forming units proportional to any given units and that is by using metric prefixes. Basically, you add a prefix to a unit’s name, which defines a new unit which is a pre-defined power of 10 times the base unit. You’re not supposed to combine these, instead there is a big list of them, enough to encompass basically every scientifically relevant order of magnitude. You can find the complete list on Wikipedia, but here are the first few:

Prefix (name)

Prefix (letter)

Multiplier it represents

deci-

d

0.1

centi-

c

0.01

milli-

m

0.001

deca-

da

10

hecto-

h

100

kilo-

k

1000

So for example, a millimeter has the symbol “mm” and is equal to 0.001m0.001\,\mathrm{m} and a hectopascal has the symbol “hPa” and is equal to 100 Pa100\,\text{ Pa}.

Dimensional Algebra

The thing about units being like constants is that you can do algebra with them.

First of all, you can divide units of the same dimension, for example kmmm =1000m0.001m=1000000mm=1000000.\frac{\text{ km}}{\text{mm }} = \frac{1000 \cdot \mathrm{m}}{0.001 \cdot \mathrm{m}} = 1000000\frac{\mathrm{m}}{\mathrm{m}} = 1000000.

Next comes the fun part: You can create new dimensions out of old ones by combining them with multiplication or division.
For example, the dimension “area” is given as the product of “distance” with itself, so a unit of area is m2=mm.\mathrm{m}^{2} = \mathrm{m} \cdot \mathrm{m}. Similarly, you can divide dimensions, for example “speed” is “distance” divided by “span of time”, a unit of which is m/s\mathrm{m}/\mathrm{s}.

The nice thing about this is how it transfers to dimensioned values. If you have a rectangle and measure its width ww and height hh, where both ww and hh are dimensioned values (both of dimension “distance“), then its area is simply given by A=wh.A = w \cdot h. Whatever units you measure ww and hh in will determine what unit the result will be. For example, if w=xmw = x\,\mathrm{m} and h=y dmh = y\,\text{ dm}, then you will get A=xmy dm =(xy)m(0.1m)=(xy)u,A = x \cdot \mathrm{m} \cdot y \cdot \text{ dm } = (x \cdot y) \cdot \mathrm{m} \cdot \left( 0.1 \cdot \mathrm{m} \right) = (x \cdot y)\, u, where u=0.1m2u = 0.1\,\mathrm{m}^{2}.

Note that prefixes conventionally apply inside a power, so dm2=(dm)2=(0.1m)2=0.01m2\text{dm}^{2} = \left( \text{dm} \right)^{2} = \left( 0.1 \cdot \mathrm{m} \right)^{2} = 0.01 \cdot \mathrm{m}^{2}.

Additionally, you can raise a single unit to any real number power, but that isn’t used very often with non-integers. For example, m=m0.5\sqrt{\mathrm{m}} = \mathrm{m}^{0.5} is a valid unit of dimension “square root of distance”. That dimension seems weird and wrong, but mathematically it works just like any other one. As for interpreting it, that’s left to equations involving it.

To illustrate this, think about the unit s2\mathrm{s}^{2}. What exactly is the square of time? Time-Area??? As stated, it’s hard to imagine what this could mean. But when divided by, this unit suddenly makes a lot of sense: The unit m/s2=(m/s)/s\mathrm{m}/\mathrm{s}^{2} = \left( \mathrm{m}/\mathrm{s} \right)/\mathrm{s} is a unit of acceleration, describing an acceleration in terms of how much speed (in units of m/s\mathrm{m}/\mathrm{s}) is added per second.

Anyway, from the math’s point of view, the previous paragraph wouldn’t have even been necessary. Products, Quotients and powers of units/dimensions are just defined abstractly and we work with them using the usual rules of algebra.

You might notice the abscense of addition and subtraction, and while you could define the sum or difference of dimensions in the same way, it isn’t really that useful in practice, so the usual stance is to say that only dimensioned values of the same dimension can be added or subtracted.
For those, we just define their sum/difference using distributivity (after expressing them in the same unit). Using the meter as an example again: (xm)±(ym)=(x±y)m.\left( x\,\mathrm{m} \right) \pm \left( y\,\mathrm{m} \right) = (x \pm y)\,\mathrm{m}.

Again, all of this only works because we said that dimensioned values are a product of a number and a unit. So be careful when working with units like ℃: It doesn’t have any of these properties because “℃” isn’t a free-standing variable, but rather only part of the notation xx\, ℃ for a dimensioned value, because we had previously defined the Kelvin to be the free-standing variable and the Degree Celsius is a unit of the same dimension as the Kelvin, but not proportional to it.

As an additional note, we can now see why I said that the dimension of dimensionless values could be said to be 1: Multiplying a dimensionless number xx with a dimensioned value ymy\,\mathrm{m} gives (xy)m(x \cdot y)\,\mathrm{m}, which should have the product of the dimensions of the input, but actually has the same dimension as the dimensioned input value.
That means that, from a mathematical perspective, the dimension of dimensionless values is the multiplicative identity for the product of dimensions, so it is apt to call it “1”.

Another note I’d like to add is that this dimensional Algebra has a really useful application called dimensional analysis (“analysis” here using the common meaning, not the one from “real analysis”).
By only looking at the dimensions of each variable in an equation, we have a quick way to find some mistakes. For example if I wanted to write down the Pythagorean Theorem, but forgot a power of 2, a2+b2=c,a^{2} + b^{2} = c, then I would replace all variables (and physical constants, but there are none here) by their dimensions and see that distance2+ distance2= distance.\begin{aligned} \text{ distance}^{2} + \text{ distance}^{2} & = \text{ distance}. \end{aligned} Since area = distance2\text{area } = \text{ distance}^{2}, I find the left hand side to be area + area = distance,\text{ area } + \text{ area } = \text{ distance}, and since addition of the same dimension is well-defined, this finally reduces to area = distance,\text{ area } = \text{ distance}, which is false.
Of course, this example is a bit silly. You don’t actually save any effort by using dimensional analysis here, but it’s good as an example to explain the process.

As another example, if I accidentally wrote a2+b3=c2,a^{2} + b^{3} = c^{2}, then I could see that, on the left hand side, I am adding an area to a volume, which we had previously forbidden.
This is actually the reason that we go as far as to forbid adding values of different dimensionalities: No part of physics actually deals with sums of differently dimensioned values, so if you encounter such a thing, you can be quite sure that it must have been an error on your part. (Of course, I’ll reiterate that it’s not mathematically impossible, but rather a very useful definition that this is illegal.)

Finally, let me say a word on functions.
In math, you usually only work with dimensionless values, so for most functions (on the real numbers) you need to check that the argument is dimensionless (which can also be said to be a part of dimensional analysis).

A particular example I want to point out is the exponential function, which can be defined as exp(x)=n=0xnn!=1+x+x22+x36+\exp(x) = \sum_{n = 0}^{\infty}\frac{x^{n}}{n!} = 1 + x + \frac{x^{2}}{2} + \frac{x^{3}}{6} + \cdots Note the sum of different powers of xx, which would be illegal if xx had any dimension other than 11.
The same is true for any power function f(x)=axf(x) = a^{x}.

Monomials like f(x)=axpf(x) = a \cdot x^{p} are fine, since they only consist of operations we defined for all dimensioned values, but general polynomials like f(x)=ax2+bx+cf(x) = ax^{2} + bx + c have the same issue again.

The way to use these with dimensioned values is to divide by a unit first, so for example exp(d/m)\exp(d/\mathrm{m}) would work if dd had dimension “distance”.

The same could be true for trigonometric functions like sin(θ)\sin(\theta) and cos(θ)\cos(\theta), but, as I said before, I think it’s better to define angles as having a dimension different from 1, so these functions would actually require their argument to be an angle, and not dimensionless.
(An issue with this is that exp(it)\exp(it) only works for dimensionless tt, which turns out to be the value of an angle in radians, but I don’t think that’s enough to refute my viewpoint.)

Part 1: Logarithms

After this long and arduous prologue, we’re finally ready to talk about logarithms (and this part will be laughably short in comparison).
Or maybe you skipped the previous section, in which case: Welcome aboard.

You might’ve learned in school that the function xbxx \mapsto b^{x} has an inverse (at least as long as b>0b > 0 and b1b \neq 1), called the logarithm to the base bb, xlogb(x)x \mapsto \log_{b}(x), which thus fulfills the equation logb(bx)=blogb(x)=x.\log_{b}\left( b^{x} \right) = b^{\log_{b}(x)} = x.

We can translate the three power rules b0=1,bxby=bx+y,(bx)y=bxy\begin{aligned} b^{0} & = 1, \\ b^{x} \cdot b^{y} & = b^{x + y}, \\ (b^{x})^{y} & = b^{x \cdot y} \end{aligned} into logarithm rules by setting x=bx,y=by\overset{\sim}{x} = b^{x},\overset{\sim}{y} = b^{y} and then applying logb\log_{b}: (1)logb(1)=logb(b0)=0,(2)logb(xy)=x+y=logb(x)+logb(y),(3)logb(xy)=yx=ylogb(x).\begin{aligned} & (1) & \log_{b}(1) & = \log_{b}\left( b^{0} \right) = 0, \\ & (2) & \quad\log_{b}\left( \overset{\sim}{x} \cdot \overset{\sim}{y} \right) & = x + y = \log_{b}\left( \overset{\sim}{x} \right) + \log_{b}\left( \overset{\sim}{y} \right), \\ & (3) & \log_{b}\left( {\overset{\sim}{x}}^{y} \right) & = y \cdot x = y \cdot \log_{b}\left( \overset{\sim}{x} \right). \end{aligned}

The logarithm rule we’ll be interested in is obtained by taking the equation x=blogb(x)x = b^{\log_{b}(x)} and applying logc\log_{c} to both sides: logc(x)=logc(blogb(x))=(3)logb(x)logc(b)logb(x)=logc(x)logc(b).\begin{aligned} \log_{c}(x) & = \log_{c}\left( b^{\log_{b}(x)} \right)\overset{(3)}{=}\log_{b}(x) \cdot \log_{c}(b) \\ \Longleftrightarrow \log_{b}(x) & = \frac{\log_{c}(x)}{\log_{c}(b)}. \end{aligned} Note that this holds for any cc (as long as logc\log_{c} is defined), so you can basically change the base of a logarithm to anything you want.

This allows us to use a “standard” base (usually Euler’s number ee) and define lnloge\ln ≔ \log_{e}, whence logb(x)=ln(x)ln(b).\begin{aligned} \log_{b}(x) & = \frac{\ln(x)}{\ln(b)}. \end{aligned} This allows us to rewrite the previous equation in the “trivial” form ln(x)ln(b)=ln(x)/ln(c)ln(b)/ln(c).\begin{aligned} \frac{\ln(x)}{\ln(b)} & = \frac{\ln(x)/\ln(c)}{\ln(b)/\ln(c)}. \end{aligned}

This is the point I want to get at. Think about meters and kilometers again. We know that km/m=1000\text{km}/\mathrm{m} = 1000, so, for a dimensioned distance d=x kmd = x\,\text{ km}, we have (x=)d/km =d1000m=d/m1000=d/mkm/m.(x = \,)\ d/\text{km } = \frac{d}{1000\,\mathrm{m}} = \frac{d/\mathrm{m}}{1000} = \frac{d/\mathrm{m}}{\text{km}/\mathrm{m}}.

Notice the similarity? dd is exactly analogous to ln(x)\ln(x) and “km” and “m” correspond to ln(b)\ln(b) and ln(c)\ln(c) respectively.
But that isn’t all. Note that ln\ln is still defined as a logarithm to a specific base. Why should we prefer one base over another? It’s the same thing as with units of distance: There’s no preferred unit, so it’s best to treat the dimensioned quantity abstractly, without giving its value in any concrete unit (except when calculating).

Thus, I propose to treat logarithms the same. For a positive real number xx, I define the abstract, dimensioned quantity log(x)\log(x) (with no base). Then, each other positive real number b1b \neq 1 defines a unit log(b)\log(b), such that the value of log(x)\log(x) in the unit log(b)\log(b) is log(x)log(b)=logb(x).\frac{\log(x)}{\log(b)} = \log_{b}(x). (Note that you’ll often see log(x)\log(x) without a base used to mean an implied base, most often ee or 10. This is not what I mean.)

This is particularly natural in information theory, where logarithms are already used in conjunction with units. There, you’ll see logarithms to the base 2 be referred to with the unit “bit(s)” and those to the base ee with the unit “nat(s)”. This is complete nonsense as practiced currently, however, since these “units” are just reminders what logarithm was used, and not actually units at all (they are equal to 11).

Using my new formalism, we can make these into actual units of the dimension “logarithm” by just defining nat =log(e),bit =log(2).\begin{aligned} \text{ nat } & = \log(e), \\ \text{bit } & = \log(2). \end{aligned} There’s another quantity that works perfectly in my framework, and that’s the bel (B), or its more commonly used brother the decibel (dB). This is just defined as B=log(10)\begin{aligned} \mathrm{B} & = \log(10) \end{aligned} and then dB =0.1B\text{dB } = 0.1\,\mathrm{B} as usual.

Using these definitions, we can have the perfectly coherent, properly dimensioned equation log(16)=4 bit 2.77 nat 12 dB.\log(16) = 4\,\text{ bit } \approx 2.77\,\text{ nat } \approx 12\,\text{ dB}.

Part 2: Logarithms of Units

Remember the part on the dimensional analysis of functions, where I said that exp(x)\exp(x) has to have a dimensionless argument.
The same could be said about log(x)\log(x).

But what if we don’t do that?

What if we just work with expressions like log(xm)\log(x\,\mathrm{m}) and see where that leads us?

Well, as a start we should work with units with the product property, so that we can apply logarithm rule (2) to get log(xm)=log(xm)=log(x)+log(m).\log(x\,\mathrm{m}) = \log(x \cdot \mathrm{m}) = \log(x) + \log(\mathrm{m}). (Note that I’m still using my dimensioned, base-less logarithm, but you can also apply this concept to logarithms with a base.)

The expression log(x)\log(x) is something we’re already familiar with: It’s a dimensioned value with dimension “logarithm”.
Now what about log(m)\log(\mathrm{m})?

Let’s just say that that also has the dimension “logarithm” so that we can keep our rule of only adding values of the same dimension.
You might object and say that there should be a new dimension, maybe call it “logarithm of distance”, but take another look at what we just derived. When we take the logarithm, the unit itself goes in a logarithm on its own. This is a single thing for each dimension.

In fact, using logarithm rule (3), we can see that for the power units mp\mathrm{m}^{p}, which, I want to emphazise, have a different dimension for each value of pp, we get log(mp)=plog(m).\log(\mathrm{m}^{p}) = p\log(\mathrm{m}).

Also, if we take the logarithm of a unit of speed, say m/s\mathrm{m}/\mathrm{s}, we get log(m/s)=log(ms1)=log(m)log(s).\log(\mathrm{m}/\mathrm{s}) = \log(\mathrm{m} \cdot \mathrm{s}^{- 1}) = \log(\mathrm{m}) - \log(\mathrm{s}).

The general picture is that the logarithm lets us see how the dimensional algebra actually defines a vector space structure on the set of dimensions.

When units come into the mix, that vector space gains a basis vector “1”, where the scaling factors go, e.g. log(km)=log(1000m)=log(1000)1+log(m).\log(\text{km}) = \log(1000\,\mathrm{m}) = \log(1000) \cdot 1 + \log(\mathrm{m}).

If all of that hasn’t blown your mind yet, let me have one more go.

Consider the unit “dBm”, which is used to describe power logarithmically.
(There are more such suffixed-decibel units, all defined analogously, so I’ll just stick to dBm here.)

The usual formula is Plog =10log10(P mW) dBm P_{\text{log }} = 10\log_{10}\left( \frac{P}{\text{ mW}} \right)\,\text{ dBm } where P/ mWP/\text{ mW} is the power in milliwatts and Plog =x dBmP_{\text{log }} = x\,\text{ dBm} is the logarithmic power, given in dBm as stated.

Now, apply our new framework to the numerical value xx given there.
First, expand log10\log_{10} into the base-less logarithm to get x=10log(P mW)log(10)=10log(P mW)B=log(P mW)dB.\begin{aligned} x & = 10\frac{\log\left( \frac{P}{\text{ mW}} \right)}{\log(10)} \\ & = 10\frac{\log\left( \frac{P}{\text{ mW}} \right)}{B} \\ & = \frac{\log\left( \frac{P}{\text{ mW}} \right)}{\text{dB}}. \end{aligned} Then, expand the quotient P/ mWP/\text{ mW} using the logarithm rules to get x=log(P mW1)dB =log(P)log(mW)dB.\begin{aligned} x & = \frac{\log\left( P \cdot \text{ mW}^{- 1} \right)}{\text{dB }} \\ & = \frac{\log(P) - \log(\text{mW})}{\text{dB}}. \end{aligned} Rearrange to get log(P)=x dB +log(mW).\begin{aligned} \log(P) & = x\,\text{ dB } + \log(\text{mW}). \end{aligned} Now, log(P)\log(P) is what we actually wanted to express when we defined PlogP_{\text{log}} above, so why not equate the two? That yields Plog =log(P)x dBm =x dB +log(mW).\begin{aligned} P_{\text{log }} & = \log(P) \\ \Longleftrightarrow x\,\text{ dBm } & = x\,\text{ dB } + \log(\text{mW}). \end{aligned} We now have a definition of “dBm” as a non-proportional unit, similar to ℃!
(Keep in mind that we shouldn’t think of x dBmx\,\text{ dBm} as a product, but rather just as notation.)

At this point, I can say that my excitement is immeasurable and my mind is blown.
I hope that you can say the same too.