Wednesday, March 3, 2010

One logarithm to rule them all

In technical material, one often comes upon logarithmic units of various sorts : decibels, astronomical magnitudes, nepers, bits, octaves, semitones, and so forth.

All of the logarithmic units of which I am aware are defined by an equation of the form

`\qquad\qquad\qquad x = R\cdot\log_a(Q_1/Q_0)\cdot"lgunit"`,

where
  • `R` is a simple nonzero rational number (positive or negative, often `1` or `-1`),
  • `a` is a base of logarithms, (in practice, this is always one of just three possibilities: `10`, `"e"`, or `2`,)
  • `Q_1` and `Q_0` are quantities, (`Q_0` is sometimes a fixed reference quantity,) and
  • `"lgunit"` is the particular logarithmic unit being defined by the equation.
While this is how logarithmic units are universally defined---even in standards documents---it is far from satisfactory.

In particular, it does not show the sense in which a logarithmic unit is, in fact, a unit.  In this posting, we look at a better way of doing this.

First, let us define the generic logarithm function, `"lg"(.)`.  A function is a object that, whenever you put something into it, you get something out.  For any given function, the thing you get out depends completely on what you put in.

A function is defined by the possible things you can put into it, i.e. the possible inputs, and then, for each such input, the output that the function gives, and also---this seems perverse at first---a given set of outputs that includes but which can be larger than the set of actual outputs.

The set of possible inputs is called the domain of the function.  The outputs that actually occur are called the image of the function.  The given output set---often a larger set that contains the image---is called the codomain of the function. 

Two functions are the same they share the same domain, the same codomain, and if for every possible input from the domain, they give the same output in the codomain.

It was once customary to talk about the range of a function, but this term is now little used---it was sometimes used to mean the image, and sometimes the codomain.

The domain of the generic logarithm, at least as we shall define it here, is the positive real numbers.

The codomain---and image---of the generic logarithm, is an otherwise unspecified set `L`.

The generic logarithm function is almost completely specified by the following, true for all real numbers `x>0` and `y>0`.  (The `almost` amounts to a continuity assumption that allows us to extend from rational powers to real powers.) :

`\qquad\qquad\qquad "lg"(x y) = "lg"(x) + "lg"(y).`

We already appear to be in difficulty.  Since we have not specified `L` to consist of numbers, or even of quantities, the equation just given defines how to add things in `L`.

The generic logarithm rather looks like a swindle.  What it says is, take a multiplication table, e.g. including stubs :

`\qquad\qquad\qquad[(xx,1,2,3),(1,1,2,3),(2,2,4,6),(3,3,6,9)]`.

Now replace number by the value of its generic logarithm, which is best thought of a kind of alter ego, or doeppelganger for the number :

`\qquad\qquad\quad[(\square,"lg"(1),"lg"(2),"lg"(3)),("lg"(1),"lg"(1),"lg"(2),"lg"(3)),("lg"(2),"lg"(2),"lg"(4),"lg"(6)),("lg"(3),"lg"(3),"lg"(6),"lg"(9))]`.

And now call the new table an addition table for the values of the logarithms :

`\qquad\qquad\qquad[(+,"lg"(1),"lg"(2),"lg"(3)),("lg"(1),"lg"(1),"lg"(2),"lg"(3)),("lg"(2),"lg"(2),"lg"(4),"lg"(6)),("lg"(3),"lg"(3),"lg"(6),"lg"(9))]`.

---all we have done is renamed everything in the table and called it an addition table.  Since we haven't required the various values to be distinct, this procedure cannot fail---at worst, we get an entire table full of zeroes, but no contradictions.

It isn't really a swindle, however, and it turns out that each positive number gets its own distinct logarithm :  what looks like mere rebranding turns out to have some content because multiplication of positive numbers behaves a great deal like addition of real numbers.

I find that it helps to have a mental picture of what generic logarithms do.  Pick any fixed positive real number `f \ne 1` as a base.  (I like to think of a small positive fractional tolerance `\epsilon`, and let `f = 1 + \epsilon`, so that `f` is slightly greater than `1`.)  Then any positive real number `x` can be written

`\qquad\qquad\qquad x = f^{p_x}`

for some real number `p_x`.  The subscript is to remind us that the value of `p_x` depends on the value of `x`.  `p_x` is the number of factors of `f` required to make `x` :

(We can even require `p_x` to be an integer, if we are content to tolerate a fractional error of about `\epsilon/2`,

`\qquad\qquad\qquad x \approx (1+\epsilon)^{p_x}`,

but there is no need to do this just yet.)

`p_x` is a measure of how powerful `x` is as a multiplier.  The specific size of `p_x` is not important---it depends not only on `x` but on the particular choice of `f`.  What is important is that, for any two positive real numbers `x` and `y`, if

