# On Natural Analogarithms

Last year my fellow students and I spent a goodly portion of our free time considering the similarities of the relationships between sequences and series and those between derivatives and integrals[1][2][3][4]. During the course of our investigations we deduced a sequence form of the exponential function $$e^x$$, which stands alone in satisfying the equations
\begin{align*} D f &= f\\ f(0) &= 1 \end{align*}
where $$D$$ is the differential operator, producing the derivative of the function to which it is applied.
This set us to wondering whether or not we might endeavour to find a discrete analogue of its inverse, the natural logarithm $$\ln x$$, albeit in the sense of being expressed in terms of integers rather than being defined by equations involving sequences and series.

Now, a logarithmic function $$\log_b$$ is defined by the expression
$\forall x \; \log_b\left(b^x\right) = x$
where $$\forall$$ means for all. The constant $$b$$, which must be greater than one, is the base of the logarithm and when equal to $$e$$ yields the natural logarithm.
Note that it must also be true that
$b^{\log_b(x)} = x$
for any non-negative $$x$$, since there is but one value of $$y$$ for which
$x = b^y$
with $$b^{-\infty}$$ being equal to zero, and therefore
$b^{\log_b(x)} = b^{\log_b\left(b^y\right)} = b^y = x$
From this it trivially follows that
$\log_b\left(x_1 \times x_2\right) = \log_b\left(b^{\log_b\left(x_1\right)} \times b^{\log_b\left(x_2\right)}\right) = \log_b\left(b^{\log_b\left(x_1\right) + \log_b\left(x_2\right)}\right) = \log_b\left(x_1\right) + \log_b\left(x_2\right)$
for non-negative $$x_1$$ and $$x_2$$.

This is an extremely important property of logarithmic functions and consequently my fellow students and I were determined that any discrete analogues that we might make of them should exhibit it too.

### Prime Factorisation

It is a fundamental theorem of arithmetic that every integer greater than zero can be uniquely represented as a product of prime numbers, being those integers greater than one that may only be wholly divided by themselves and one, with the convention that one is the product of no primes. For example,
$3,600 = 2^4 \times 3^2 \times 5^2$
It is also the case that when multiplying integers we can recover the prime factorisation of their product by adding together the powers of the primes in their factorisations, treating missing primes as having a power of zero. For example
\begin{align*} 36 &= 2^2 \times 3^2\\ 100 &= 2^2 \times 5^2\\ 36 \times 100 &= 2^{2+2} \times 3^2 \times 5^2 = 2^4 \times 3^2 \times 5^2 = 3,600 \end{align*}
It was consequently rather tempting for my fellow students and I to define an integer logarithm to the base of a prime $$p$$, which we denoted as $$\mathrm{lf}_p$$, as the power to which that prime is raised in its factorisation, or zero if that prime doesn't appear. Returning to the above example, we have
\begin{align*} \mathrm{lf}_2(36) &= 2\\ \mathrm{lf}_2(100) &= 2\\ \mathrm{lf}_2(3,600) &= 4 = \mathrm{lf}_2(36) + \mathrm{lf}_2(100)\\ \mathrm{lf}_7(3,600) &= 0 = \mathrm{lf}_7(36) + \mathrm{lf}_7(100) \end{align*}
Whilst this displays the property that we wished to emulate, we cannot recover its argument by raising its base to its result
$2^{\mathrm{lf}_2(3,600)} = 2^4 = 16$
but must instead multiply every prime raised to the logarithm having it as its base of the argument.
$x = \prod_{p \in P} p^{\mathrm{lf}_p(x)}$
where $$\prod$$ is the product sign, $$\in$$ means within and $$P$$ is the set of all of the primes.
Noting that we can ignore any primes that are not in the factorisation of a number, we can therefore recover the argument in our example with
$2^{\mathrm{lf}_2(3,600)} \times 3^{\mathrm{lf}_3(3,600)} \times 5^{\mathrm{lf}_5(3,600)}= 2^4 \times 3^2 \times 5^2 = 3,600$
If we define a system of units $$\ell_p$$ to identify the results of logarithms to the base $$p$$, much as we use $$i$$ to represent the imaginary part of a complex number, then we can define an integer logarithm with respect to every prime with
$\mathrm{lp}(x) = \sum_{p \in P} \mathrm{lf}_p(x) \ell_p$
where $$\sum$$ is the summation sign and which, for our example, yields
$\mathrm{lp}(3,600) = 4 \ell_2 + 2 \ell_3 + 2 \ell_5$
Now, if we associate each $$\ell_p$$ with the real number $$\ln(p)$$ then we may assert that the exponential function is also the inverse of this logarithm since
$e^{\mathrm{lp}(x)} = e^{\sum_{p \in P} \mathrm{lf}_p(x) \ell_p} = \prod_{p \in P} e^{\mathrm{lf}_p(x) \ln(p)} = \prod_{p \in P} p^{\mathrm{lf}_p(x)} = x$
My fellow students and I assembled a deck of cards for Professor B------'s mathematical engine[5] to compute this logarithm employing repeated division by the prime numbers produced by its ak.primeSequence function, given in listing 1

