Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Algorithm to compute logarithms to any base

6 views
Skip to first unread message

Frederick Williams

unread,
Feb 6, 2013, 5:47:11 AM2/6/13
to
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.

--
When a true genius appears in the world, you may know him by
this sign, that the dunces are all in confederacy against him.
Jonathan Swift: Thoughts on Various Subjects, Moral and Diverting

Barry Schwarz

unread,
Feb 7, 2013, 12:20:59 AM2/7/13
to
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
0 new messages