`\qquad\qquad\qquad x = f^{p_x}` and `y = f^{p_y},`

then the ratio of `p_y` to `p_x` does not depend on the particular choice of `f`.

This is like the situation for physical quantities---the ratio of a pair of lengths, or a pair of weights, or a pair of electric currents does not depend on our particular choice of length unit, weight unit, or current unit.

Each positive real number, then, has its own particular multiplying strength, and that multiplying strength is a quantity.  The generic logarithm function takes in a positive real number as input, gives as output the multiplying strength of the number.

(In technical terms, `L`, the codomain of lg, is a one dimensional real vector space.  For comparison, the values of physical quantity 'electric current' also belong to a one dimensional real vector space. )

Indeed

`\qquad\qquad\qquad y = f^{p_y} = f^{p_x \cdot p_y/p_x} = (f^{p_x})^{p_y//p_x} = x^{p_y//p_x}`

In other words, the ratio of the multiplying strengths of `y` and `x` is the power one has to raise `x` to get `y`.  Since, e.g. `2^3 = 8`, the multiplying strength of `8` is three times the multiplying strength of `2`,

`\qquad\qquad\qquad "lg"(8) = 3 xx "lg"(2).`

Yet another way to write this is

`\qquad\qquad\qquad \log_2(8) = 3.`

Comparing these, we see that

`\qquad\qquad\qquad \log_2(8) = 3 = {"lg"(8)}/"lg"(2).`

This illustrates a general truth.  The following are equivalent, for all positive real numbers `x` and `b` and all real numbers `p` :
  • `x = b^p`,
  • `"lg"(x) = p "lg"(b)`,
  • `x` has `p` times the multiplying strength of `b`,
  • `\log_b(x) = p`,
  • `\frac{"lg"(x)}{"lg"(b)} = p`. 
From the last two of these, we have that

`\qquad\quad\qquad \log_b(x) = \frac{"lg"(x)}{"lg"(b)}.`

This connects the usual theory of logarithms to the generic logarithm.  The logarithm of a given number to a given base number is the ratio of their generic logarithms.  While generic logarithms are quantities rather than numbers, ratios of generic logarithms are numbers.

From this, we also get 

`\qquad\quad\qquad "lg"(x) = \frac{"lg"(x)}{"lg"(b)} xx "lg"(b) = \log_b(x) xx "lg"(b).`

It proves convenient to name some particular values of the generic logarithm :
  • `1" decade" = "lg"(10)`,
  • `1" neper" = "lg"("e")`,
  • `1" octave" = "lg"(2)`.
In that case,
`\qquad\qquad\qquad "lg"(x) = \frac{"lg"(x)}{"lg"(10)} xx "lg"(10) = \log_{10}(x)" decades",`

`\qquad\qquad\qquad\qquad\qquad = \frac{"lg"(x)}{"lg"("e")} xx "lg"("e") = \log_{"e"}(x)" nepers",`

`\qquad\qquad\qquad\qquad\qquad = \frac{"lg"(x)}{"lg"(2)} xx "lg"(2) = \log_{2}(x)" octaves".`

The decade (dec), neper (Np), and octave (oct) serve as different units of the single quantity `"lg"(x)` :

`\qquad\qquad "lg"(x)  = \log_{10}(x)" dec" = \log_{"e"}(x)" Np" = \log_{2}(x)" oct".`

This is somewhat similar to saying, for a line segment `U`,

`\qquad\qquad "length of "U = 1.5" yards" = 4.5" feet" = 54" inches".`

It would be possible, of course, to define three different quantities called, say, the yardiness, feetiness, and inchiness of a line segment `U`, and say that the yardiness of `U` is `1.5`, its feetiness is `4.5`, and its inchiness is `54`.

Of course that seems a little strange---but aren't we doing something rather similar when we say that the common logarithm of `1012` is slightly over `3`, its base `2` logarithm is just under `10`, and its natural logarithm is about `6.92`?

It seems preferable to have just one logarithm, the generic one, and to write, and also think :

`\qquad\qquad "lg"(1012)  \approx 3.005" dec" \approx 6.920 " Np" \approx 9.983 " oct".`

Another way to avoid having using multiple quantities is to strongly favor one unit, to the exclusion of other possibilities.  One could agree to avoid the use of yardiness and inchiness, favoring feetiness by default.  Or one could favor by default the base `"e"` (or 'natural') logarithm.

This latter trick works, as long as one is consistent.

Nothing in the definition of a length of, say, a foot, says that we cannot subsequently equate a foot to the number `1`.  If we do, than footiness and length become the same thing.

Similarly, there is nothing in the definition of the generic logarithm that prevents us from subsequently identifying, say, the neper with the number `1`.  In that case, the generic logarithm would be equivalent to the natural logarithm.

