Jurij Kovič's paper "The Arithmetic Derivative and Antiderivative" contains a curious remark in Section 1.2. Having just stated the definition of the logarithmic arithmetic derivative (L(n) = n′/n = Σj aj/pj where the prime mark indicates the arithmetic derivative, and Πipiai is the prime factorization of n), Kovič writes:
The logarithmic derivative is an additive function L(xy) = L(x) + L(y) for any x, y ∈ ℚ. Consequently, using a table of values L(p) = 1/p (computed to sufficient decimal places!) and the formula D(x) = L(x)·x, it is easy to find D(n) for n ∈ ℕ having all its prime factors in the table.
... a table of values? Did I read that correctly? Surely there must be some mistake; surely a paper published in 2012 can't expect us to rely on a printed table, for all the world as if we were John Napier in the seventeenth century! But never fear, dear reader, for the situation is easily rectified—with just a few lines of Python, you can take all the arithmetic derivatives you like on your own personal computing device.
Although first, we will need a function to find the prime factorization of a natural number. You can write your own, copy-paste someone else's, or (my personal favorite) use the subprocess module to call the system's /usr/bin/factor:
from subprocess import check_output def factorize(n): if n == 0 or n == 1: return {} output = check_output(["factor", str(n)]).decode('utf-8') factors = list(map(int, output.split(": ")[1].split(' '))) factorization = {(f, factors.count(f)) for f in set(factors)} return factorization
But then coding the definition of the arithmetic derivative itself is easy:
def D(n): result = 0 factorization = factorize(n) for p in factorization: term = 1 term *= p[1]*p[0]**(p[1]-1) for q in factorization: if q is not p: term *= q[0]**q[1] result += term return result
Leave a Reply