# What is the logarithm of a kilometer? Is it a dimensionless number?

In log-plots a quantity is plotted on a logarithmic scale. This got me thinking about what the logarithm of a unit actually is.

Suppose I have something with length $L = 1 \:\mathrm{km}$.

$\log L = \log \mathrm{km}$

It seems that the unit of $\log L$ is $\log \mathrm{km}$, but I can also say $L = 1000 \mathrm{\:m}$ and now:

$\log L = 3 + \log \mathrm{m}$

This doesn't appear to have any units at all.

This suggests that $\log \mathrm{km}$ and $\log \mathrm{m}$ are actually dimensionless numbers. But wait, I can do this with any unit! Does it actually make sense to talk about the logarithm of a unit, or some other function for that matter?

• Related (verging on a duplicate): Fundamental question about dimensional analysis. Aug 1 '11 at 14:44
• Agree with dmckee. The same logic holds: expand to Taylor series, and you see that you add ㎞ and ㎢ Aug 2 '11 at 10:42
• I think we need some examples of equations that do this, i.e. logarithms or powers of a quantity. Experience says in all equations arising from nature, the units combine to give a dimensionless number, e.g. in Planck's formula or Tsiolkovsky's rocket equation. Sep 7 '11 at 4:54
• It is also worth noting that a trigonometric function ought to applied in the same way, i.e. to unitless numbers. Otherwise, it does not make physical sense. Jul 28 '13 at 13:15
• $km$ is not some variable that is multiplied by $1000$ to give $1000km$ rather it is a base unit of $1 km$ a thousand times which gives $1000km$. As such you cannot detach the unit from the number and apply logarithmic rules to it; $\log L=1 + \log km$ or $\log L=3+\log m$ is nonsense. Jun 10 '16 at 10:56

This is a fun question. I have a hard time getting a good grip on the transformation that is $ln$ so I'll write things in terms of exponents.

$$\mathrm{value} = \ln(10\ \mathrm{ km})$$ $$e^{\mathrm{value}} = 10\ \mathrm{ km}$$

The number $e$ is, of course, unit-less. If I raise a number to a power, what are the permissible units of the power? If I write $x^2$, I have an intuitive assumption that $2$ has no units, because it is just a count used to express $x \times x = x^2$.

Thus, I have convinced myself of Carl's answer, and I would require a logarithm to have a reference to make sense. For example:

$$e^{\mathrm{value}} = \frac{ 10\ \mathrm{ km} }{1\ \mathrm{ km}}$$

The previous alternative of $e$ raised to a power equaling a physical quantity with real units seems like the perfect example of something that is nonsensical.

log plots

I have another question that stemmed from your question and I will try to answer it here. I specifically remember taking the derivative of log-log and linear-log plots in engineering classes. We had some justification for that, but it would appear to be nonsensical on the surface, so let's dive in. Here is an example of a log-log plot. I'll show the graph and then offer an equation of the line that is being represented.

Image source: Wikipedia

I'll start writing things from the basic $y=mx+b$ form, then change things as necessary. Since I'm using an arbitrary constant, I'll fudge it whenever necessary.