Listing 1: The Integer Logarithm
function lp(x) {
var i = 0;
var l = [];
var p, k;

if(x!==ak.floor(x) || x<=0 || !isFinite(x)) {
throw new Error('invalid argument in lp');
}

while(x>1) {
p = ak.primeSequence(i++);
k = 0;
while(x%p===0) {++k; x /= p;}
if(k!==0) l.push({p: p, k: k});
}
return l;
}


and which deck 1 exercises for the integers from one to twenty.

Deck 1: Employing The Integer Logarithm

### Rationals And Beyond

With the observation that
$\frac{x}{y} = x \times y^{-1}$
for any numbers $$x$$ and $$y$$, we can extend this logarithm to rational numbers by allowing negative coefficients for the units $$\ell_p$$ so that
$\mathrm{lp}\left(\frac{x}{y}\right) = \mathrm{lp}\left(\frac{\prod_{p \in P} p^{\mathrm{lf}_p(x)}}{\prod_{p \in P} p^{\mathrm{lf}_p(y)}}\right) = \mathrm{lp}\left(\prod_{p \in P} p^{\mathrm{lf}_p(z)-\mathrm{lf}_p(y)}\right) = \sum_{p \in P} \left(\mathrm{lf}_p(x) - \mathrm{lf}_p(y)\right) \ell_p$
Furthermore, if we admit rational coefficients then we may generalise it to the roots of rationals, being those irrational numbers which, when raised to some positive integer power, produce rationals. This follows from the fact that
$\left(\prod_{p \in P} p^\frac{n_p}{d_p}\right)^{\prod_{p \in P} d_p} = \prod_{p \in P} p^{\frac{n_p}{d_p} \times \prod_{q \in P} d_q} = \prod_{p \in P} p^{n_p \times \prod_{q \in P \wedge q \neq p} d_q}$
where $$\wedge$$ means and, since the powers to which the primes are raised in the result are all integers and consequently the product must yield a rational number. Note that this implies that these factorisations of roots must also be unique for if they were not then we should have more than one prime factorisation of the rationals so produced.
Listing 2 generalises the lp function to roots of rationals by taking an ak.rational for its first argument and introducing an optional second argument indicating which root of it, if any, is desired

Listing 2: The Rational Root Logarithm
function lp(x, r) {
var i = 0;
var l = [];
var n, d, p, k;

if(ak.type(x)!==ak.RATIONAL_T) {
throw new Error('invalid argument in lp');
}
n = x.num();
d = x.den();
if(n<=0 || !isFinite(n)) throw new Error('invalid argument in lp');

if(ak.nativeType(r)===ak.UNDEFINED_T) {
r = 1;
}
else if(r!==ak.floor(r) || r<1 || !isFinite(r)) {
throw new Error('invalid root in lp');
}

while(n>1 || d>1) {
p = ak.primeSequence(i++);
k = 0;
if(n>1) while(n%p===0) {++k; n /= p;}
if(d>1) while(d%p===0) {--k; d /= p;}
if(k!==0) l.push({p: p, k: ak.rational(k, r)});
}
return l;
}


