Logarithm: Logarithm of Positive Real Numbers
Logarithm: Logarithm of Positive Real Numbers
In mathematics, the logarithm of a number to a given base is the exponent to which the base
must be raised in order to produce that number. For example, the logarithm of 1000 to base 10 is
3, because 10 to the power of 3 is 1000: 103 = 1000. The logarithm of x to the base b is written
logb(x) such as log10(1000) = 3.
By the following formulas, logarithms reduce multiplication to addition and exponentiation to
products:
logb(x · y) = logb(x) + logb(y),
logb(xp) = p logb(x).
Three particular values for the base b are most common. The natural logarithm, the one with base
b = e, occurs in calculus since its derivative is 1/x. The logarithm to base b = 10 is called
common logarithm, while the base b = 2 gives rise to the binary logarithm.
The invention of logarithms is due to John Napier in the early 17th century. Before calculators
became available, via logarithm tables, logarithms were crucial to simplifying scientific
calculations. Today's applications of logarithms are numerous. Logarithmic scale reduces wide-
ranging quantities to smaller scopes; this is applied in the Richter scale, for example. In addition
to being a standard function used in various scientific formulas, logarithms appear in determining
the complexity of algorithms and of fractals. They also form the mathematical backbone of
musical intervals and some models in psychophysics, and have been used in forensic accounting.
Logarithms are also closely related to questions revolving around counting prime numbers.
Different routines are available to calculate logarithms, some designed for speedy calculations,
other ones for high accuracy. Logarithms have been generalized in various ways. The complex
logarithm applies to complex numbers instead of real numbers. The discrete logarithm is an
important primer in public-key cryptography.
Logarithm of positive real numbers
The logarithm of a number y with respect to a number b is the power to which b has to be raised
in order to give y. The number b is called base. In symbols, the logarithm is the number x solving
the following equation:
bx = y.[1]
The logarithm x is denoted logb(y). For b = 2, for example, this means
log2(8) = 3,
since 23 = 2 · 2 · 2 = 8. Another example is
since
The first equality is because a−1 is the reciprocal of a, 1 / a, for any number a unequal to zero.c[›]
A third example: log10(150) is approximately 2.176. Indeed, 102 = 100 and 103 = 1000. As 150
lies between 100 and 1000, its logarithm lies between 2 and 3. Ways of calculating the logarithm
are explained further down.
The logarithm logb(y) is defined for any positive number y and any positive base b which is
unequal to 1. These restrictions are explained below.
[edit] Logarithmic identities
Main article: Logarithmic identities
There are three important formulas, sometimes called logarithmic identities, relating various
logarithms to one another. The first is about the logarithm of a product, the second about
logarithms of powers and the third involves logarithms with respect to different bases.
[edit] Logarithm of a product
The logarithm of a product is the sum of the two logarithms. That is, for any two positive real
numbers x and y, and a given base b, the following equality holds:
logb(x · y) = logb(x) + logb(y).
For example,
log3(9 · 27) = log3(243) = 5,
5
since 3 = 243. On the other hand, the sum of log3(9) = 2 and log3(27) = 3 also equals 5. For y =
b, it yields
logb(x · b) = logb(x) + 1,
since logb(b) is 1, because b1 = b. In other words, multiplying the number x by the base b amounts
to adding one to its logarithm. In general, that identity is proven using the following relation of
powers and multiplication:c[›]
bs · bt = bs + t.
Substituting the particular values s = logb(x) and t = logb(y) gives
blogb(x) · blogb(y) = blogb(x) + logb(y).
The left hand side agrees with x · y. Indeed, the logarithm of x is the number to which the base b
has to be raised in order to yield x. That is to say:
x = blogb(x)
and a similar equality holds with y in place of x. Taking the base-b-logarithm of both sides yields
logb(x · y) = logb(blogb(x) + logb(y)) = logb(x) + logb(y).
Logarithms also convert divisions to subtractions:
for example
[edit] Logarithm of a power
The logarithm of the p-th power of a number x is p times the logarithm of that number. In
symbols:
logb(xp) = p · logb(x).
Also, logarithms relate roots to division:
As an example, the logarithm to base b = 2 of 64 is 6, since 26 = 64. But 64 is also 43 and indeed
3 · log2(4) = 3 · 2 equals 6. This formula can be derived by raising the afore-mentioned identity
x = blogb(x)
to the p-th power (exponentiation), which gives
xp = (blogb(x))p = bp · logb(x).
For the second equality, the identity (de)f = de · f was used.c[›] Thus, the logb of the left hand side,
logb(xp), and of the right hand side, p · logb(x), agree. The sought formula is proven.
[edit] Change of base
The following formula relates the logarithm of a fixed number x to one base in terms of the one
to another base:
This is actually a consequence of the previous rule, as the following proof shows: taking the
base-k-logarithm of the above-mentioned identity,
x = blogb(x),
yields
logk(x) = logk(blogb(x)).
By the previous rule, the right hand term equals logb(x) · logk(b). Dividing the preceding equation
by logk(b) shows the change-of-base formula. The division is possible since logkb ≠ 0. Indeed,
this logarithm cannot be zero, since k0 = 1, but b was supposed to be different than 1.
As a practical consequence, logarithms with respect to any base k can be calculated with a
calculator, if logarithms to any base b (often b = 10 or b = e) are available: logk(x) = log10(x) /
log10(k).
[edit] Particular bases
While the definition of logarithm applies to any positive real number b (excluding 1), a few
particular choices for b are more commonly used. These are b = 10, b = e (the mathematical
constant ≈ 2.71828…), and b = 2. The different standards come about because of the different
properties preferred in different fields. For example, it has been argued that base-10 logarithms
are easier to deal with than other ones, since in the decimal number system the powers of 10
have a simple representation.[2] Mathematical analysis, on the other hand, prefers the base b = e
because of the "natural" properties explained below.
The following table lists common notations for logarithms to these bases and the fields where
they are used. Instead of writing logb(x), it is common in many disciplines to omit the base and to
write log(x), when the intended base can be determined from the context. The notations
suggested by the International Organization for Standardization (ISO 31-11) are underlined in
the table below.[3] Given a number n and its logarithm logb(n), the base b can be determined by
the following formula:
This can be derived from the definition as the inverse function of ex, using the chain rule.[6] This
implies that the antiderivative of 1/x is ln(x) + C. An early application of this fact was the
quadrature of a hyperbolic sector, as shown at the right, by de Saint-Vincent in 1647. The
derivative with a generalised functional argument f(x) is
For this reason the quotient at right hand side is called logarithmic derivative of f. The
antiderivative of the natural logarithm ln(x) is
Derivatives and antiderivatives of logarithms to other bases can be derived therefrom using the
formula for change of bases.
[edit] Integral representation of the natural logarithm
The natural logarithm of t is the shaded area underneath the graph of the function f(x) = 1/x
(reciprocal of x).
The natural logarithm satisfies the following identity:
In prose, the natural logarithm of t agrees with the integral of 1/x dx from 1 to t, that is to say, the
area between the x-axis and the function 1/x, ranging from x = 1 to x = t. This is depicted at the
right. The formula is a consequence of the fundamental theorem of calculus and the above
formula for the derivative of ln(x). Some authors actually use the right hand side of this equation
as a definition of the natural logarithm and derive the formulas concerning logarithms of
products and powers mentioned above from this definition.[7] The product formula ln(tu) = ln(t) +
ln(u) is deduced in the following way:
The "=" labelled (1) used a splitting of the integral into two parts, the equality (2) is a change of
variable (w = x/t). This can also be understood geometrically. The integral is split into two parts
(shown in yellow and blue). The key point is this: rescaling the left hand blue area in vertical
direction by the factor t and shrinking it by the same factor in the horizontal direction does not
change its size. Moving it appropriately, the area fits the graph of the function 1/x again.
Therefore, the left hand area, which is the integral of f(x) from t to tu is the same as the integral
from 1 to u:
The second equality is using a change of variables, w := x1/r, while the third equality follows from
integration by substitution.
The sum over the reciprocals of natural numbers, the so-called harmonic series
is also closely tied to the natural logarithm: as n tends to infinity, the difference
converges (i.e., gets arbitrarily close) to a number known as Euler–Mascheroni constant. Little is
known about it—not even whether it is a rational number or not. This relation is used in the
performance analysis of algorithms such as quicksort, see below.[8]
[edit] Calculation
There are a variety of ways to calculate logarithms for practical purposes. One method uses
power series, that is to say a sequence of polynomials whose values get arbitrarily close to the
exact value of the logarithm. For high precision calculation of the natural logarithm, an
approximation formula based on the arithmetic-geometric mean is used. Algorithms involving
lookups of precalculated tables are used when emphasis is on speed rather than high accuracy.
Moreover, the binary logarithm algorithm calculates lb(x) recursively based on repeated
squarings of x, taking advantage of the relation
log2(x2) = 2 log2(x).
Finally, based on quick ways to calculate exponentials ey, the natural logarithm of x, that is the
solution a to
ea − x = 0
can also efficiently be calculated using Newton's method.[9]
While in some cases—such as log10(10.000) = 4—logarithms can be easy to compute, they
generally take less simple values: by the Gelfond–Schneider theorem, given two algebraic
The Taylor series of ln(z) at z = 1. The animation shows the first 10 approximations.
For real numbers z satisfying 0 < z < 2,b[›] the natural logarithm of z can be written as
[11]
The infinite sum means that the logarithm of z is approximated by the sums
to arbitrary precision, provided n big is enough. In the parlance of elementary calculus, ln(z) is
the limit of the sequence of these sums. This series is the Taylor series expansion of the natural
logarithm at z = 1.
[edit] More efficient series
Another series is
for complex numbers z with positive real part.[11] This series can be derived from the above
Taylor series. It converges more quickly than the Taylor series, especially if z is close to 1. For
example, for z = 1.5, the first three terms of the second series approximate ln(1.5) with an error
of about 3·10−6. The above Taylor series needs 13 terms to achieve that precision. The quick
convergence for z close to 1 can be taken advantage of in the following way: given a low-
accuracy approximation y ≈ ln(z) and putting A = z/exp(y), the logarithm of z is
ln(z) = y + ln(A).
The better the initial approximation y is, the closer A is to 1, so its logarithm can be calculated
efficiently. The calculation of A can be done using the exponential series, which converges
quickly provided y is not too large. Calculating the logarithm of larger z can be reduced to
smaller values of z by writing z = a · 10b, so that ln(z) = ln(a) + b · ln(10).
[edit] Arithmetic-geometric mean approximation
The natural logarithm ln(x) is approximated to a precision of 2−p (or p precise bits) by
[12][13]
Here M denotes the arithmetic-geometric mean and m is chosen so that s = x / 2m is bigger than
2p/2. The constants π and ln(2) can be calculated with particular series. The formula goes back to
Gauss.
[edit] Complex logarithm
Main article: Complex logarithm
Polar form of complex numbers
The complex logarithm is a generalization of the above definition of logarithms of positive real
numbers to complex numbers. Complex numbers are commonly represented as z = x + iy, where
x and y are real numbers and i is the imaginary unit. As was discussed above, given any real
number z ≠ 1, the equation
ea = z
has exactly one real solution a. However, there are infinitely many complex numbers a solving
this equation, i.e., multiple complex numbers a whose exponential equals z. This causes complex
logarithms to be different from real ones.
The solutions of the above equation are most readily described using the polar form of z. It
encodes a complex number z by its absolute value, that is, the distance r to the origin, and the
argument φ, the angle between the line connecting the origin and z and the x-axis. In terms of the
trigonometric functions sine and cosine, r and φ are such that
z = r · cos(φ) + i · r · sin(φ).[14]
The principal branch of the complex logarithm, Log(z). The hue of the color shows the argument
of Log(z), the saturation (intensity) of the color shows the absolute value of the complex
logarithm.
The absolute value r is uniquely determined by z by the formula but
there are multiple numbers φ such that the preceding equation holds—given one such φ,
φ' = φ + 2π
also satisfies the preceding equation. Adding 2π or 360 degreesd[›] to the argument corresponds to
"winding" around the circle counter-clock-wise by an angle of 2π. However, there is exactly one
argument φ satisfying −π < φ and φ ≤ π. It is called the principal argument and denoted Arg(z),
with a capital A.[15] (The normalization 0 ≤ Arg(z) < 2π also appears in the literature.[16]) It is a
fact proven in complex analysis that
z = reiφ.
Consequently, if φ is the principal argument Arg(z), the number number
a = ln(r) + i · (φ + 2nπ)
is such that the a-th power of e equals z, for any integer n. Accordingly, a is called complex
logarithm of z. If n = 0, a is called principal value of the logarithm, denoted Log(z). The
principal argument of any positive real number is 0; hence the principal logarithm of such a
number is a real number and equals the natural logarithm as defined above. In contrast to the real
case, analogous formula for principal values of logarithm of products and powers for complex
numbers do in general not hold.
The graph at the right depicts Log(z). The discontinuity, i.e., jump in the hue at the negative part
of the x-axis is due to the jump of the principal argument at this locus. This behavior can only be
circumvented by dropping the range restriction on φ. Then the argument of z and, consequently,
its logarithm become multi-valued functions.
[edit] Uses and occurrences
A tiling of the Poincaré disk of hyperbolic geometry by ideal triangles—their edges are shortest
"lines" in hyperbolic geometry.
In hyperbolic geometry the logarithm is used in measuring the distances between points. In the
Poincaré disk model, this causes the shortest connections between any two points to be either
segments of circles perpendicular to the boundary of the disk or lines through the origin, the
center of the circle.[18]
[edit] Logarithmic scale
Main article: Logarithmic scale
A logarithmic chart depicting the value of one Goldmark in Reichsmark during the German
hyperinflation in the 1920s.
Various scientific quantities are expressed as logarithms of other quantities, a concept known as
logarithmic scale. For example, the Richter scale measures the strength of an earthquake by
taking the common logarithm of the energy emitted at the earthquake. Thus, an increase in
energy by a factor of 10 adds one to the Richter magnitude; a 100-fold energy results in +2 in the
magnitude etc.[19] This way, large-scaled quantities are reduced to much smaller ranges. A second
example is the pH in chemistry: it is the negative of the base-10 logarithm of the activity of
hydronium ions (H3O+, the form H+ takes in water).[20] The activity of hydronium ions in neutral
water is 10−7 mol·L−1 at 25 °C, hence a pH of 7. Vinegar (typically around 5% w/v aqueous
solution of acetic acid), on the other hand, has a pH of about 3. The difference of 4 corresponds
to a ratio of 104 of the activity, that is, vinegar's hydronium ion activity is about 10−3 mol·L−1. In a
similar vein, the decibel (symbol dB) is a unit of measure which is the base-10 logarithm of
ratios. For example it is used to quantify the loss of voltage levels in transmitting electrical
signals[21] or to describe power levels of sounds in acoustics.[22] In spectrometry and optics, the
absorbance unit used to measure optical density is equivalent to −10 dB. The apparent magnitude
measures the brightness of stars logarithmically.[23]
Semilog graphs or log-linear graphs use this concept for visualization: one axis, typically the
vertical one, is scaled logarithmically. This way, exponential functions of the form f(x) = a · bx
appear as straight lines with slope proportional to b. In a similar vein, log-log graphs scale both
axes logarithmically.[24]
[edit] Psychology
In psychophysics, the Weber–Fechner law proposes a logarithmic relationship between stimulus
and sensation.[25] (However, it is often considered to be less accurate than Stevens' power law.[26])
According to that model, the smallest change ΔS of some stimulus S that an observer can still
notice is proportional to S. This gives rise to a logarithmic relation by the above relation of the
natural logarithm and the integral over dS / S. Hick's law proposes a logarithmic relation between
the time individuals take for choosing an alternative and the number of choices they have.[27]
Mathematically untrained individuals tend to estimate numerals with a logarithmic spacing, i.e.,
the position of a presented numeral correlates with the logarithm of the given number so that
smaller numbers are given more space than bigger ones. With increasing mathematical training
this logarithmic representation becomes gradually superseeded by a linear one—a finding
confirmed both in comparing second to sixth grade Western school children,[28] as well as in
comparison between American and indigene cultures.[29]
[edit] Probability theory and statistics
Distribution of first digits (in %, red bars) in the population of the 237 countries of the world.
Black dots indicate the distribution predicted by Benford's law.
Logarithms also arise in probability theory: tossing a coin repeatedly, it is known (by the law of
large numbers), that the "heads"-vs.-"tails"-ratio is approaching 0.5 as the number of tosses
increases. The fluctuations of this ratio around the limiting value are quantified by the law of the
iterated logarithm.
Logarithms are used in the process of maximum likelihood estimation when applied to a sample
consisting of independent random variables: maximizing the product of the random variables is
equivalent to maximizing the logarithm of the product, and in so doing one differentiates a sum
rather than a product.[30]
Benford's law, an empirical statistical description of the occurrence of digits in certain real-life
data sources, such as heights of buildings, is based on logarithms: the probability that the first
decimal digit of an item in the data sample is d (from 1 to 9) equals
log10(d + 1) − log10(d),
irrespective of the unit of measurement.[31] Thus, according to that law, about 30% of the data
can be expected to have 1 as first digit, 18% start with 2 etc. Deviations from this pattern can be
used to detect fraud in accounting.[32]
A log-normal distribution is one whose logarithm is normally distributed.[33]
[edit] Complexity
Quicksort sorts by choosing a pivot element (red), and sorts separately the items which are
smaller than this element and the ones which are bigger.
Logarithms arise in complexity theory, a branch of computer science which studies the
performance of algorithms.[34] They are prone to occur in describing algorithms which divide a
problem into two smaller ones, and join the solution of the subproblems.[35] For example, to find
a number in an sorted list, the binary search algorithm checks the middle entry and proceeds with
the half before or after the middle entry if the number is still not found. Similarly, the quicksort
algorithm sorts an array by dividing the array into halves and sorting these first, as shown in the
animation. These algorithms typically need time that is approximately proportional to log(N) and
N · log(N), respectively, where N is the length of the list.
A function f(x) is said to grow logarithmically, if it is (sometimes approximately) proportional to
the logarithm. (Biology, in describing growth of organisms, uses this term for an exponential
function, though.[36]) It is irrelevant to which base the logarithm is taken, since choosing a
different base amounts to multiplying the result by a constant, as follows from the change-of-
base formula above. For example, any natural number N can be represented in binary form in no
more than (log2(N)) + 1 bits. I.e., the amount of hard disk space on a computer grows
logarithmically as a function of the size of the number to store. Corresponding calculations
carried out using loge will lead to results in nats which may lack this intuitive interpretation. The
change amounts to a factor of loge2≈0.69—twice as many values can be encoded with one
additional bit, which corresponds to an increase of about 0.69 nats. A similar example is the
relation of decibel (dB), using a common logarithm (b = 10) vis-à-vis neper, based on a natural
logarithm.
[edit] Entropy
Entropy, broadly speaking a measure of (dis-)order of some system, also relies on logarithms. In
thermodynamics, the entropy S of some physical system is defined by
The sum is over all states i the system in question can have, pi is the probability that the state i is
attained and k is the Boltzmann constant. Similarly, entropy in information theory is a measure
of quantity of information. If a message recipient may expect any one of N possible messages
with equal likelihood, then the amount of information conveyed by any one such message is
quantified as log2 N bits.[37]
[edit] Fractals
The Sierpinski triangle (at the right) is constructed by repeatedly replacing equilateral triangles
by three smaller ones.
Logarithms occur in various definitions of the dimension of fractals.[38] Fractals are geometric
objects that are self-similar, i.e., that have small parts which reproduce (at least roughly) the
entire global structure. The Sierpinski triangle, for example, can be covered by three copies of it
having half the original size. This causes the Hausdorff dimension of this structure to be
log(3)/log(2) ≈ 1.58. The idea of scaling invariance is also inherent to Benford's law mentioned
above. Another logarithm-based notion of dimension is obtained by counting the number of
boxes needed to cover the fractal in question.
[edit] Number theory
Graph comparing π(x) (red), x / ln x (green) and Li(x) (blue).
Natural logarithms are closely linked to counting prime numbers, an important topic in number
theory. For any given number x, the number of prime numbers less than or equal to x is denoted
π(x). In its simplest form, the prime number theorem asserts that π(x) is approximately given by
in the sense that the ratio of π(x) and that fraction approaches 1 when x tends to infinity.[39] This
can be rephrased by saying that the probability that a randomly chosen number between 1 and x
is prime is indirectly proportional to the numbers of decimal digits of x. A far better estimate of
π(x) is given by the offset logarithmic integral function Li(x), defined by
The Riemann hypothesis, one of the oldest open mathematical conjectures, can be stated in terms
of comparing π(x) and Li(x).[40] The Erdős–Kac theorem describing the number of distinct prime
factors also involves the natural logarithm.
By the formula calculating logarithms of products, the logarithm of n factorial, n! = 1 · 2 · ... · n,
is given by
ln(n!) = ln(1) + ln(2) + ... + ln(n).
This can be used to obtain Stirling's formula, an approximation for n! for large n.[41]
[edit] Music
Logarithms appear in the encoding of musical tones. In equal temperament, the frequency ratio
depends only on the interval between two tones, not on the specific frequency, or pitch of the
individual tones. Therefore, logarithms can be used to describe the intervals: the interval between
two notes in semitones is the base-21/12 logarithm of the frequency ratio.[42] For finer encoding, as
it is needed for non-equal temperaments, intervals are also expressed in cents, hundredths of an
equally-tempered semitone. The interval between two notes in cents is the base-21/1200 logarithm
of the frequency ratio (or 1200 times the base-2 logarithm). The table below lists some musical
intervals together with the frequency ratios and their logarithms.
Frequency ratio r 2
1/6 1 ≈ 3.86 4 6 12
, i.e., corresponding
number of semitones
≈
16.67 100 400 600 1200
, i.e., corresponding 386.31
number of cents
[48]
It is related to the natural logarithm by Li1(z) = −ln(1 − z). Moreover, Lis(1) equals the Riemann
zeta function ζ(s).
The discrete logarithm is a related notion in the theory of finite groups. It involves solving the
equation bn = x, where b and x are elements of the group, and n is an integer specifying a power
in the group operation. Zech's logarithm is related to the discrete logarithm in the multiplicative
group of non-zero elements of a finite field.[49] For some finite groups, it is believed that the
discrete logarithm is very hard to calculate, whereas discrete exponentials are quite easy. This
asymmetry has applications in public key cryptography, more specifically in elliptic curve
cryptography.[50]
For p-adic numbers, the logarithm can also be defined via its Taylor series, which again has
radius of convergence equal to 1. This definition can be extended to all non-zero p-adic numbers.
Similarly, a p-adic exponential can be defined (though its domain is smaller than in the real or
complex case) and the p-adic logarithm is, once again, its inverse function.[51]
The logarithm of a matrix is the inverse function of the matrix exponential.[52]