$$\log(p) = a \log(m) + b = a ( \log(m) + b' ) = a \log( b'' m ) = \log( b''^a m^a ) = \log\bigg( \frac{p_0}{m_0^a} m^a \bigg)$$ $$p = p_0 \left( \frac{m}{m_0} \right)^a$$

Like magic, a recognizable form comes through. Observing a linear relation in a log-log plot really means you're observing a power fit, not a linear fit. A student may still ask "but what are a and b", which is a bit more difficult. Firstly, I did no manipulation of $a$, so you can take the meaning directly from the final form, which is to say it's an exponent and thus unitless. For b:

$$b = a b' = a \log(b'') = a \log\bigg( \frac{p_0^{1/a}}{m_0} \bigg) = \log\left( \frac{p_0}{m_0^a} \right)$$

This shows that $b$ is also unitless, but it also gives interpretation to $p_0$, which is the reference y-value at some reference x-value ($m_0$). I'll move on to linear-log plot, or a semi-log scale.

Image source: J. Exp. Med. 103, 653 (1956).

I'll denote $f$ for "surviving fraction" and $d$ for dose. The equation for a regression that appears linear on the above plot will be the following.

$$\log(f) = a d + b$$ $$f = e^{a d + b} = e^b e^{a d} = f_0 e^{a d}$$

It's important to note here that $b$ had dubious units all along, just like in the log-log case, but it doesn't really matter because a more useful form comes out of the mathematics naturally. The value $f_0$ would be the baseline value (100% in this case) at $d=0$.

Summary: assuming a linear relation in log plots really makes the assumption that the actual relation follows some nonlinear form, and the units will work out once you do the mathematics, but the interpretation of the values may be nontrivial.

– user4552
Aug 7 '11 at 17:50
• @AlanSE: that's nice enough, but here's the thing: $e^\text{value}=\rm{\frac{10\,km}{1\,km}}$ implies $\text{value} = \ln\rm{\frac{10\,km}{1\,km}} = \ln(\rm{10\,km}) - \ln(\rm{1\,km})$, so it seems unavoidable that taking the log of a quantity with units must be meaningful. I like to think of $\ln(\rm{10,km})$ as having units of log-kilometres. Apr 10 '12 at 11:42
• Continuing that thought, log-units are weird in that (for example), subtracting one log-kilometer quantity from another one results in a dimensionless quantity, whereas dividing one by the other doesn't. Log-units follow different rules from normal ones, but that doesn't mean they couldn't be a useful concept. (Though I don't actually know of anyone using them.) Apr 10 '12 at 11:49
• Now that I've read the whole page I see that Ben Crowell and leftaroundabout had the same idea and take it a bit further in their answers. Apr 10 '12 at 11:57
• @Nathaniel That's interesting, but I can still mathematically remove the $km$ from the first equation and $value$ would still seem to be unitless to me. Sure, they can be log-km units, but that doesn't change the fact that a log-km unit... is 1. Even if it has units, it doesn't follow the ordinary rules of units as you've already noticed. So it seems the more simple explanation is that it's not a unit. Apr 10 '12 at 12:41

Yes, logarithms always give dimensionless numbers, but no, it's not physical to take the logarithm of anything with units.

Instead, there is always some standard unit. For your example, the standard is the kilometer. Then 20 km, under the log transformation, becomes $\ln(20\;\textrm{km}\;/\;\textrm{km}\;)$. Similarly, the log of 10 cm, with this scale is
$$\ln(10\;\textrm{cm}\;/10\;\textrm{km}\;) = \ln(10\times 10^{-3} / 10^{3}) = \ln(10^{-5})$$

• can you explain why it isn't physical to take the log of anything with units? Aug 1 '11 at 14:15
• @user: See the link I put in the comments on the question which addresses that issue directly. Aug 1 '11 at 14:45
• @dmckee nice link, but I was hoping to get a different view from Carl. I don't think people are getting to the heart of the question and are merely hand waving: "It's not physical to take the logarithm of anything with units" is easy to regurgitate from high-school physics. To offer physical insight into the why involves understanding. Aug 1 '11 at 16:54
• @user2146: the 'why' is justified by the Buckingham Pi Theorem: if you see $\ln(20 \text{km})$ somewhere in a physics equation, it means that there must be a counterterm $-\ln(16 \text{km})$ somewhere else. Aug 3 '11 at 12:41

Here's one "mathematical" but highly unphysical answer.

Using that $km\cdot km = (km)^2$ etc, we can formally define arithmetic of numbers with units over a graded algebra $A = \oplus_{k\in \mathbb{N}} V_k$ where $V_k = \otimes^k V$ where $V$ is treated as a one-dimensional real vector space ($V_0$ is the scalar $\mathbb{R}$). The choice of unit is the choice of a basis vector in $V$. $V_0$ is the pure scalars. So for each choice of a basis vector $v \in V$, we get mapping from the infinite sequence $\mathbb{R}^{\mathbb{N}}\to A$ realizing that sequence via $(r_k) \to [r_k]_v = \sum r_k (\otimes^k v)$. We define multiplication $V_k\times V_{k'} \to V_{k+k'}$ as usual.