as demonstrated by deck 2.

Deck 2: Employing The Rational Root Logarithm

Finally, if we define a vector $$\boldsymbol{\ell}$$ of infinite dimension as
$\boldsymbol{\ell} = \begin{pmatrix} \ell_2\\ \ell_3\\ \ell_5\\ \vdots \end{pmatrix}$
so that its $$i^\mathrm{th}$$ element is the unit associated with the $$i^\mathrm{th}$$ prime number, then we can create a one to one correspondence between a root of a rational $$x$$ and an infinite dimensional rational vector $$\mathbf{x}$$ whose elements are its coefficients of the associated units in $$\boldsymbol{\ell}$$ since, as we have already reasoned, those coefficients are uniquely defined.
My fellow students and I therefore felt it appropriate to represent this correspondence with
$\mathbf{x} = \tfrac{\mathrm{lp}}{\boldsymbol{\ell}}(x)$
since
$\mathbf{x} \times \boldsymbol{\ell} = \sum_{p \in P} \mathrm{lf}_p(x) \times \ell_p = \mathrm{lp}(x)$
This affords us the opportunity to define functions of roots of rationals using linear algebra, such as the magnitude of a number $$x$$ in $$\boldsymbol{\ell}$$-space
$|x|_\boldsymbol{\ell} = \left|\tfrac{\mathrm{lp}}{\boldsymbol{\ell}}(x)\right| = \sqrt{\sum_{p \in P} \mathrm{lf}_p(x)^2}$
where $$|\mathbf{x}|$$ is the magnitude of the vector $$\mathbf{x}$$. For example
$\left|\frac{\sqrt{3}}{2}\right|_\boldsymbol{\ell} = \sqrt{\mathrm{lf}_2\left(\frac{\sqrt{3}}{2}\right)^2 + \mathrm{lf}_3\left(\frac{\sqrt{3}}{2}\right)^2} = \sqrt{\left(-1\right)^2 + \left(\tfrac12\right)^2} = \frac{\sqrt{5}}{2}$
Note that this must satisfy the relations
\begin{align*} \left|\frac{1}{x}\right|_\boldsymbol{\ell} &= \left|x\right|_\boldsymbol{\ell}\\ \left|x \times y\right|_\boldsymbol{\ell} &\leqslant \left|x\right|_\boldsymbol{\ell} + \left|y\right|_\boldsymbol{\ell} \end{align*}
since
\begin{align*} \mathrm{lp}\left(\frac{1}{x}\right) &= -\mathrm{lp}\left(x\right)\\ \mathrm{lp}\left(x \times y\right) &= \mathrm{lp}\left(x\right) + \mathrm{lp}\left(y\right) \end{align*}
and, by the triangle inequality
$|\mathbf{x}+\mathbf{y}| \leqslant |\mathbf{x}|+|\mathbf{y}|$
for all vectors $$\mathbf{x}$$ and $$\mathbf{y}$$.

Deck 3 plots the $$\boldsymbol{\ell}$$-space magnitude of consecutive rational numbers with a denominator of twelve, revealing it to be quite unlike the kinds of functions that we are accustomed to.

Deck 3: ℓ-Space Magnitudes Of Rationals

My fellow students and I are consequently rather keen to further explore its properties, but must wait until our studies afford us the time us to do so.
$$\Box$$

### References

[1] On A Calculus Of Differences, www.thusspakeak.com, 2017.

[2] Further On A Calculus Of Differences, www.thusspakeak.com, 2017.

[3] Further Still On A Calculus Of Differences, www.thusspakeak.com, 2017.

[4] Finally On A Calculus Of Differences, www.thusspakeak.com, 2017.

[5] On An Age Of Wonders, www.thusspakeak.com, 2014.