# Dimensional analysis - application to logarithms

However, it still puzzles me that logarithm of some physical quantity has no units. Example, let's assume we have a collection of values of the distance between two cities. In set A, distances are expressed in km, while in set B distances are expressed in m.

If I apply a logarithmic transformation to both sets and compute the average and standard deviation I get two different values for the first parameter and the same for the latter.

The latter makes sense because I'm subracting logarithms and that is equal to a division operation so I get dimensionless values for the standard deviation.

For the average value I get different values. Assuming that the logarithmic transformation returns dimensionless values in principle I could sum the average values of sets A and B and get a number, however this doesn't make sense since sets A and B are not expressed in the same scale of length unit. Therefore one can argue that you must still somehow keep track of dimensions when you do logarithmic transformations or you might end up summing apples and oranges.

What is your take on the above?

The reason a logarithmic function, or an exponential function can't have dimensions is easy to see if you consider what the expression for a logarithm is in terms of a power series.

\begin{align} \ln x &= (x-1) - \frac{(x-1)^2}{2} + \frac{(x-1)^3}{3} + \cdots\\ &= \sum\limits_{n=1}^\infty \left((-1)^{n-1}\frac{(x-1)^n}{n}\right) \end{align}

If $$x$$ has dimensions (say of length), then it's clear that $$\ln x$$ is just a nonsensical physical quantity because its dimensions make no sense at all. So $$x$$, and hence $$\ln x$$, must be pure numbers.

A similar argument applies to exponentials:

$$\exp x = \sum\limits_{n=0}^\infty \frac{x^n}{n!}$$

So $$x$$, and $$e^x$$ must be dimensionless. This also applies to trig functions of course.

In particular this means you can't take the logarithm or exponential of any physical quantity: you can only ever take logarithms or exponentials or ratios of physical quantities, which are pure numbers.

Here's an example of taking logarithms in a legitimate way. If we have some quantity with a dimension, $$q$$, we can express it as $$q = xu$$ where $$x$$ is a pure number and $$u$$ is a unit of the same dimension as $$q$$. So if we want a quantity with the dimension of length we can express it as $$d\,\mathrm{mi}$$, where $$\mathrm{mi}$$ is a mile. So for any quantity with a dimension we can construct a pure number by dividing by the unit:

$$\frac{d\,\mathrm{mi}}{1\,\mathrm{mi}} = d$$

And it's fine to take logs of this. And using this technique we can do things like combining logarithms of quantities with different units:

$$\ln\left(\frac{x\,\mathrm{chain}}{1\,\mathrm{chain}}\right) + \ln\left(\frac{y\,\mathrm{furlong}}{1\,\mathrm{furlong}}\right) = \ln \left(xy \frac{\mathrm{chain}\,\mathrm{furlong}}{\mathrm{chain}\,\mathrm{furlong}}\right)$$

(A $$\mathrm{chain}\,\mathrm{furlong}$$ is an acre.)

The units don't have to be dimensionally the same even in cases like this

$$\ln\left(\frac{A\,\mathrm{acre}}{1\,\mathrm{acre}}\right) + \ln\left(\frac{m\,\mathrm{month}}{1\,\mathrm{month}}\right) = \ln \left(Am \frac{\mathrm{acre}\,\mathrm{month}}{\mathrm{acre}\,\mathrm{month}}\right)$$

Acre months might be a useful unit for computing rent on land, say.

• Appreciated the answer. Although I have a question on how to apply the statement you made in the last paragraph: If I apply logarithms to set A as log(x value in km / 1km) and to set B as log (x value in m / 1m) the confusion still remains... are you saying you cannot compute logarithms of values in kilometers only in meters (i.e. you need always to convert values to only one scale of unit)? Jan 22, 2019 at 12:02
• You can, but you need to be very careful. So say you have $\ln x + \ln y = \ln (xy)$, where $x$ is in inches and $y$ is in miles say. That's an area which is expressed in inch miles which could make sense in some cases (for instance if you are calculating the amount of paint you need to paint lines an inch wide on a road a number of miles long.
– user107153
Jan 22, 2019 at 12:20
• Now I'm a bit confused, sorry for this possible misunderstanding. Are you now saying ln of some quantity retains the units (you mentioned area when referring if I'm not mistaken to ln(xy)). Jan 22, 2019 at 12:27
• @jpcgandre, your comment reminds me of the various types of dB 'units', e.g., $\mathrm{dBm}$ and $\mathrm{dBmV}$ etc. The suffixes denote the reference value used to calculate the ratio, e.g., $1\,\mathrm{mW}$ and $1\,\mathrm{mV}$ respectively. I'm not sure if this goes to your confusion or not but if so, I'll be glad to elaborate in an answer. Jan 22, 2019 at 13:54
• @jpcgandre Yes, perhaps we should say something like the following: there's a difference between "dimensions" (what comes out of dimensional analysis for a quantity) and "units" (the scale one sets for measurements of that quantity). A quantity can have units while not having dimensions (e.g. units of degrees for angle), and a quantity can have dimensions while not having units (e.g. speeds when setting $c=1$). You can only take the log of dimensionless quantities; they can have units, though, as long as you keep track of them. Jan 22, 2019 at 14:57