(We won't define the negative power units for now. But they probably can be incorporated analogously.)

Then formally we can define $\exp: A \to A$ by the power series expansion

$$\exp a = \sum_{k = 0}^{\infty} \frac{1}{k!} a^k$$

where $a^k$ is defined in the sense of the graded algebra. And there, we have defined what it means for $\exp$ of something with units. Change of base of $\exp$ is handled by $y^a = \exp (\ln(y)\cdot a)$. And similarly the change of units is naturally incorporated, using the fact that a change of basis on a one dimensional real vector space is just multiplication by scalars. In other words, we have $[r_k]_v = [r'_k]_{v'}$ where $r_k = s^kr'_k$ when $v = s v'$.

Using this we can formally invert the power series expansion to find what $\ln$ "should" be. Fix a unit $v$. Take $(r_k) \in \mathbb{R}^{\mathbb{N}}$ and consider $[r_k]_v \in A$. To find $\ln [r_k]_v$ we need to find $(s_k)\in \mathbb{R}^{\mathbb{N}}$ such that

\begin{align} r_0 & = \exp s_0\\ r_1 & = e^{s_0} s_1 \\ r_2 & = e^{s_0} (s_2 + \frac{1}{2} s_1^2)\\ & \vdots \end{align}

(We can also use the Taylor expansion of $\ln$ around $1\in\mathbb{R}$ to get the expression for $(s_k)$ in terms of $(r_k)$.)

Unfortunately, even in this frame work $\ln 1 km$ is still not well-defined: in the image of $\exp$, $r_0$ is necessarily positive. Formally, it is possible to define $\ln (1 km) = \ln (1 + (1 km - 1))$ as the rather divergent, power series

$$\ln (1 m) = \sum \frac{(-1)^{k+1}}{k} (-1 + 1 (m))^k = \sum \frac{-1}{k} + \sum 1(m) - \sum \frac{k-1}{2} (m^2) + \cdots$$

Now some fun with divergent series: note that $\sum 1 = \sum (-1)^k(-1)^k = \sum (-1)^kx^k |_{-1}$ is the Taylor series expansion of $1/x$ around $x_0 = 1$ evaluated at $-1$, so the second term is nominally $\lim_{x\to 0+} 1/x$. So even if we regularise:

$$\lim_{\delta \to 0+} \ln (\delta + 1m) = \lim_{\delta \to 0+} \ln \delta + \delta^{-1} m + \cdots$$

is still heavily divergent.

(Observe, that, however, $\ln (1 + 1km) = \sum (-1)^{j+1}/j (km)^j$ is well defined as a formal power series.)

So what was the point of this post? This post is primarily addressed at the conclusion that $\log m$ is a "dimensionless number" as stated in the statement of the question. While in the usual arithmetic we are taught that we cannot add apples to oranges, that is only if we take the point of view of trying to add an object in the $\mathbb{Z}$-module of apples to a separate object in the $\mathbb{Z}$-module of oranges. If you are willing to work in the direct sum module of apples $\oplus$ oranges, you can indeed add apples to oranges.

Now, implicitly in asserting that $\log$ makes sense for objects with units, (and similarly that $\exp$ makes sense for objects of units), it is necessary that we already work in a system, that of the graded $\mathbb{R}$-algebra, in which you can add a scalar (an object with no units) to a vector (some object with units). So in asserting that you want to make sense of $\log km$, you cannot conclude from it that $3$ and $\log m$ must have the same units.

• Nice answer. I was just about to post something similar. Feb 20 '15 at 11:35
• You lost me pretty early on, but I'll take your word for it. :P Apr 19 '18 at 1:46

The best way to think about it is that a number like 1 km consists of a dimensionless 1 multiplied by a unit, km. When you take the log of a product, you get the sum of the logs, so log(1 km) is the same as log(1)+log(km). This shows that the log of 1 km is neither a dimensionless quantity nor a dimensionful one. If it was dimensionless, then it would be expressible without reference to any system of units. If it was dimensionful, then it would change by multiplication when the system of units was changed. It's neither of these things.

• 1 km isn't a number. 10 km consists of the number 10 and the definition of 1 in that system of units. Therefore, you decomposing log (1 km) into log(1) + log(km) lacks a sensible reason for doing so. Aug 7 '11 at 20:38
• @John McVirgo: "1 km isn't a number." Different people have different ways of thinking about this. Mathematicians would typically say that in x=1 km, 1 is the value of x, and the "km" is part of the definition of x. Scientists usually consider the "km" to be part of the value of x. This can all be formalized, e.g., you can define a group of SI units under multiplication, which is isomorphic to a three-dimensional vector space with one basis vector for each SI base unit.
– user4552
Aug 8 '11 at 15:26
• I found this to be a clever answer :) Aug 26 '11 at 12:24