Both manoeuvres, equating length with footiness, or multiplying strength with the value of the natural logarithm, are a kind of cheat, however.

Such ideas as length and multiplying strength are best left without such encumbering identifications.  They are best kept generic.

    A continuous stripy multiplication table

    Sometimes, numbers and other quantities are used to count segments : "chapter one, chapter two, chapter three"; "first mile, second mile, third mile"; "first year, second year, third year".

    Sometimes, they are used to mark waypoints: "start (milestone 0), milestone 1, milestone 2, milestone 3"; "0 years old, first birthday, second birthday, third birthday".

    Sometimes, board games are played with pieces placed in the spaces: chess, draughts (checkers), snakes and ladders, noughts and crosses (tic-tac-toe).

    Sometimes, board games are played with pieces placed at the intersections: nine men's morris, go.

    In all of our multiplication tables so far, numbers have occupied cells in an array.

    Let us now fashion a multiplication table where the numbers are now thought of as labels for points.

    agraph
    width=400; height=400;
    xmin=(9.9); xmax=11.1;
    ymin=(-11.1); ymax=-9.9;
    marker = "none";
    marker = "dot";
    stroke = "none";
    markerfill = "blue";
    a=[];
    a[0]=[10,-10]; text([10,-10],"1",above);
    a[1]=[11,-10]; text([11,-10],"10",above);
    a[2]=[10,-11]; text([10,-11],"10",above);
    a[3]=[11,-11]; text([11,-11],"100",above);
    path(a);
    endagraph

    These four points are the corners of a square.  The idea now is to think of every point in the square as having a number, so that all the numbers form a continuous stripy multiplication table.  The line joining through the two `10` points consists of points that all have the value ten.  This is a stripe of the continuous table.

    We can mark some other points, to help see how things are working :

    agraph
    width=400; height=400;
    xmin=(9.9); xmax=11.1;
    ymin=(-11.1); ymax=-9.9;
    marker = "none";
    marker = "dot";
    stroke = "none";
    markerfill = "blue";
    a=[];
    a[0]=[10,-10]; text([10,-10],"1",above);
    a[1]=[11,-10]; text([11,-10],"10",above);
    a[2]=[10,-11]; text([10,-11],"10",above);
    a[3]=[11,-11]; text([11,-11],"100",above);
    a[4]=[10.5,-10.5]; text([10.5,-10.5],"10",above);
    a[5]=[10.25,-10.75]; text([10.25,-10.75],"10",above);
    a[6]=[10.75,-10.25]; text([10.75,-10.25],"10",above);
    path(a);
    markerfill = "yellow";
    b=[];
    b[0]=[10,-10.5];  text([10,-10.5],"3.16",above);
    b[1]=[10.25,-10.25];  text([10.25,-10.25],"3.16",above);
    b[2]=[10.5,-10];  text([10.5,-10],"3.16",above);
    b[3]=[10.5,-11];  text([10.5,-11],"31.6",above);
    b[4]=[10.75,-10.75];  text([10.75,-10.75],"31.6",above);
    b[5]=[11,-10.5];  text([11,-10.5],"31.6",above);
    path(b);
    markerfill = "red";
    c=[];
    c[0]=[10,-10.25]; text([10,-10.25],"1.78",above);
    c[1]=[10.25,-10]; text([10.25,-10],"1.78",above);
    c[2]=[10.25,-11]; text([10.25,-11],"17.8",above);
    c[3]=[10.5,-10.75]; text([10.5,-10.75],"17.8",above);
    c[4]=[10.75,-10.5]; text([10.75,-10.5],"17.8",above);
    c[5]=[11,-10.25]; text([11,-10.25],"17.8",above);
    path(c);
    markerfill = "green";
    d=[];
    d[0]=[10,-10.75]; text([10,-10.75],"5.62",above);
    d[1]=[10.25,-10.5]; text([10.25,-10.5],"5.62",above);
    d[2]=[10.5,-10.25]; text([10.5,-10.25],"5.62",above);
    d[3]=[10.75,-10]; text([10.75,-10],"5.62",above);
    d[4]=[11,-10.75]; text([11,-10.75],"56.2",above);
    d[5]=[10.75,-11]; text([10.75,-11],"56.2",above);
    path(d);
    endagraph

    This is clearly still a multiplication table of sorts.  To better emphasize continuity, we can drop all of our marker points except those on the perimeter of the square, and draw marker lines :

    agraph
    width=400; height=400;
    xmin=(9.9); xmax=11.1;
    ymin=(-11.1); ymax=-9.9;
    marker = "none";
    marker = "dot";
    stroke = "none";
    markerfill = "blue";
    a=[];
    a[0]=[10,-10]; text([10,-10],"1",above);
    a[1]=[11,-11]; text([11,-11],"100",above);
    path(a);
    stroke = "blue";
    aa=[];
    aa[0]=[11,-10]; text([11,-10],"10",above);
    aa[1]=[10,-11]; text([10,-11],"10",above);
    path(aa);
    markerfill = "yellow";
    stroke = "yellow";
    b=[];
    b[0]=[10,-10.5];  text([10,-10.5],"3.16",above);
    b[1]=[10.5,-10];  text([10.5,-10],"3.16",above);
    path(b);
    bb=[];
    bb[0]=[10.5,-11];  text([10.5,-11],"31.6",above);
    bb[1]=[11,-10.5];  text([11,-10.5],"31.6",above);
    path(bb);
    markerfill = "red";
    stroke = "red";
    c=[];
    c[0]=[10,-10.25]; text([10,-10.25],"1.78",above);
    c[1]=[10.25,-10]; text([10.25,-10],"1.78",above);
    path(c);
    cc=[];
    cc[0]=[10.25,-11]; text([10.25,-11],"17.8",above);
    cc[1]=[11,-10.25]; text([11,-10.25],"17.8",above);
    path(cc);
    markerfill = "green";
    stroke = "green";
    d=[];
    d[0]=[10,-10.75]; text([10,-10.75],"5.62",above);
    d[1]=[10.75,-10]; text([10.75,-10],"5.62",above);
    path(d);
    dd=[];
    dd[0]=[11,-10.75]; text([11,-10.75],"56.2",above);
    dd[1]=[10.75,-11]; text([10.75,-11],"56.2",above);
    path(dd);
    endagraph

    These marker lines are just a few of the continuous infinity of parallel lines that form the stripes of this table.

    Let the foregoing table be a single quilt square.  We can make copies of this square, some exact, and some multiplied by various whole powers of ten, and put them together like a quilt, to form a continuous, infinite, stripy multiplication table.

    To see how this is done, change the scale a bit, and consider the following powers-of-ten stripy multiplication table :

    agraph
    width=400; height=400;
    xmin=(9.8); xmax=13.2;
    ymin=(-13.2); ymax=-9.8;
    marker = "none";
    marker = "dot";
    stroke = "none";
    markerfill = "blue";
    a=[];
    a[0]=[10,-10]; text([10,-10],"0.01",above);
    a[1]=[11,-10]; text([11,-10],"0.1",above);
    a[2]=[10,-11]; text([10,-11],"0.1",above);
    a[3]=[12,-10]; text([12,-10],"1",above);
    a[4]=[11,-11]; text([11,-11],"1",above);
    a[5]=[10,-12]; text([10,-12],"1",above);
    a[6]=[13,-10]; text([13,-10],"10",above);
    a[7]=[12,-11]; text([12,-11],"10",above);
    a[8]=[11,-12]; text([11,-12],"10",above);
    a[9]=[10,-13]; text([10,-13],"10",above);
    a[10]=[13,-11]; text([13,-11],"100",above);
    a[11]=[12,-12]; text([12,-12],"100",above);
    a[12]=[11,-13]; text([11,-13],"100",above);
    a[13]=[13,-12]; text([13,-12],"1000",above);
    a[14]=[12,-13]; text([12,-13],"1000",above);
    a[15]=[13,-13]; text([13,-13],"10000",above);
    path(a);
    endagraph
    Put a copy of the preceding "single quilt square" table in the middle, and fit appropriate other quilt squares around it in all directions, selecting the appropriate power of ten multiplier for the quilt square so that edges match.

    The result is an infinite, continuous, stripy multiplication table.

    Take a horizontal or vertical line through this infinite table.  Each point on such a line has a number associated with it.  The numbers run from arbitrarily small positive numbers at one end of the line, to arbitrarily large positive numbers at the other.  A line so marked is called a logarithmic scale.  On a logarithmic scale, the integer powers of any given positive number are evenly spaced.

    The single quilt square multiplication table devised above, if given a quarter turn anticlockwise, is apparently the original log-log plot.  For details, see the article on Lalanne's Universal Calculator in Ron Doerfler's beautiful 2010 "Graphical Computing" calendar.

    I ran into Doerfler's calendar, and was introduced to Lalanne, three or four days after coming up with and using stripy continuous multiplication tables in lectures to give my liberal arts major classes a feel for logarithmic units.  I am familiar with log-log plots, but hadn't approached this in that light.

    As my father used to say, great minds think alike, but greater minds think first.

    Nor is this the first time Doerfler and I have crossed paths mentally.  A piece of Doerfler's writing, on calculating inverse hyperbolic tangents, proved useful in a physics paper I got published in the American Journal of Physics a few years ago.  That, too, was related to logarithms.