On Wed, 06 Feb 2013 10:47:11 +0000, Frederick Williams
<
freddyw...@btinternet.com> wrote:
>I'm looking for an algorithm to compute logarithms of real numbers > 0
>to any base > 1. Easy to understand would be nice, speed is less
>important.
Consider the natural log function ln:
1 - ln(i) = j iff e^j = i
Now consider the base b log function log_b:
2 - log_b(x) = y iff b^y = x
Since e^(ln b) = b this can be rewritten as
log_b(x) = y iff [e^ln(b)]^y = x
and standard exponent processing lets us rewrite this as
log_b(x) = y iff e^[y*ln(b)] = x
Substituting y*ln(b) for j and x for i in 1 above yields
ln(x) = y*ln(b) iff e[y*ln(b)] = x
Since the right had expression is true, the left one must be also.
y*ln(b) = ln(x)
y = ln(x) / ln(b)
From 2 we know that y = log_b(x) and therefore
log_b(x) = ln(x) / ln(b)
The literature amply describes ways to calculate ln(z) for positive z.
Once you have that algorithm implemented, you execute it twice (for x
and b) to produce the logarithm of x in base b.
--
Remove del for email