It is something that's neither a physical quantity nor a dimensionless number, but something that can just be described as logarithm of a physical quantity. There is not much problem with this: let $\mathcal{P}$ be the space of physical quantities. We can span this space in a vectorspace-like manner by base-physical units (eg. SI) as described by Willie Wong. What's important: we know that we can't perform certain operations in this space, for instance we cannot add a mass to an electrical current. Addition of quantities $a,b\in\mathcal{P}$ is only defined if $a$ and $b$ have the same dimension, that is, if $\exists x\in\mathbb{R}$ such that $a=xb$. Multiplication is always defined and always yields a physical quantity again. (This also defines powers of physical quantities, but not what, say, the exponential of one of them is.)
We then know that $\mathbb{R}\subset\mathcal{P}$, since for, say, two lengths $a,b\in\mathcal{P}$ the ratio $\tfrac{a}b$ will be a dimensionless number. For these dimensionless quantities, the logarithm is defined right from the start.

It's quite simple to extend this to a full space $\ln\!\!\mathcal{P}\supset\mathbb{R}$: for $a\in\mathbb{R}\subset\mathcal{P}$, the logarithm is defined as usually. For $a\not\in\mathbb{R}$, we define the logarithm axiomatically: first we require $\ln\!\!\mathcal{P}$ to be an abelian group WRT addition, even a vector space over $\mathbb{R}$. Then, for $\lambda\in\mathbb{R}$, \begin{align} \ln(a^\lambda) &:= \lambda\ln(a) \end{align} and for $b\in\mathcal{P}$, $$\ln(ba) := \ln(b) + \ln(a).$$ Provided that $a$ and $b$ have the same dimension and therefore can be added, this already tells us the logarithm of the sum: we know that then $\exists x\in\mathbb{R}\colon b=ax$, in other words we can write any sum of physical quantities as a product of one of them with a real number, so the logarithm of any length cooks down to the logarithm of any one particular length, plus the logarithm of the ratio between the lengths.

Coming back to your question: what is the logarithm of a kilometre? The answer: $\ln(1\:\mathrm{km})=\ln(\mathrm{km})$. If you treat kilometres as the basis unit of length, then this is all you need. If you prefer metres or inches or whatever, you just get $$\ln(1\:\mathrm{km}) = \ln(1000\:\mathrm{m}) = \ln(1000) + \ln(\mathrm{m})$$ $$\ln(1\:\mathrm{km}) = \ln(\tfrac{1\:\mathrm{km}}{1"}\:\mathrm{"}) = \ln(\tfrac{1\:\mathrm{km}}{1"}) + \ln(\mathrm{"}) \approx 10.58 + \ln(\mathrm{"})$$ Here, $\ln(\mathrm{km}),\ln(\mathrm{m}),\ln(\mathrm{"})$ are not dimensionless numbers. Rather think of them as elements of a vector space that has the real numbers as a subspace.