Example, let's assume we have a collection of values of the distance between two cities. In set A, distances are expressed in km, while in set B distances are expressed in m. [I then] apply a logarithmic transformation to both sets...

Sure, but you're not taking the logarithms of the distances. Instead, you have a set $$S = \{x_j : j=1,\ldots,N\}$$ of a bunch of different distances, and you have two different reference lengths, $$R_1 = 1\:\rm km$$ and $$R_2 = 1\:\rm m$$, and you're then forming the new sets \begin{align} \tilde S_1 & = \left\{ \ln(x_j/R_1) : j=1,\ldots,N \right\} \quad \text{and} \\ \tilde S_2 & = \left\{ \ln(x_j/R_2) : j=1,\ldots,N \right\}, \end{align} since "take the logarithm of $$x_j$$ when expressed in kilometers" really means "take the quotient of the length $$x_j$$ and the length $$R_1=1\:\rm km$$, and then take the logarithm of that value".

These are different sets of numbers, so in principle there's no reason to expect them to be related.

Fortunately, however, the properties of the logarithm do allow us to say useful things about the relationship between these two transformed sets, since for every distance $$x_j$$ we have $$\ln\left(\frac{x_j}{R_2}\right) = \ln\left(\frac{x_j}{R_1}\frac{R_1}{R_2}\right) = \ln\left(\frac{x_j}{R_1}\right) + \ln\left(\frac{R_1}{R_2}\right),$$ where we know that $$\frac{R_1}{R_2}=1000$$, so therefore $$\ln\left(\frac{R_1}{R_2}\right)=\ln(1000)=3\ln(10) \approx 6.9$$.

In other words, the sets $$\tilde S_1$$ and $$\tilde S_2$$ are related to each other by a rigid translation; this makes a lot of sense, as the sets $$\{x_j/R_1 : j=1,\ldots,N\}$$ and $$\{x_j/R_2 : j=1,\ldots,N\}$$ are related by a scaling transformation, and logarithms turn scalings into translations.

In particular, the average of $$\tilde S_1$$, $$\mathbb E(\tilde S_1)$$ will be directly related to $$\mathbb E(\tilde S_1)$$ via $$\mathbb E(\tilde S_2) = \mathbb E(\tilde S_1) + \ln(1000).$$ Moreover, since translations don't affect the shape of the distribution, the standard deviation of both sets will be identical.

As for the more general question of why you cannot take logarithms of the $$x_j$$ directly, that's well-trod territory with a large number of answers on this site. See, for instance, my answer to Why is it "bad taste" to have a dimensional quantity in the argument of a logarithm or exponential function?, as well as the many questions on the Linked sidebar on the right.

• Hi, appreciated also your comprehensive reply. I understand the point and the formulation. My issue is with the statement that if logarithmic transformation does result in dimensionless values, then one can think (wrongly I assume) that you can perform meaningful operations with the resulting values, like summing the averages of logarithmic transformations of sets A and B.... If somehow the units are kept anyone would notice that A is expressed in different units than B.... Jan 22, 2019 at 14:45
• @jpcgandre Dimensional analysis is one possible tool to prevent you from making mistakes, but it is neither unique nor infallible in this role: it is not the only tool that does this, and it will not catch all possible mistakes. The fact that you can do something wrong without falling afoul of dimensional analysis is simply How Things Are. Jan 22, 2019 at 14:52
• Agree 100% with your comment Jan 22, 2019 at 14:54

The log is an exponent: if $$p=\log x$$ then $$e^p=x$$. There's nothing fundamentally different between one exponent or the other, and you would never think of the exponent of $$t^2$$ in $$x(t)=x_0+v_0t+\frac{1}{2}at^2$$ as having units.

When taking the log of $$A$$ and $$B$$, you need to express $$A$$ and $$B$$ in the same unit - say $$km$$ in your case. One then takes the log of not of the unitful $$A$$ but of the unitless $$A/km$$

In the case of $$x_0+v_0t+\frac{1}{2}at^2$$, it wouldn't make sense to obtain an equation for $$x(t)$$ if some of the time measurements were in seconds and others in microseconds: you'd convert everything to a single unit of time first, and only then you look for the power law: the exponent shouldn't depend on using seconds or microseconds, and the units are "put back" when expressing $$x$$ in meters, $$v$$ in $$m/s$$, $$t$$ in seconds etc.

• I agree, but as you mention "... it wouldn't make sense to obtain an equation for x(t) if some of the time measurements were in seconds and others in microseconds". So you need to have a sense of units, that's my point. Regardless of what the effect of transcendental functions is you need to keep track of units. Therefore, even though the transcendental functions are unitless there's no harm in including them even if just symbolic in your logic. Jan 22, 2019 at 14:51