• Yes, exactly! The dimension of a quantity is ultimately a description of how its numerical value changes when you change units; so, if you change from kilometres to metres, then you multiply a length by 1 thousand, multiply an area by 1 million, and add 3 to a common logarithm of a length. All of these are meaningful. Oct 17 '16 at 19:01
• The logarithm behaves differently from the others, but then so do the traditional units of temperature, and people manage to work with those. You just have to learn the rules. All of the people saying that you can't take a logarithm until you divide by a reference length (or otherwise obtain a dimensionless quantity) sound to me like the 2013-07-28 answer by Johannes, who says that you can't do any mathematics whatsoever except on dimensionless quantities! Of course you can, we do all the time, we all just need to learn how at some point. Oct 17 '16 at 19:04
• How do kilometers change when you change them to grams? This is not a complete idea; they (units) are also independent (orthogonal). Dec 4 '16 at 20:35

The closest thing to "Logarithm units" are decibels, which are 10 times the base 10 logarithm of a ratio. To put any physical quantity into a decibel-like unit, you need to first divide by some reference quantity. For example, the "decibel" unit for power is "dBm", which is the ratio of the power in question over 1 mW, expressed in dB:

$$P_{\rm dBm} = 10\ {\rm log_{10}} \left(\frac{P_{\rm mW}}{1\ \rm mW}\right)$$

Logarithmic function is readily used for transformation from one scale to another. Infact a scale/unit is a measurement and hence dimentionless, but to construe in physical sense we appropriate a unit relative to a absolute standard for the value to make sense and be reproducible. Thus answering your question. Log (x) is unitless, for all the mathematical operation performed are intrinsically unitless.. For better understanding i would like to give an imaginary example: "When i go running with my friend the distance between us is proportional to the speed my friend runs at" In this example the units on either side of equality are entirely arbitary depending on the formulation of situation it could well be dimentionless--m/s or lets say weather then celsius--m/s !

Hope this helps.

For an alternative view on the potential "dimensionless-ness" of the logarithm function, related to its relationship to integrals and derivatives of power functions, and its closeness to the $0$-th-power function. If one computes a primitive of $t^p$: $$\int t^p dt\,,$$ with $p \neq -1$, one gets, on well-set intervals:
$$\frac{1}{p+1} \times t^{p+1}\,.$$

Each time, one gains another dimension (or a power to the respective unit). When you differentiate, you loose dimensions up to degree $0$ for positive powers. For negative powers, this goes down to $-\infty$: for $p \neq 0$,

$$\frac{d(t^p)}{dt} = pt^{p-1}$$

Something is definitely going on around the zeroth power.

It is customary to set a zeroth-power of a non-null scalar $\alpha$ to $1$ ($\alpha^0=1$). If you now fix a non-null $t$, the coefficient of variation for a real $p$-power near $0$ goes like: $$\frac{e^{p \log t} - t^0}{p-0} \approx \frac{1 + p\log t - 1}{p}$$ as $p$ tends to $0$. Hence the $\log t$ behavior.

In a way, a constant is a limit behavior of the logarithm, or the other way around. Hence, the logarithm should be somehow unit-less.

There are similar concepts in statistical experimental data analysis. When you try to find a relationship between variables $y$ and $t$, and cannot find a linear one, some try to modify at least one variable with a power function. J. Tukey ("inventor" of the box-plot and the FFT) proposed the transformation ladder, or ladder of powers, by looking at $y = a+ bt^{p}$. A more satisfactory solution lies in the Box-Cox transform: if $\hat{t}$ denotes the geometric mean of $t$, and $\alpha$ some shift, then: $$t_\alpha^{(p)} = \frac{(t-\alpha)^p - 1}{p \hat{t}^{p-1}}$$ where you see that a good care is taken at keeping the same "unit" between $t_\alpha^{(p)}$ and $t$. Guess what? For $p=0$, they set $t_\alpha^{(0)} = \hat{t}\log (t+\alpha)$.

In a word, the $0$-th-power of a constant is $1$, the $0$-th-power of a variable is its $\log$. Somewhow.

References:

First, the question is a little ill-posed. In a log plot, for example, the quantities are (log X) km, not log(X km). We need to define the question further: What does it mean to "take a logarithm"? The logarithm, or any such function, is defined to take a real or complex number and give a new number based on a certain rule. Giving it something other than a number is a little like asking "How much does the number three weigh?"; it does not make sense because the function that gives the weight of an object does not accept numbers.

(Consider physical equations that involve physical quantities as arguments of logarithms, trigonometric functions, or as exponents. Experience tells us that, in equations arising from nature, the units of quantities within exponents and functions always combine to give a dimensionless number. Any meaningful expression must come from physical reasoning, so you would need to arrive at this question from physical reasoning as well..)

As Ben Cromwell noted in his comment, I am sure there are ways of representing units in mathematics.

• Actually you plot $\log (X/km)$ Sep 15 '15 at 9:20

My two cents is that this is a classic mix up of meta levels.

A kilometer is a measure on the ground of the earth. When we make a map, a meta level to the actual measure, the length on the map is maybe 1cm per ten kilometers, and we take that in our stride not wondering how it is possible. It is possible because we have very clearly the concept of the map being a meta level.

Suppose we make the map on a logarithmic scale ( funny maps of the globe exist depending on functions). This would mean that what would be marked as a kilometer on this map will be getting logarithmically larger as the real (non-meta) data increase in kilometers. The reason one uses meta levels for quantities that have units is for convenience, projecting the globe on a plane is convenient for what we want to do, though it distorts the relative size of the kilometer on the map , which our "intuition" wants constant.

When we are dealing with exponents and logarithms in physics equations we are very careful to have dimensionless numbers there. It is actually one of the tools, balancing units. Study the Boltzmann distribution as an example.

Somehow units in physics keep confusing people. A simple way to get out of this confusion is to realize that translating physics into math requires casting the problem into one dealing only with pure (so-called dimensionless) numbers.

This can be straightforward. Consider a simple pendulum. Deriving the time period for swinging the bob $t_{swing}$ requires us to cast the problem in math form. This forces us to work not with the time period itself, but with a dimensionless quantity like the ratio between $t_{swing}$ and some other time $t_0$. As a result we can derive equations like $$\frac{t_{swing}}{t_0} \ = \ f(..)$$ In case of a pendulum, the problem contains a time parameter in the form of the square root of its length divided by the local gravitational acceleration: $t_0 = \sqrt{l/g}$. So one attempts to find an expression of the form

$$\frac{t_{swing}}{\sqrt{l/g}} \ = \ f(..)$$

When doing the analysis for small swinging angles, it follows that $f(..) = 2\pi$.

In some other cases the number of parameters available in the problem is not sufficient to render the equation dimensionless. In such cases physicists fall back on generic physical parameters called units. Their sole purpose is to render all parameters in the mathematical equations dimensionless (pure numbers).

Physicists often violate against the rule that prescribes dimensionless math. So you will see equations like

$$x^2+y^2=r^2$$

Strictly speaking this is incorrect. However, people tend to interpret this as shorthand for $$(x/1m)^2 + (y/1m)^2 = (r/1m)^2$$

(or with any other length unit of choice in the denominator). This makes the equation again dimensionless. I would argue that what is really meant, however, is $$(x/r)^2 + (y/r)^2 = 1$$

Also equations like

$$\ln x - \ln r = 2 \pi$$

strictly speaking make little sense. Again, people might turn this nonsense into something meaningful by interpreting it as shorthand for

$$\ln (x/1m) - \ln (r/1m) = 2\pi$$

What is really meant, however, is

$$\ln(x/r) = 2\pi$$

The bottom line is that it makes no sense to have a bare length $x$ or a bare length $r$ in the equations. Neither does it make sense to have a bare $1m$ in there. It does make sense though to have a parameter $\frac{r}{1 m}$ or $\frac{x}{r}$. This is always the case, but it becomes more apparent when the function in question takes the shape of, for instance, a logarithm.